From 06bfb319fe0d16474483ed5d9343740c93429842 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sat, 8 May 2010 17:18:26 +0000 Subject: [PATCH] Add extra module argument to provide a nesting.clone option. This option does the same as nesting.children except that each configuration inherits from the top-level configuration. svn path=/nixos/trunk/; revision=21663 --- lib/eval-config.nix | 2 +- modules/system/activation/no-clone.nix | 13 +++++++++++ modules/system/activation/top-level.nix | 30 ++++++++++++++++--------- 3 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 modules/system/activation/no-clone.nix diff --git a/lib/eval-config.nix b/lib/eval-config.nix index 77c20caf604..49057f2d6da 100644 --- a/lib/eval-config.nix +++ b/lib/eval-config.nix @@ -30,7 +30,7 @@ rec { # These are the extra arguments passed to every module. In # particular, Nixpkgs is passed through the "pkgs" argument. extraArgs = extraArgs_ // { - inherit pkgs; + inherit pkgs modules baseModules; modulesPath = ../modules; servicesPath = services; }; diff --git a/modules/system/activation/no-clone.nix b/modules/system/activation/no-clone.nix new file mode 100644 index 00000000000..ca106807513 --- /dev/null +++ b/modules/system/activation/no-clone.nix @@ -0,0 +1,13 @@ +# This configuration is not made to figure inside the module-list.nix to +# allow clone of the first level. +{pkgs, ...}: + +with pkgs.lib; + +{ + boot.loader.grub.device = mkOverride 0 {} ""; + # undefined the obsolete name of the previous option. + boot.grubDevice = mkOverride 0 {} pkgs.lib.mkNotdef; + nesting.children = mkOverride 0 {} []; + nesting.clone = mkOverride 0 {} []; +} diff --git a/modules/system/activation/top-level.nix b/modules/system/activation/top-level.nix index 871172f3039..262a3bb9ae7 100644 --- a/modules/system/activation/top-level.nix +++ b/modules/system/activation/top-level.nix @@ -1,4 +1,4 @@ -{pkgs, config, ...}: +{pkgs, config, modules, baseModules, ...}: let @@ -18,6 +18,14 @@ let ''; }; + nesting.clone = pkgs.lib.mkOption { + default = []; + description = '' + Additional configurations to build based on the current + configuration which is has a lower priority. + ''; + }; + system.boot.loader.id = pkgs.lib.mkOption { default = ""; description = '' @@ -71,18 +79,20 @@ let # you can provide an easy way to boot the same configuration # as you use, but with another kernel # !!! fix this - children = with pkgs.lib; + cloner = inheritParent: list: with pkgs.lib; map (childConfig: (import ../../../lib/eval-config.nix { - modules = [ - (recursiveUpdate childConfig { - boot.loader.grub.device = ""; - # undefined the obsolete name of the previous option. - boot.grubDevice = pkgs.lib.mkNotdef; - }) - ] ++ attrByPath ["require"] [] childConfig; + inherit baseModules; + modules = + (optionals inheritParent modules) + ++ [ ./no-clone.nix ] + ++ [ childConfig ]; }).config.system.build.toplevel - ) config.nesting.children; + ) list; + + children = + cloner false config.nesting.children + ++ cloner true config.nesting.clone; systemBuilder =