diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-09-28 18:22:49 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-09-28 18:22:49 +0000 |
commit | 33d43ac18bd9178e5222433f3ef7e58a3a35f173 (patch) | |
tree | 1c29bf0bf2f79fe231f7c8338bd1fe380405f567 | |
parent | b3b40ebf791156abba529b2e50678f8958e284c3 (diff) | |
download | nixpkgs-33d43ac18bd9178e5222433f3ef7e58a3a35f173.tar nixpkgs-33d43ac18bd9178e5222433f3ef7e58a3a35f173.tar.gz nixpkgs-33d43ac18bd9178e5222433f3ef7e58a3a35f173.tar.bz2 nixpkgs-33d43ac18bd9178e5222433f3ef7e58a3a35f173.tar.lz nixpkgs-33d43ac18bd9178e5222433f3ef7e58a3a35f173.tar.xz nixpkgs-33d43ac18bd9178e5222433f3ef7e58a3a35f173.tar.zst nixpkgs-33d43ac18bd9178e5222433f3ef7e58a3a35f173.zip |
Add extraConfigs attribute inside options. This attribute is used to
insert definitions from an external location. As opposed to other defintions, these definitions are always embedded into a list which allow to add multiple definitions with one module. !!! This feature _should not_ be used as a new mean to define options. svn path=/nixpkgs/trunk/; revision=17481
-rw-r--r-- | pkgs/lib/modules.nix | 6 | ||||
-rw-r--r-- | pkgs/lib/options.nix | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/pkgs/lib/modules.nix b/pkgs/lib/modules.nix index 19b04bd827f..4de12e1a07c 100644 --- a/pkgs/lib/modules.nix +++ b/pkgs/lib/modules.nix @@ -230,10 +230,14 @@ rec { }" ); - config = lib.zipWithNames (modulesNames modules) (name: values: + config = lib.zipWithNames (modulesNames modules) (name: values_: let hasOpt = builtins.hasAttr name result.options; opt = lib.getAttr name result.options; + values = values_ ++ + optionals + (hasOpt && isOption opt && opt ? extraConfigs) + opt.extraConfigs; in if hasOpt && isOption opt then let defs = evalProperties values; in diff --git a/pkgs/lib/options.nix b/pkgs/lib/options.nix index c1c6a64d6d5..6f1b1afe12a 100644 --- a/pkgs/lib/options.nix +++ b/pkgs/lib/options.nix @@ -25,6 +25,7 @@ rec { # merge (function used to merge definitions into one definition: [ /type/ ] -> /type/) # apply (convert the option value to ease the manipulation of the option result) # options (set of sub-options declarations & definitions) + # extraConfigs (list of possible configurations) }; mapSubOptions = f: opt: @@ -138,14 +139,17 @@ rec { assert opt1 ? merge -> ! opt2 ? merge; assert opt1 ? apply -> ! opt2 ? apply; assert opt1 ? type -> ! opt2 ? type; - if opt1 ? options || opt2 ? options then - opt1 // opt2 // { + opt1 // opt2 + // optionalAttrs (opt1 ? options || opt2 ? options) { options = (toList (attrByPath ["options"] [] opt1)) ++ (toList (attrByPath ["options"] [] opt2)); } - else - opt1 // opt2 + // optionalAttrs (opt1 ? extraConfigs || opt2 ? extraConfigs) { + extraConfigs = + (attrByPath ["extraConfigs"] [] opt1) + ++ (attrByPath ["extraConfigs"] [] opt2); + } )) {} opts; |