summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2016-11-21 14:51:57 +0100
committerEelco Dolstra <edolstra@gmail.com>2016-11-21 14:51:57 +0100
commita6bb468acf48e2dd9dddbd54d911f9e5919b70a3 (patch)
tree0cfb5107efb722bcf0627be765cbda4e1ac585de /lib/modules.nix
parentc686a8fc7b194c5dc139762fb12605a3d4eaee0d (diff)
downloadnixpkgs-a6bb468acf48e2dd9dddbd54d911f9e5919b70a3.tar
nixpkgs-a6bb468acf48e2dd9dddbd54d911f9e5919b70a3.tar.gz
nixpkgs-a6bb468acf48e2dd9dddbd54d911f9e5919b70a3.tar.bz2
nixpkgs-a6bb468acf48e2dd9dddbd54d911f9e5919b70a3.tar.lz
nixpkgs-a6bb468acf48e2dd9dddbd54d911f9e5919b70a3.tar.xz
nixpkgs-a6bb468acf48e2dd9dddbd54d911f9e5919b70a3.tar.zst
nixpkgs-a6bb468acf48e2dd9dddbd54d911f9e5919b70a3.zip
mkIf: Check whether the condition is a Boolean
This gives a nicer error message than (say)

while evaluating the option `fileSystems':
while evaluating the attribute ‘isDefined’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:323:5:
while evaluating ‘filterOverrides’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:395:21, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:307:18:
while evaluating ‘concatMap’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/lists.nix:79:18, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:401:8:
while evaluating ‘concatMap’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/lists.nix:79:18, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:302:17:
while evaluating anonymous function at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:302:28, called from undefined position:
while evaluating ‘dischargeProperties’ at /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:365:25, called from /nix/store/r8z4vvl2qzg31zm4ra6awlx5b22k7gf9-nixos-16.09.tar.gz/lib/modules.nix:303:62:
value is a list while a Boolean was expected
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index e66d6a6926c..256d49ba27d 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -375,10 +375,13 @@ rec {
     if def._type or "" == "merge" then
       concatMap dischargeProperties def.contents
     else if def._type or "" == "if" then
-      if def.condition then
-        dischargeProperties def.content
+      if isBool def.condition then
+        if def.condition then
+          dischargeProperties def.content
+        else
+          [ ]
       else
-        [ ]
+        throw "‘mkIf’ called with a non-Boolean condition"
     else
       [ def ];