Loading lib/modules.nix +13 −2 Original line number Diff line number Diff line Loading @@ -1322,13 +1322,24 @@ let : 1\. Function argument */ pushDownProperties = let mapAttrsIfAttrs = f: val: if isAttrs val then mapAttrs f val else # This does not actually work, since arriving here means we have e.g. # (lib.mkIf cond nonAttrs), while an attrset is expected. However, # avoiding the mapAttrs call here gives better errors later. val; in cfg: if cfg._type or "" == "merge" then concatMap pushDownProperties cfg.contents else if cfg._type or "" == "if" then map (mapAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content) map (mapAttrsIfAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content) else if cfg._type or "" == "override" then map (mapAttrs (n: v: mkOverride cfg.priority v)) (pushDownProperties cfg.content) map (mapAttrsIfAttrs (n: v: mkOverride cfg.priority v)) (pushDownProperties cfg.content) # FIXME: handle mkOrder? else [ cfg ]; Loading lib/tests/modules.sh +2 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,8 @@ checkConfigError() { # Shorthand meta attribute does not duplicate the config checkConfigOutput '^"one two"$' config.result ./shorthand-meta.nix checkConfigError "In module .*test-push-down-non-attrs.nix., you're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option" config ./test-push-down-non-attrs.nix checkConfigOutput '^true$' config.result ./test-mergeAttrDefinitionsWithPrio.nix # Check that a module argument is passed, also when a default is available Loading lib/tests/modules/test-push-down-non-attrs.nix 0 → 100644 +5 −0 Original line number Diff line number Diff line { lib, ... }: { config = lib.mkIf true true; } Loading
lib/modules.nix +13 −2 Original line number Diff line number Diff line Loading @@ -1322,13 +1322,24 @@ let : 1\. Function argument */ pushDownProperties = let mapAttrsIfAttrs = f: val: if isAttrs val then mapAttrs f val else # This does not actually work, since arriving here means we have e.g. # (lib.mkIf cond nonAttrs), while an attrset is expected. However, # avoiding the mapAttrs call here gives better errors later. val; in cfg: if cfg._type or "" == "merge" then concatMap pushDownProperties cfg.contents else if cfg._type or "" == "if" then map (mapAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content) map (mapAttrsIfAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content) else if cfg._type or "" == "override" then map (mapAttrs (n: v: mkOverride cfg.priority v)) (pushDownProperties cfg.content) map (mapAttrsIfAttrs (n: v: mkOverride cfg.priority v)) (pushDownProperties cfg.content) # FIXME: handle mkOrder? else [ cfg ]; Loading
lib/tests/modules.sh +2 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,8 @@ checkConfigError() { # Shorthand meta attribute does not duplicate the config checkConfigOutput '^"one two"$' config.result ./shorthand-meta.nix checkConfigError "In module .*test-push-down-non-attrs.nix., you're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option" config ./test-push-down-non-attrs.nix checkConfigOutput '^true$' config.result ./test-mergeAttrDefinitionsWithPrio.nix # Check that a module argument is passed, also when a default is available Loading
lib/tests/modules/test-push-down-non-attrs.nix 0 → 100644 +5 −0 Original line number Diff line number Diff line { lib, ... }: { config = lib.mkIf true true; }