diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2016-11-21 14:51:57 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2016-11-21 14:51:57 +0100 |
commit | a6bb468acf48e2dd9dddbd54d911f9e5919b70a3 (patch) | |
tree | 0cfb5107efb722bcf0627be765cbda4e1ac585de /lib/modules.nix | |
parent | c686a8fc7b194c5dc139762fb12605a3d4eaee0d (diff) | |
download | nixpkgs-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.nix | 9 |
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 ]; |