* Revert the last two commits since they break every job in the

buildfarm ("undefined variable `delayPropertiesTemplate'").

svn path=/nixpkgs/trunk/; revision=17738
This commit is contained in:
Eelco Dolstra 2009-10-09 19:34:28 +00:00
parent d11481e9bf
commit 24b50e92ee
3 changed files with 8 additions and 31 deletions

View file

@ -113,17 +113,9 @@ rec {
value value
) module; ) module;
delayModule = module: delayModule = module:
moduleApply { config = delayProperties; } module; moduleApply { config = delayProperties; } module;
evalDefinitions = opt: values:
if opt ? type && opt.type.delayProperties then
map (delayPropertiesTemplate opt.type.iter opt.name) values
else
evalProperties values;
selectModule = name: m: selectModule = name: m:
{ inherit (m) key; { inherit (m) key;
} // ( } // (
@ -251,7 +243,7 @@ rec {
opt.extraConfigs; opt.extraConfigs;
in if hasOpt && isOption opt then in if hasOpt && isOption opt then
let defs = evalDefinitions opt values; in let defs = evalProperties values; in
lib.addErrorContext "${eol lib.addErrorContext "${eol
}while evaluating the option '${addName name}'.${eol }while evaluating the option '${addName name}'.${eol
}${errorSource (modulesOf name)}${eol }${errorSource (modulesOf name)}${eol

View file

@ -69,21 +69,18 @@ rec {
# Move properties from the current attribute set to the attribute # Move properties from the current attribute set to the attribute
# contained in this attribute set. This trigger property handlers called # contained in this attribute set. This trigger property handlers called
# `onDelay' and `onGlobalDelay'. # `onDelay' and `onGlobalDelay'.
delayPropertiesWithIter = iter: path: attrs: delayProperties = attrs:
let cleanAttrs = rmProperties attrs; in let cleanAttrs = rmProperties attrs; in
if isProperty attrs then if isProperty attrs then
iter (a: v: lib.mapAttrs (a: v:
lib.addErrorContext "while moving properties on the attribute `${a}'." ( lib.addErrorContext "while moving properties on the attribute `${a}'." (
triggerPropertiesGlobalDelay a ( triggerPropertiesGlobalDelay a (
triggerPropertiesDelay a ( triggerPropertiesDelay a (
copyProperties attrs v copyProperties attrs v
)))) path cleanAttrs )))) cleanAttrs
else else
attrs; attrs;
delayProperties = # implicit attrs argument.
delayPropertiesWithIter (f: p: v: lib.mapAttrs f v) "";
# Call onDelay functions. # Call onDelay functions.
triggerPropertiesDelay = name: attrs: triggerPropertiesDelay = name: attrs:
let let
@ -288,7 +285,7 @@ rec {
# priorities are kept. The template argument must reproduce the same # priorities are kept. The template argument must reproduce the same
# attribute set hierarchy to override leaves of the hierarchy. # attribute set hierarchy to override leaves of the hierarchy.
isOverride = attrs: (typeOf attrs) == "override"; isOverride = attrs: (typeOf attrs) == "override";
mkOverrideTemplate = priority: template: content: mkProperty { mkOverride = priority: template: content: mkProperty {
property = { property = {
_type = "override"; _type = "override";
onDelay = onOverrideDelay; onDelay = onOverrideDelay;
@ -298,10 +295,6 @@ rec {
inherit content; inherit content;
}; };
# Currently an alias, but sooner or later the template argument should be
# removed.
mkOverride = mkOverrideTemplate;
# Sugar to override the default value of the option by making a new # Sugar to override the default value of the option by making a new
# default value based on the configuration. # default value based on the configuration.
mkDefaultValue = content: mkOverride 1000 {} content; mkDefaultValue = content: mkOverride 1000 {} content;

View file

@ -19,8 +19,7 @@ rec {
# iter (iterate on all elements contained in this type) # iter (iterate on all elements contained in this type)
# fold (fold all elements contained in this type) # fold (fold all elements contained in this type)
# hasOptions (boolean: whatever this option contains an option set) # hasOptions (boolean: whatever this option contains an option set)
# delayProperties (boolean: should properties go through the evaluation of this option) # path (path contatenated to the option name contained contained in the option set)
# docPath (path concatenated to the option name contained in the option set)
isOptionType = attrs: typeOf attrs == "option-type"; isOptionType = attrs: typeOf attrs == "option-type";
mkOptionType = mkOptionType =
{ name { name
@ -32,11 +31,10 @@ rec {
, docPath ? lib.id , docPath ? lib.id
# If the type can contains option sets. # If the type can contains option sets.
, hasOptions ? false , hasOptions ? false
, delayProperties ? false
}: }:
{ _type = "option-type"; { _type = "option-type";
inherit name check merge iter fold docPath hasOptions delayProperties; inherit name check merge iter fold docPath hasOptions;
}; };
@ -75,7 +73,6 @@ rec {
check = lib.traceValIfNot isDerivation; check = lib.traceValIfNot isDerivation;
}; };
listOf = types.list;
list = elemType: mkOptionType { list = elemType: mkOptionType {
name = "list of ${elemType.name}s"; name = "list of ${elemType.name}s";
check = value: lib.traceValIfNot isList value && all elemType.check value; check = value: lib.traceValIfNot isList value && all elemType.check value;
@ -84,10 +81,6 @@ rec {
fold = op: nul: list: lib.fold (e: l: elemType.fold op l e) nul list; fold = op: nul: list: lib.fold (e: l: elemType.fold op l e) nul list;
docPath = path: elemType.docPath (path + ".*"); docPath = path: elemType.docPath (path + ".*");
inherit (elemType) hasOptions; inherit (elemType) hasOptions;
# You cannot define multiple configurations of one entity, therefore
# no reason justify to delay properties inside list elements.
delayProperties = false;
}; };
attrsOf = elemType: mkOptionType { attrsOf = elemType: mkOptionType {
@ -98,7 +91,7 @@ rec {
iter = f: path: set: lib.mapAttrs (name: elemType.iter f (path + "." + name)) set; 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); fold = op: nul: set: fold (e: l: elemType.fold op l e) nul (lib.attrValues set);
docPath = path: elemType.docPath (path + ".<name>"); docPath = path: elemType.docPath (path + ".<name>");
inherit (elemType) hasOptions delayProperties; inherit (elemType) hasOptions;
}; };
uniq = elemType: mkOptionType { uniq = elemType: mkOptionType {
@ -125,7 +118,6 @@ rec {
merge = lib.id; merge = lib.id;
check = x: lib.traceValIfNot builtins.isAttrs x; check = x: lib.traceValIfNot builtins.isAttrs x;
hasOptions = true; hasOptions = true;
delayProperties = true;
}; };
}; };