From 123a8bf9a58e817b694d35dc2622045e096c93fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 7 Jan 2015 17:27:29 +0100 Subject: [PATCH] stdenv: refactor code for evaluation errors (no hash changes) --- pkgs/stdenv/generic/default.nix | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index d50ac9f430e..04c05162bb6 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -27,15 +27,6 @@ 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); isUnfree = licenses: lib.lists.any (l: @@ -61,19 +52,24 @@ let else unsafeGetAttrPos "name" attrs; pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; + + throwEvalHelp = unfreeOrBroken: whatIsWrong: + assert (unfreeOrBroken == "Unfree" || unfreeOrBroken == "Broken"); + throw '' + Package ‘${attrs.name}’ in ${pos'} ${whatIsWrong}, refusing to evaluate. + 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. + ''; in if !allowUnfree && isUnfree (lib.lists.toList attrs.meta.license or []) && !allowUnfreePredicate attrs then - throw '' - Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. - ${forceEvalHelp "Unfree"}'' + throwEvalHelp "Unfree" "has an unfree license" else if !allowBroken && attrs.meta.broken or false then - throw '' - Package ‘${attrs.name}’ in ${pos'} is marked as broken, refusing to evaluate. - ${forceEvalHelp "Broken"}'' + throwEvalHelp "Broken" "is marked as 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. - ${forceEvalHelp "Broken"}'' + throwEvalHelp "Broken" "is not supported on ‘${result.system}’" else lib.addPassthru (derivation ( (removeAttrs attrs ["meta" "passthru" "crossAttrs"])