From d1e87dfc86b71b1b238ccdb5696044c1a89b81ad Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Wed, 28 Apr 2010 14:55:26 +0000 Subject: [PATCH] =?UTF-8?q?adding=20two=20new=20options:=20-=20system.copy?= =?UTF-8?q?SystemConfiguration=20(requested=20by=20Ludovic=20Court=C3=A8s)?= =?UTF-8?q?=20-=20system.extraSystemBuilderCmds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/nixos/trunk/; revision=21406 --- lib/from-env.nix | 1 + modules/system/activation/top-level.nix | 36 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/from-env.nix b/lib/from-env.nix index a7a339b5f2ec..6bd71e40e9a1 100644 --- a/lib/from-env.nix +++ b/lib/from-env.nix @@ -1,3 +1,4 @@ +# TODO: remove this file. There is lib.maybeEnv now name: default: let value = builtins.getEnv name; in if value == "" then default else value diff --git a/modules/system/activation/top-level.nix b/modules/system/activation/top-level.nix index 8cd23cd933da..2893ef076eac 100644 --- a/modules/system/activation/top-level.nix +++ b/modules/system/activation/top-level.nix @@ -31,6 +31,36 @@ let Name of the kernel file to be passed to the bootloader. ''; }; + + system.copySystemConfiguration = pkgs.lib.mkOption { + default = true; + description = '' + Unless set to false copies the nixos configuration file + $NIXOS_CONFIG defaulting to + /etc/nixos/configuration.nix + to the system store path. + See + if you want to do add more customized info + to your system storepath. + ''; + }; + + system.extraSystemBuilderCmds = pkgs.lib.mkOption { + default = ""; + merge = pkgs.lib.concatStringsSep "\n"; + description = '' + This code will be added to the builder creating the system store path. + This use case copies your configuration file into the system derivation: + + cp ${pkgs.lib.maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"} $out + + Of course you could add code saving a svn diff or svn revision number + of both nixos and nixpkgs repositories as well. Keep in mind that when + you build in chroots that you have do either copy sources to store or + add them to the chroot somehow. + You still should consider putting your configuration into a VCS. + ''; + }; }; @@ -95,6 +125,8 @@ let ensureDir $out/bin substituteAll ${./switch-to-configuration.sh} $out/bin/switch-to-configuration chmod +x $out/bin/switch-to-configuration + + ${config.system.extraSystemBuilderCmds} ''; @@ -139,5 +171,9 @@ let in { require = [options]; + system.extraSystemBuilderCmds = + pkgs.lib.optionalString + config.system.copySystemConfiguration + "cp ${pkgs.lib.maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"} $out"; system.build.toplevel = system; }