From 59429aa449cf988a1ea9d4b387f8878436c84b3f Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sat, 25 Sep 2010 09:32:52 +0000 Subject: [PATCH] Change the policy used to select files added in the import list of the generated configuration. Use all files listed as modules of eval-config. svn path=/nixos/trunk/; revision=23914 --- .../installer/cd-dvd/installation-cd-base.nix | 18 +----- modules/profiles/installation-device.nix | 56 +++++++++++++++---- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/modules/installer/cd-dvd/installation-cd-base.nix b/modules/installer/cd-dvd/installation-cd-base.nix index 23c1e02be43..0df44fac116 100644 --- a/modules/installer/cd-dvd/installation-cd-base.nix +++ b/modules/installer/cd-dvd/installation-cd-base.nix @@ -7,21 +7,6 @@ with pkgs.lib; let - options = { - - # you can retrieve the profiles which have been used by looking at the - # list of modules use to configure the installation device. - installer.configModule = mkOption { - example = "./nixos/modules/installer/cd-dvd/installation-cd.nix"; - description = '' - Filename of the configuration module that builds the CD - configuration. Must be specified to support reconfiguration - in live CDs. - ''; - }; - }; - - # We need a copy of the Nix expressions for Nixpkgs and NixOS on the # CD. We put them in a tarball because accessing that many small # files from a slow device like a CD-ROM takes too long. !!! Once @@ -45,8 +30,7 @@ in { require = - [ options - ./memtest.nix + [ ./memtest.nix ./iso-image.nix # Profiles of this basic installation CD. diff --git a/modules/profiles/installation-device.nix b/modules/profiles/installation-device.nix index 32f356cdd29..cea967cc36d 100644 --- a/modules/profiles/installation-device.nix +++ b/modules/profiles/installation-device.nix @@ -1,21 +1,40 @@ -{config, pkgs, ...}: +# Provide a basic cponfiguration for installation devices like CDs. +{config, pkgs, modules, ...}: with pkgs.lib; let # Location of the repository on the harddrive - profilePath = toString ./.; + nixosPath = toString ../../.; # Check if the path is from the NixOS repository - isProfile = path: + isNixOSFile = path: let s = toString path; in - removePrefix profilePath s != s; + removePrefix nixosPath s != s; - # Rename NixOS modules used to setup the current device to make findable form - # the default location of the configuration.nix file. - getProfileModules = - map (path: "./nixos/modules/profiles" + removePrefix isProfile (toString path)) - filter (m: isPath m && isProfile m) modules; + # Copy modules given as extra configuration files. Unfortunately, we + # cannot serialized attribute set given in the list of modules (that's why + # you should use files). + moduleFiles = + filter isPath modules; + + # Partition module files because between NixOS and non-NixOS files. NixOS + # files may change if the repository is updated. + partitionnedModuleFiles = + let p = partition isNixOSFile moduleFiles; in + { nixos = p.right; others = p.wrong; }; + + # Path transformed to be valid on the installation device. Thus the + # device configuration could be rebuild. + relocatedModuleFiles = + let + relocateNixOS = path: + "/etc/nixos/nixos" + removePrefix nixosPath (toString path); + relocateOthers = null; + in + { nixos = map relocateNixOS partitionnedModuleFiles.nixos; + others = []; # TODO: copy the modules to the install-device repository. + }; # A dummy /etc/nixos/configuration.nix in the booted CD that # rebuilds the CD's configuration (and allows the configuration to @@ -28,7 +47,9 @@ let {config, pkgs, ...}: { - require = [${toString config.installer.cloneConfigIncludes}]; + require = [ + ${toString config.installer.cloneConfigIncludes} + ]; # Add your own options below and run "nixos-rebuild switch". # E.g., @@ -61,10 +82,23 @@ in List of modules used to re-build this installation device profile. ''; }; + + # Ignored. Kept for Backward compatibiliy. + # you can retrieve the profiles which have been used by looking at the + # list of modules use to configure the installation device. + installer.configModule = mkOption { + example = "./nixos/modules/installer/cd-dvd/installation-cd.nix"; + description = '' + Filename of the configuration module that builds the CD + configuration. Must be specified to support reconfiguration + in live CDs. + ''; + }; }; config = { - installer.cloneConfigIncludes = getProfileModules; + installer.cloneConfigIncludes = + relocatedModuleFiles.nixos ++ relocatedModuleFiles.others; # Show the manual. services.nixosManual.showManual = true;