diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2015-01-07 17:27:29 +0100 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2015-01-11 21:37:50 +0100 |
commit | 123a8bf9a58e817b694d35dc2622045e096c93fd (patch) | |
tree | 42b53d1a2dec4d2f88e90ac18d4cd40c658813a8 /pkgs/stdenv/generic | |
parent | 2f4dc089a95cbea8451007585d10c39c43e5553f (diff) | |
download | nixlib-123a8bf9a58e817b694d35dc2622045e096c93fd.tar nixlib-123a8bf9a58e817b694d35dc2622045e096c93fd.tar.gz nixlib-123a8bf9a58e817b694d35dc2622045e096c93fd.tar.bz2 nixlib-123a8bf9a58e817b694d35dc2622045e096c93fd.tar.lz nixlib-123a8bf9a58e817b694d35dc2622045e096c93fd.tar.xz nixlib-123a8bf9a58e817b694d35dc2622045e096c93fd.tar.zst nixlib-123a8bf9a58e817b694d35dc2622045e096c93fd.zip |
stdenv: refactor code for evaluation errors (no hash changes)
Diffstat (limited to 'pkgs/stdenv/generic')
-rw-r--r-- | pkgs/stdenv/generic/default.nix | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index d50ac9f430e5..04c05162bb63 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"]) |