Fix NixOps evaluation

This commit is contained in:
Eelco Dolstra 2013-10-28 17:24:14 +01:00
parent 259f7a93b1
commit 9a8516438e
2 changed files with 11 additions and 9 deletions

View File

@ -22,35 +22,37 @@ rec {
/* Close a set of modules under the imports relation. */
closeModules = modules: args:
let
toClosureList = parent: imap (n: x:
toClosureList = file: parentKey: imap (n: x:
if isAttrs x || builtins.isFunction x then
unifyModuleSyntax parent "anon-${toString n}" (applyIfFunction x args)
unifyModuleSyntax file "${parentKey}:anon-${toString n}" (applyIfFunction x args)
else
unifyModuleSyntax (toString x) (toString x) (applyIfFunction (import x) args));
in
builtins.genericClosure {
startSet = toClosureList unknownModule modules;
operator = m: toClosureList m.file m.imports;
startSet = toClosureList unknownModule "" modules;
operator = m: toClosureList m.file m.key m.imports;
};
/* Massage a module into canonical form, that is, a set consisting
of options, config and imports attributes. */
unifyModuleSyntax = file: key: m:
if m ? config || m ? options || m ? imports then
let badAttrs = removeAttrs m ["imports" "options" "config"]; in
let badAttrs = removeAttrs m ["imports" "options" "config" "key"]; in
if badAttrs != {} then
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. ${builtins.toXML m} "
else
{ inherit file key;
{ inherit file;
key = m.key or key;
imports = m.imports or [];
options = m.options or {};
config = m.config or {};
}
else
{ inherit file key;
{ inherit file;
key = m.key or key;
imports = m.require or [];
options = {};
config = removeAttrs m ["require"];
config = removeAttrs m ["key" "require"];
};
applyIfFunction = f: arg: if builtins.isFunction f then f arg else f;

View File

@ -236,7 +236,7 @@ in
system.build.installBootLoader =
if cfg.devices == [] then
throw "You must set the boot.loader.grub.device option to make the system bootable."
throw "You must set the option boot.loader.grub.device to make the system bootable."
else
"PERL5LIB=${makePerlPath [ pkgs.perlPackages.XMLLibXML pkgs.perlPackages.XMLSAX ]} " +
"${pkgs.perl}/bin/perl ${./install-grub.pl} ${grubConfig}";