diff options
Diffstat (limited to 'pkgs/stdenv/generic/default.nix')
-rw-r--r-- | pkgs/stdenv/generic/default.nix | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 751366e38d23..6960c84ba5e3 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -69,8 +69,6 @@ let isUnfree (lib.lists.toList attrs.meta.license) && !allowUnfreePredicate attrs; - unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null); - defaultNativeBuildInputs = extraBuildInputs ++ [ ../../build-support/setup-hooks/move-docs.sh ../../build-support/setup-hooks/compress-man-pages.sh @@ -83,19 +81,30 @@ let # Add a utility function to produce derivations that use this # stdenv and its shell. - mkDerivation = attrs: + mkDerivation = + { buildInputs ? [] + , nativeBuildInputs ? [] + , propagatedBuildInputs ? [] + , propagatedNativeBuildInputs ? [] + , crossConfig ? null + , meta ? {} + , passthru ? {} + , pos ? null # position used in error messages and for meta.position + , ... } @ attrs: let - pos = - if attrs.meta.description or null != null then - unsafeGetAttrPos "description" attrs.meta + pos' = + if pos != null then + pos + else if attrs.meta.description or null != null then + builtins.unsafeGetAttrPos "description" attrs.meta else - unsafeGetAttrPos "name" attrs; - pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; + builtins.unsafeGetAttrPos "name" attrs; + pos'' = if pos' != null then "‘" + pos'.file + ":" + toString pos'.line + "’" else "«unknown-file»"; throwEvalHelp = unfreeOrBroken: whatIsWrong: assert builtins.elem unfreeOrBroken ["Unfree" "Broken" "blacklisted"]; - throw ("Package ‘${attrs.name or "«name-missing»"}’ in ${pos'} ${whatIsWrong}, refusing to evaluate." + throw ("Package ‘${attrs.name or "«name-missing»"}’ in ${pos''} ${whatIsWrong}, refusing to evaluate." + (lib.strings.optionalString (unfreeOrBroken != "blacklisted") '' For `nixos-rebuild` you can set @@ -121,14 +130,8 @@ let assert licenseAllowed attrs; lib.addPassthru (derivation ( - (removeAttrs attrs ["meta" "passthru" "crossAttrs"]) - // (let - buildInputs = attrs.buildInputs or []; - nativeBuildInputs = attrs.nativeBuildInputs or []; - propagatedBuildInputs = attrs.propagatedBuildInputs or []; - propagatedNativeBuildInputs = attrs.propagatedNativeBuildInputs or []; - crossConfig = attrs.crossConfig or null; - in + (removeAttrs attrs ["meta" "passthru" "crossAttrs" "pos"]) + // { builder = attrs.realBuilder or shell; args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)]; @@ -144,7 +147,7 @@ let nativeBuildInputs = nativeBuildInputs ++ (if crossConfig == null then buildInputs else []); propagatedNativeBuildInputs = propagatedNativeBuildInputs ++ (if crossConfig == null then propagatedBuildInputs else []); - }))) ( + })) ( { # The meta attribute is passed in the resulting attribute set, # but it's not part of the actual derivation, i.e., it's not @@ -152,15 +155,15 @@ let # include it in the result, it *is* available to nix-env for # queries. We also a meta.position attribute here to # identify the source location of the package. - meta = attrs.meta or {} // (if pos != null then { - position = pos.file + ":" + (toString pos.line); + meta = meta // (if pos' != null then { + position = pos'.file + ":" + toString pos'.line; } else {}); - passthru = attrs.passthru or {}; + inherit passthru; } // # Pass through extra attributes that are not inputs, but # should be made available to Nix expressions using the # derivation (e.g., in assertions). - (attrs.passthru or {})); + passthru); # The stdenv that we are producing. result = |