From abfaf423332cd2980cfc44b53962a8d4e7847d51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
Date: Wed, 30 Apr 2014 21:51:03 +0200
Subject: [PATCH 1/2] More helpful message when refusing to evaluate "broken"
 package

A "broken" package is one where either "meta.broken = true" or build
platform != meta.platforms.
---
 pkgs/stdenv/generic/default.nix | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 6047ecf853c5..ab9af40cc678 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -84,9 +84,19 @@ let
               { allowUnfree = true; }
             to ~/.nixpkgs/config.nix.''
         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. You can set
+              { nixpkgs.config.allowBroken = true; }
+            in configuration.nix to override this. If you use Nix standalone, you can add
+              { allowBroken = true; }
+            to ~/.nixpkgs/config.nix.''
         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. You can set
+              { nixpkgs.config.allowBroken = true; }
+            in configuration.nix to override this. If you use Nix standalone, you can add
+              { allowBroken = true; }
+            to ~/.nixpkgs/config.nix.''
         else
           lib.addPassthru (derivation (
             (removeAttrs attrs ["meta" "passthru" "crossAttrs"])

From ff999c31aa050cec735b787d1bbe519fa2298c3d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
Date: Wed, 30 Apr 2014 23:41:16 +0200
Subject: [PATCH 2/2] Factor out allowUnfree,allowBroken help message

DRY.
---
 pkgs/stdenv/generic/default.nix | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index ab9af40cc678..ac094126c09e 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.
@@ -78,25 +88,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 ''
-            Package ‘${attrs.name}’ in ${pos'} is marked as broken, refusing to evaluate. You can set
-              { nixpkgs.config.allowBroken = true; }
-            in configuration.nix to override this. If you use Nix standalone, you can add
-              { allowBroken = true; }
-            to ~/.nixpkgs/config.nix.''
+            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 ''
-            Package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’, refusing to evaluate. You can set
-              { nixpkgs.config.allowBroken = true; }
-            in configuration.nix to override this. If you use Nix standalone, you can add
-              { allowBroken = true; }
-            to ~/.nixpkgs/config.nix.''
+            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"])