diff options
Diffstat (limited to 'pkgs/lib/options.nix')
-rw-r--r-- | pkgs/lib/options.nix | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/pkgs/lib/options.nix b/pkgs/lib/options.nix index 59bda41a623..3a8cc0006ef 100644 --- a/pkgs/lib/options.nix +++ b/pkgs/lib/options.nix @@ -90,10 +90,17 @@ rec { # Evaluate sub-modules. subModuleMerge = path: vals: lib.fix (args: - let result = recurseInto path (optionConfig vals args); in { - inherit (result) config options; + let + result = recurseInto path (optionConfig vals args); name = lib.removePrefix (opt.name + ".") path; - } + extraArgs = opt.extraArgs or {}; + individualExtraArgs = opt.individualExtraArgs or {}; + in { + inherit (result) config options; + inherit name; + } // + (opt.extraArgs or {}) // + (if hasAttr name individualExtraArgs then getAttr name individualExtraArgs else {}) ); # Add _options in sub-modules to make it viewable from other @@ -158,6 +165,14 @@ rec { // optionalAttrs (opt1 ? extraConfigs || opt2 ? extraConfigs) { extraConfigs = opt1.extraConfigs or [] ++ opt2.extraConfigs or []; } + // optionalAttrs (opt1 ? extraArgs || opt2 ? extraArgs) { + extraArgs = opt1.extraArgs or {} // opt2.extraArgs or {}; + } + // optionalAttrs (opt1 ? individualExtraArgs || opt2 ? individualExtraArgs) { + individualExtraArgs = zipAttrsWith (name: values: + if length values == 1 then head values else (head values // (head (tail values))) + ) [ (opt1.individualExtraArgs or {}) (opt2.individualExtraArgs or {}) ]; + } )) {} opts; |