summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorNicolas Pierron <nicolas.b.pierron@gmail.com>2009-10-12 13:37:00 +0000
committerNicolas Pierron <nicolas.b.pierron@gmail.com>2009-10-12 13:37:00 +0000
commit03eab956182461127726c6410a3a6e748cb3a62a (patch)
treea36aed86246c50612a8d1ec2d1f47bb93ea927ab /pkgs
parentc6efc69ad2850894b5b31412455bdf7b188be794 (diff)
downloadnixlib-03eab956182461127726c6410a3a6e748cb3a62a.tar
nixlib-03eab956182461127726c6410a3a6e748cb3a62a.tar.gz
nixlib-03eab956182461127726c6410a3a6e748cb3a62a.tar.bz2
nixlib-03eab956182461127726c6410a3a6e748cb3a62a.tar.lz
nixlib-03eab956182461127726c6410a3a6e748cb3a62a.tar.xz
nixlib-03eab956182461127726c6410a3a6e748cb3a62a.tar.zst
nixlib-03eab956182461127726c6410a3a6e748cb3a62a.zip
Only allow properties with a onGlobalEval function to go through specific
types.

svn path=/nixpkgs/trunk/; revision=17756
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/lib/modules.nix5
-rw-r--r--pkgs/lib/properties.nix8
-rw-r--r--pkgs/lib/types.nix12
3 files changed, 16 insertions, 9 deletions
diff --git a/pkgs/lib/modules.nix b/pkgs/lib/modules.nix
index 6626812076e7..becd786d8cd0 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 ddf3d6cf594e..a911c99bf3fd 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 723dd22e2f05..8b0f61549b5d 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 + ".<name>");
-      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;
     };
 
   };