From 9a8516438e93ec61bc37fc6f2e1125df30df2f4b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 28 Oct 2013 17:24:14 +0100 Subject: [PATCH] Fix NixOps evaluation --- lib/modules.nix | 18 ++++++++++-------- nixos/modules/system/boot/loader/grub/grub.nix | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index 47c7e9bf1ac..5c5820e92f4 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -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; diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 955235da70f..31e55b5ef9f 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -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}";