diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2015-10-03 13:33:13 +0200 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2015-10-03 13:33:37 +0200 |
commit | 5227fb1dd53fcb5918b9342dff4868f4ad68427e (patch) | |
tree | d6cd521e3f67944031216a27f740f28f22b73b41 /pkgs/stdenv/generic | |
parent | d6dd3b8bd1eaeeb21dfdb5051cd4732c748ce5d7 (diff) | |
parent | 33373d939a19f465228ddede6d38ce9032b5916b (diff) | |
download | nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.gz nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.bz2 nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.lz nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.xz nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.zst nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.zip |
Merge commit staging+systemd into closure-size
Many non-conflict problems weren't (fully) resolved in this commit yet.
Diffstat (limited to 'pkgs/stdenv/generic')
-rw-r--r-- | pkgs/stdenv/generic/default.nix | 57 | ||||
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 80 |
2 files changed, 93 insertions, 44 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 1a43b5a6159a..9e011ab88ae1 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -10,6 +10,8 @@ let lib = import ../../../lib; in lib.makeOverridable ( , setupScript ? ./setup.sh , extraBuildInputs ? [] +, __stdenvImpureHostDeps ? [] +, __extraImpureHostDeps ? [] }: let @@ -19,11 +21,13 @@ let whitelist = config.whitelistedLicenses or []; blacklist = config.blacklistedLicenses or []; + ifDarwin = attrs: if system == "x86_64-darwin" then attrs else {}; + onlyLicenses = list: lib.lists.all (license: let l = lib.licenses.${license.shortName or "BROKEN"} or false; in if license == l then true else - throw ''‘${builtins.toJSON license}’ is not an attribute of lib.licenses'' + throw ''‘${showLicense license}’ is not an attribute of lib.licenses'' ) list; mutuallyExclusive = a: b: @@ -69,6 +73,8 @@ let isUnfree (lib.lists.toList attrs.meta.license) && !allowUnfreePredicate attrs; + showLicense = license: license.shortName or "unknown"; + defaultNativeBuildInputs = extraBuildInputs ++ [ ../../build-support/setup-hooks/move-docs.sh ../../build-support/setup-hooks/compress-man-pages.sh @@ -91,6 +97,10 @@ let , meta ? {} , passthru ? {} , pos ? null # position used in error messages and for meta.position + , separateDebugInfo ? false + , outputs ? [ "out" ] + , __impureHostDeps ? [] + , __propagatedImpureHostDeps ? [] , ... } @ attrs: let pos' = @@ -118,21 +128,36 @@ let licenseAllowed = attrs: if hasDeniedUnfreeLicense attrs && !(hasWhitelistedLicense attrs) then - throwEvalHelp "Unfree" "has an unfree license ‘${builtins.toJSON attrs.meta.license}’ which is not whitelisted" + throwEvalHelp "Unfree" "has an unfree license (‘${showLicense attrs.meta.license}’)" else if hasBlacklistedLicense attrs then - throwEvalHelp "blacklisted" "has the ‘${builtins.toJSON attrs.meta.license}’ license which is blacklisted" + throwEvalHelp "blacklisted" "has a blacklisted license (‘${showLicense attrs.meta.license}’)" else if !allowBroken && attrs.meta.broken or false then throwEvalHelp "Broken" "is marked as broken" else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then throwEvalHelp "Broken" "is not supported on ‘${result.system}’" else true; + outputs' = + outputs ++ + (if separateDebugInfo then assert result.isLinux; [ "debug" ] else []); + + buildInputs' = buildInputs ++ + (if separateDebugInfo then [ ../../build-support/setup-hooks/separate-debug-info.sh ] else []); + in assert licenseAllowed attrs; lib.addPassthru (derivation ( - (removeAttrs attrs ["meta" "passthru" "crossAttrs" "pos"]) - // + (removeAttrs attrs + ["meta" "passthru" "crossAttrs" "pos" + "__impureHostDeps" "__propagatedImpureHostDeps"]) + // (let + # TODO: remove lib.unique once nix has a list canonicalization primitive + computedImpureHostDeps = + lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (extraBuildInputs ++ buildInputs ++ nativeBuildInputs)); + computedPropagatedImpureHostDeps = + lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (propagatedBuildInputs ++ propagatedNativeBuildInputs)); + in { builder = attrs.realBuilder or shell; args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)]; @@ -142,13 +167,23 @@ let __ignoreNulls = true; # Inputs built by the cross compiler. - buildInputs = if crossConfig != null then buildInputs else []; + buildInputs = if crossConfig != null then buildInputs' else []; propagatedBuildInputs = if crossConfig != null then propagatedBuildInputs else []; # Inputs built by the usual native compiler. - nativeBuildInputs = nativeBuildInputs ++ (if crossConfig == null then buildInputs else []); + nativeBuildInputs = nativeBuildInputs ++ (if crossConfig == null then buildInputs' else []); propagatedNativeBuildInputs = propagatedNativeBuildInputs ++ (if crossConfig == null then propagatedBuildInputs else []); - })) ( + } // ifDarwin { + __impureHostDeps = computedImpureHostDeps ++ computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps ++ __impureHostDeps ++ __extraImpureHostDeps ++ [ + "/dev/zero" + "/dev/random" + "/dev/urandom" + "/bin/sh" + ]; + __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; + } // (if outputs' != [ "out" ] then { + outputs = outputs'; + } 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 @@ -180,6 +215,9 @@ let setup = setupScript; inherit preHook initialPath shell defaultNativeBuildInputs; + } + // ifDarwin { + __impureHostDeps = __stdenvImpureHostDeps; }) // rec { @@ -211,16 +249,19 @@ let || system == "i686-gnu" || system == "i686-freebsd" || system == "i686-openbsd" + || system == "i686-cygwin" || system == "i386-sunos"; isx86_64 = system == "x86_64-linux" || system == "x86_64-darwin" || system == "x86_64-freebsd" || system == "x86_64-openbsd" + || system == "x86_64-cygwin" || system == "x86_64-solaris"; is64bit = system == "x86_64-linux" || system == "x86_64-darwin" || system == "x86_64-freebsd" || system == "x86_64-openbsd" + || system == "x86_64-cygwin" || system == "x86_64-solaris" || system == "mips64el-linux"; isMips = system == "mips-linux" diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 1011c4c53480..87e18db90a4b 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -19,7 +19,7 @@ runHook() { if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi eval "local -a dummy=(\"\${$var[@]}\")" for hook in "_callImplicitHook 0 $hookName" "${dummy[@]}"; do - if ! _eval "$hook" "$@"; then return 1; fi + _eval "$hook" "$@" done return 0 } @@ -73,6 +73,35 @@ _eval() { ###################################################################### +# Logging. + +nestingLevel=0 + +startNest() { + nestingLevel=$(($nestingLevel + 1)) + echo -en "\033[$1p" +} + +stopNest() { + nestingLevel=$(($nestingLevel - 1)) + echo -en "\033[q" +} + +header() { + startNest "$2" + echo "$1" +} + +# Make sure that even when we exit abnormally, the original nesting +# level is properly restored. +closeNest() { + while [ $nestingLevel -gt 0 ]; do + stopNest + done +} + + +###################################################################### # Error handling. exitHandler() { @@ -97,7 +126,7 @@ exitHandler() { # If the builder had a non-zero exit code and # $succeedOnFailure is set, create the file - # `$out/nix-support/failed' to signal failure, and exit + # ‘$out/nix-support/failed’ to signal failure, and exit # normally. Otherwise, return the original exit code. if [ -n "$succeedOnFailure" ]; then echo "build failed with exit code $exitCode (ignored)" @@ -202,7 +231,7 @@ runHook addInputsHook # Recursively find all build inputs. findInputs() { - local pkg=$1 + local pkg="$1" local var=$2 local propagatedBuildInputsFile=$3 @@ -214,17 +243,22 @@ findInputs() { eval $var="'${!var} $pkg '" - if [ -f $pkg ]; then - source $pkg + if ! [ -e "$pkg" ]; then + echo "build input $pkg does not exist" >&2 + exit 1 + fi + + if [ -f "$pkg" ]; then + source "$pkg" fi - if [ -f $pkg/nix-support/setup-hook ]; then - source $pkg/nix-support/setup-hook + if [ -f "$pkg/nix-support/setup-hook" ]; then + source "$pkg/nix-support/setup-hook" fi - if [ -f $pkg/nix-support/$propagatedBuildInputsFile ]; then - for i in $(cat $pkg/nix-support/$propagatedBuildInputsFile); do - findInputs $i $var $propagatedBuildInputsFile + if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then + for i in $(cat "$pkg/nix-support/$propagatedBuildInputsFile"); do + findInputs "$i" $var $propagatedBuildInputsFile done fi } @@ -409,32 +443,6 @@ substituteAllInPlace() { # What follows is the generic builder. -nestingLevel=0 - -startNest() { - nestingLevel=$(($nestingLevel + 1)) - echo -en "\033[$1p" -} - -stopNest() { - nestingLevel=$(($nestingLevel - 1)) - echo -en "\033[q" -} - -header() { - startNest "$2" - echo "$1" -} - -# Make sure that even when we exit abnormally, the original nesting -# level is properly restored. -closeNest() { - while [ $nestingLevel -gt 0 ]; do - stopNest - done -} - - # This function is useful for debugging broken Nix builds. It dumps # all environment variables to a file `env-vars' in the build # directory. If the build fails and the `-K' option is used, you can |