about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2014-08-12 20:18:10 +0200
committerVladimír Čunát <vcunat@gmail.com>2014-08-12 20:18:10 +0200
commite80f41f35e8347a5e8cbb028c0ea3c33448ddece (patch)
tree1738934bfbd6b419c3a50f9d163fc7bc2db788cc /pkgs/stdenv
parentbcdbbf3ea158b694192e12be9e719ec653b94fc2 (diff)
parentff999c31aa050cec735b787d1bbe519fa2298c3d (diff)
Merge pull request #2455 from bjornfor/helpful-messages-when-refusing-eval
More helpful message when refusing to evaluate "broken" package
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/generic/default.nix25
1 files changed, 18 insertions, 7 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 0d8355e89cc38..11731c1c1c105 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -29,6 +29,16 @@ let
 
   allowBroken = config.allowBroken or false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
 
+  forceEvalHelp = unfreeOrBroken:
+    assert (unfreeOrBroken == "Unfree" || unfreeOrBroken == "Broken");
+    ''
+      You can set
+        { nixpkgs.config.allow${unfreeOrBroken} = true; }
+      in configuration.nix to override this. If you use Nix standalone, you can add
+        { allow${unfreeOrBroken} = true; }
+      to ~/.nixpkgs/config.nix.
+    '';
+
   unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
 
   # The stdenv that we are producing.
@@ -76,15 +86,16 @@ let
         in
         if !allowUnfree && (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l) && !(allowUnfreePredicate attrs) then
           throw ''
-            Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. You can set
-              { nixpkgs.config.allowUnfree = true; }
-            in configuration.nix to override this. If you use Nix standalone, you can add
-              { allowUnfree = true; }
-            to ~/.nixpkgs/config.nix.''
+            Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate.
+            ${forceEvalHelp "Unfree"}''
         else if !allowBroken && attrs.meta.broken or false then
-          throw "you can't use package ‘${attrs.name}’ in ${pos'} because it has been marked as broken"
+          throw ''
+            Package ‘${attrs.name}’ in ${pos'} is marked as broken, refusing to evaluate.
+            ${forceEvalHelp "Broken"}''
         else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then
-          throw "the package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’"
+          throw ''
+            Package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’, refusing to evaluate.
+            ${forceEvalHelp "Broken"}''
         else
           lib.addPassthru (derivation (
             (removeAttrs attrs ["meta" "passthru" "crossAttrs"])