diff --git a/pkgs/lib/modules.nix b/pkgs/lib/modules.nix index 6626812076e..becd786d8cd 100644 --- a/pkgs/lib/modules.nix +++ b/pkgs/lib/modules.nix @@ -118,8 +118,9 @@ rec { moduleApply { config = delayProperties; } module; evalDefinitions = opt: values: - if opt ? type && opt.type.delayProperties then - map (delayPropertiesWithIter opt.type.iter opt.name) values + if opt ? type && opt.type.delayOnGlobalEval then + map (delayPropertiesWithIter opt.type.iter opt.name) + (evalLocalProperties values) else evalProperties values; diff --git a/pkgs/lib/properties.nix b/pkgs/lib/properties.nix index ddf3d6cf594..a911c99bf3f 100644 --- a/pkgs/lib/properties.nix +++ b/pkgs/lib/properties.nix @@ -124,13 +124,19 @@ rec { evalProperties = valList: if valList != [] then filter (x: !isNotdef x) ( - lib.addErrorContext "while evaluating properties an attribute." ( + lib.addErrorContext "while evaluating properties." ( triggerPropertiesGlobalEval ( map triggerPropertiesEval valList ))) else valList; + evalLocalProperties = valList: + filter (x: !isNotdef x) ( + lib.addErrorContext "while evaluating local properties." ( + map triggerPropertiesEval valList + )); + # Call onEval function triggerPropertiesEval = val: foldProperty (p@{property, ...}: diff --git a/pkgs/lib/types.nix b/pkgs/lib/types.nix index 723dd22e2f0..8b0f61549b5 100644 --- a/pkgs/lib/types.nix +++ b/pkgs/lib/types.nix @@ -19,7 +19,7 @@ rec { # iter (iterate on all elements contained in this type) # fold (fold all elements contained in this type) # hasOptions (boolean: whatever this option contains an option set) - # delayProperties (boolean: should properties go through the evaluation of this option) + # delayOnGlobalEval (boolean: should properties go through the evaluation of this option) # docPath (path concatenated to the option name contained in the option set) isOptionType = attrs: typeOf attrs == "option-type"; mkOptionType = @@ -32,11 +32,11 @@ rec { , docPath ? lib.id # If the type can contains option sets. , hasOptions ? false - , delayProperties ? false + , delayOnGlobalEval ? false }: { _type = "option-type"; - inherit name check merge iter fold docPath hasOptions delayProperties; + inherit name check merge iter fold docPath hasOptions delayOnGlobalEval; }; @@ -87,7 +87,7 @@ rec { # You cannot define multiple configurations of one entity, therefore # no reason justify to delay properties inside list elements. - delayProperties = false; + delayOnGlobalEval = false; }; attrsOf = elemType: mkOptionType { @@ -98,7 +98,7 @@ rec { iter = f: path: set: lib.mapAttrs (name: elemType.iter f (path + "." + name)) set; fold = op: nul: set: fold (e: l: elemType.fold op l e) nul (lib.attrValues set); docPath = path: elemType.docPath (path + "."); - inherit (elemType) hasOptions delayProperties; + inherit (elemType) hasOptions delayOnGlobalEval; }; uniq = elemType: mkOptionType { @@ -125,7 +125,7 @@ rec { merge = lib.id; check = x: lib.traceValIfNot builtins.isAttrs x; hasOptions = true; - delayProperties = true; + delayOnGlobalEval = true; }; };