diff options
Diffstat (limited to 'nixpkgs/pkgs/build-support')
17 files changed, 304 insertions, 63 deletions
diff --git a/nixpkgs/pkgs/build-support/alternatives/blas/default.nix b/nixpkgs/pkgs/build-support/alternatives/blas/default.nix index 36708ce8841a..bdee6688a740 100644 --- a/nixpkgs/pkgs/build-support/alternatives/blas/default.nix +++ b/nixpkgs/pkgs/build-support/alternatives/blas/default.nix @@ -1,7 +1,7 @@ { lib, stdenv , lapack-reference, openblasCompat, openblas -, is64bit ? false -, blasProvider ? if is64bit then openblas else openblasCompat }: +, isILP64 ? false +, blasProvider ? if isILP64 then openblas else openblasCompat }: let blasFortranSymbols = [ @@ -31,12 +31,12 @@ let else stdenv.hostPlatform.extensions.sharedLibrary; - is64bit = blasProvider.blas64 or false; + isILP64 = blasProvider.blas64 or false; blasImplementation = lib.getName blasProvider; in -assert is64bit -> (blasImplementation == "openblas" && blasProvider.blas64) || blasImplementation == "mkl"; +assert isILP64 -> (blasImplementation == "openblas" && blasProvider.blas64) || blasImplementation == "mkl"; stdenv.mkDerivation { pname = "blas"; @@ -49,7 +49,7 @@ stdenv.mkDerivation { }; passthru = { - inherit is64bit; + inherit isILP64; provider = blasProvider; implementation = blasImplementation; }; @@ -58,10 +58,12 @@ stdenv.mkDerivation { dontConfigure = true; unpackPhase = "src=$PWD"; + dontPatchELF = true; + installPhase = ('' mkdir -p $out/lib $dev/include $dev/lib/pkgconfig - libblas="${lib.getLib blasProvider}/lib/libblas${stdenv.hostPlatform.extensions.sharedLibrary}" + libblas="${lib.getLib blasProvider}/lib/libblas${canonicalExtension}" if ! [ -e "$libblas" ]; then echo "$libblas does not exist, ${blasProvider.name} does not provide libblas." @@ -98,7 +100,7 @@ Libs: -L$out/lib -lblas Cflags: -I$dev/include EOF - libcblas="${lib.getLib blasProvider}/lib/libcblas${stdenv.hostPlatform.extensions.sharedLibrary}" + libcblas="${lib.getLib blasProvider}/lib/libcblas${canonicalExtension}" if ! [ -e "$libcblas" ]; then echo "$libcblas does not exist, ${blasProvider.name} does not provide libcblas." @@ -132,6 +134,8 @@ Libs: -L$out/lib -lcblas EOF '' + stdenv.lib.optionalString (blasImplementation == "mkl") '' mkdir -p $out/nix-support - echo 'export MKL_INTERFACE_LAYER=${lib.optionalString is64bit "I"}LP64,GNU' > $out/nix-support/setup-hook + echo 'export MKL_INTERFACE_LAYER=${lib.optionalString isILP64 "I"}LP64,GNU' > $out/nix-support/setup-hook + ln -s $out/lib/libblas${canonicalExtension} $out/lib/libmkl_rt${stdenv.hostPlatform.extensions.sharedLibrary} + ln -sf ${blasProvider}/include/* $dev/include ''); } diff --git a/nixpkgs/pkgs/build-support/alternatives/lapack/default.nix b/nixpkgs/pkgs/build-support/alternatives/lapack/default.nix index 24c339042a2f..98b458b778a7 100644 --- a/nixpkgs/pkgs/build-support/alternatives/lapack/default.nix +++ b/nixpkgs/pkgs/build-support/alternatives/lapack/default.nix @@ -1,7 +1,7 @@ { lib, stdenv , lapack-reference, openblasCompat, openblas -, is64bit ? false -, lapackProvider ? if is64bit then openblas else openblasCompat }: +, isILP64 ? false +, lapackProvider ? if isILP64 then openblas else openblasCompat }: let @@ -14,7 +14,7 @@ let in -assert is64bit -> (lapackImplementation == "openblas" && lapackProvider.blas64) || lapackImplementation == "mkl"; +assert isILP64 -> (lapackImplementation == "openblas" && lapackProvider.blas64) || lapackImplementation == "mkl"; stdenv.mkDerivation { pname = "lapack"; @@ -27,7 +27,7 @@ stdenv.mkDerivation { }; passthru = { - inherit is64bit; + inherit isILP64; provider = lapackProvider; implementation = lapackImplementation; }; @@ -36,10 +36,12 @@ stdenv.mkDerivation { dontConfigure = true; unpackPhase = "src=$PWD"; + dontPatchELF = true; + installPhase = ('' mkdir -p $out/lib $dev/include $dev/lib/pkgconfig - liblapack="${lib.getLib lapackProvider}/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}" + liblapack="${lib.getLib lapackProvider}/lib/liblapack${canonicalExtension}" if ! [ -e "$liblapack" ]; then echo "$liblapack does not exist, ${lapackProvider.name} does not provide liblapack." @@ -52,10 +54,6 @@ stdenv.mkDerivation { '' + (if stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf" then '' patchelf --set-soname liblapack${canonicalExtension} $out/lib/liblapack${canonicalExtension} patchelf --set-rpath "$(patchelf --print-rpath $out/lib/liblapack${canonicalExtension}):${lapackProvider}/lib" $out/lib/liblapack${canonicalExtension} -'' else if stdenv.hostPlatform.isDarwin then '' - install_name_tool -id liblapack${canonicalExtension} \ - -add_rpath ${lib.getLib lapackProvider}/lib \ - $out/lib/liblapack${canonicalExtension} '' else "") + '' if [ "$out/lib/liblapack${canonicalExtension}" != "$out/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}" ]; then @@ -72,7 +70,7 @@ Cflags: -I$dev/include Libs: -L$out/lib -llapack EOF - liblapacke="${lib.getLib lapackProvider}/lib/liblapacke${stdenv.hostPlatform.extensions.sharedLibrary}" + liblapacke="${lib.getLib lapackProvider}/lib/liblapacke${canonicalExtension}" if ! [ -e "$liblapacke" ]; then echo "$liblapacke does not exist, ${lapackProvider.name} does not provide liblapacke." @@ -85,10 +83,6 @@ EOF '' + (if stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf" then '' patchelf --set-soname liblapacke${canonicalExtension} $out/lib/liblapacke${canonicalExtension} patchelf --set-rpath "$(patchelf --print-rpath $out/lib/liblapacke${canonicalExtension}):${lib.getLib lapackProvider}/lib" $out/lib/liblapacke${canonicalExtension} -'' else if stdenv.hostPlatform.isDarwin then '' - install_name_tool -id liblapacke${canonicalExtension} \ - -add_rpath ${lib.getLib lapackProvider}/lib \ - $out/lib/liblapacke${canonicalExtension} '' else "") + '' if [ -f "$out/lib/liblapacke.so.3" ]; then @@ -106,6 +100,8 @@ Libs: -L$out/lib -llapacke EOF '' + stdenv.lib.optionalString (lapackImplementation == "mkl") '' mkdir -p $out/nix-support - echo 'export MKL_INTERFACE_LAYER=${lib.optionalString is64bit "I"}LP64,GNU' > $out/nix-support/setup-hook + echo 'export MKL_INTERFACE_LAYER=${lib.optionalString isILP64 "I"}LP64,GNU' > $out/nix-support/setup-hook + ln -s $out/lib/liblapack${canonicalExtension} $out/lib/libmkl_rt${stdenv.hostPlatform.extensions.sharedLibrary} + ln -sf ${lapackProvider}/include/* $dev/include ''); } diff --git a/nixpkgs/pkgs/build-support/appimage/appimage-exec.sh b/nixpkgs/pkgs/build-support/appimage/appimage-exec.sh index 1273effe5fe2..15eafc58a1ee 100755 --- a/nixpkgs/pkgs/build-support/appimage/appimage-exec.sh +++ b/nixpkgs/pkgs/build-support/appimage/appimage-exec.sh @@ -17,7 +17,7 @@ unpack() { local appimageType=0 # https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63 - eval "$(r2 "$src" -nn -Nqc "p8j 3 @ 8" | + eval "$(r2 -nn -Nqc "p8j 3 @ 8" "$src"| jq -r '{appimageSignature: (.[:-1]|implode), appimageType: .[-1]}| @sh "appimageSignature=\(.appimageSignature) appimageType=\(.appimageType)"')" @@ -38,7 +38,7 @@ unpack() { # multiarch offset one-liner using same method as AppImage # see https://gist.github.com/probonopd/a490ba3401b5ef7b881d5e603fa20c93 - offset=$(r2 "$src" -nn -Nqc "pfj.elf_header @ 0" |\ + offset=$(r2 -nn -Nqc "pfj.elf_header @ 0" "$src"|\ jq 'map({(.name): .value}) | add | .shoff + (.shnum * .shentsize)') echo "Uncompress $(basename "$src") of type $appimageType @ offset $offset." diff --git a/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix b/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix index 84020505a635..5cc99c6412a7 100644 --- a/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix +++ b/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix @@ -85,7 +85,7 @@ stdenv.mkDerivation { inherit targetPrefix infixSalt; - outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ]; + outputs = [ "out" ] ++ optionals propagateDoc ([ "man" ] ++ optional (bintools ? info) "info"); passthru = { inherit bintools libc nativeTools nativeLibc nativePrefix; @@ -259,14 +259,15 @@ stdenv.mkDerivation { printWords ${bintools_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages '' - + optionalString propagateDoc '' + + optionalString propagateDoc ('' ## ## Man page and info support ## ln -s ${bintools.man} $man + '' + optionalString (bintools ? info) '' ln -s ${bintools.info} $info - '' + '') + '' ## diff --git a/nixpkgs/pkgs/build-support/build-pecl.nix b/nixpkgs/pkgs/build-support/build-pecl.nix index f43205f24c5c..d75d3cf943a0 100644 --- a/nixpkgs/pkgs/build-support/build-pecl.nix +++ b/nixpkgs/pkgs/build-support/build-pecl.nix @@ -3,6 +3,7 @@ { pname , version , internalDeps ? [] +, peclDeps ? [] , buildInputs ? [] , nativeBuildInputs ? [] , postPhpize ? "" @@ -16,11 +17,12 @@ stdenv.mkDerivation (args // { name = "php-${pname}-${version}"; + extensionName = pname; inherit src; nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs; - buildInputs = [ php ] ++ buildInputs; + buildInputs = [ php ] ++ peclDeps ++ buildInputs; makeFlags = [ "EXTENSION_DIR=$(out)/lib/php/extensions" ] ++ makeFlags; diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh b/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh index 1358b167f6ec..323ea5bfd772 100644 --- a/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh +++ b/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh @@ -10,6 +10,7 @@ var_templates_list=( NIX+CFLAGS_LINK NIX+CXXSTDLIB_COMPILE NIX+CXXSTDLIB_LINK + NIX+GNATFLAGS_COMPILE ) var_templates_bool=( NIX+ENFORCE_NO_NATIVE @@ -40,6 +41,10 @@ if [ -e @out@/nix-support/cc-cflags ]; then NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE" fi +if [ -e @out@/nix-support/gnat-cflags ]; then + NIX_@infixSalt@_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_@infixSalt@_GNATFLAGS_COMPILE" +fi + if [ -e @out@/nix-support/cc-ldflags ]; then NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)" fi diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/default.nix b/nixpkgs/pkgs/build-support/cc-wrapper/default.nix index f6248335052c..1b7c5750727a 100644 --- a/nixpkgs/pkgs/build-support/cc-wrapper/default.nix +++ b/nixpkgs/pkgs/build-support/cc-wrapper/default.nix @@ -199,6 +199,12 @@ stdenv.mkDerivation { fi '' + + optionalString cc.langAda or false '' + wrap ${targetPrefix}gnatmake ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatmake + wrap ${targetPrefix}gnatbind ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatbind + wrap ${targetPrefix}gnatlink ${./gnat-wrapper.sh} $ccPath/${targetPrefix}gnatlink + '' + + optionalString cc.langFortran or false '' wrap ${targetPrefix}gfortran $wrapper $ccPath/${targetPrefix}gfortran ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}g77 @@ -283,6 +289,13 @@ stdenv.mkDerivation { ccLDFlags+=" -L${cc_solib}/lib" ccCFlags+=" -B${cc_solib}/lib" + '' + optionalString cc.langAda or false '' + basePath=$(echo $cc/lib/*/*/*) + ccCFlags+=" -B$basePath -I$basePath/adainclude" + gnatCFlags="-I$basePath/adainclude -I$basePath/adalib" + + echo "$gnatCFlags" > $out/nix-support/gnat-cflags + '' + '' echo "$ccLDFlags" > $out/nix-support/cc-ldflags echo "$ccCFlags" > $out/nix-support/cc-cflags '' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) '' @@ -351,6 +364,8 @@ stdenv.mkDerivation { hardening_unsupported_flags+=" stackprotector fortify pie pic" '' + optionalString targetPlatform.isNetBSD '' hardening_unsupported_flags+=" stackprotector fortify" + '' + optionalString cc.langAda or false '' + hardening_unsupported_flags+=" stackprotector strictoverflow" '' + optionalString targetPlatform.isWasm '' diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/gnat-wrapper.sh b/nixpkgs/pkgs/build-support/cc-wrapper/gnat-wrapper.sh new file mode 100644 index 000000000000..15b53d76c630 --- /dev/null +++ b/nixpkgs/pkgs/build-support/cc-wrapper/gnat-wrapper.sh @@ -0,0 +1,165 @@ +#! @shell@ +set -eu -o pipefail +o posix +shopt -s nullglob + +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + +path_backup="$PATH" + +# That @-vars are substituted separately from bash evaluation makes +# shellcheck think this, and others like it, are useless conditionals. +# shellcheck disable=SC2157 +if [[ -n "@coreutils_bin@" && -n "@gnugrep_bin@" ]]; then + PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin" +fi + +source @out@/nix-support/utils.bash + +# Flirting with a layer violation here. +if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then + source @bintools@/nix-support/add-flags.sh +fi + +# Put this one second so libc ldflags take priority. +if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then + source @out@/nix-support/add-flags.sh +fi + + +# Parse command line options and set several variables. +# For instance, figure out if linker flags should be passed. +# GCC prints annoying warnings when they are not needed. +dontLink=0 +nonFlagArgs=0 +# shellcheck disable=SC2193 + +expandResponseParams "$@" +declare -i n=0 +nParams=${#params[@]} +while (( "$n" < "$nParams" )); do + p=${params[n]} + p2=${params[n+1]:-} # handle `p` being last one + if [ "$p" = -c ]; then + dontLink=1 + elif [ "$p" = -S ]; then + dontLink=1 + elif [ "$p" = -E ]; then + dontLink=1 + elif [ "$p" = -E ]; then + dontLink=1 + elif [ "$p" = -M ]; then + dontLink=1 + elif [ "$p" = -MM ]; then + dontLink=1 + elif [[ "$p" = -x && "$p2" = *-header ]]; then + dontLink=1 + elif [[ "$p" != -?* ]]; then + # A dash alone signifies standard input; it is not a flag + nonFlagArgs=1 + fi + n+=1 +done + +# If we pass a flag like -Wl, then gcc will call the linker unless it +# can figure out that it has to do something else (e.g., because of a +# "-c" flag). So if no non-flag arguments are given, don't pass any +# linker flags. This catches cases like "gcc" (should just print +# "gcc: no input files") and "gcc -v" (should print the version). +if [ "$nonFlagArgs" = 0 ]; then + dontLink=1 +fi + +# Optionally filter out paths not refering to the store. +if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then + rest=() + nParams=${#params[@]} + declare -i n=0 + while (( "$n" < "$nParams" )); do + p=${params[n]} + p2=${params[n+1]:-} # handle `p` being last one + if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then + skip "${p:2}" + elif [ "$p" = -L ] && badPath "$p2"; then + n+=1; skip "$p2" + elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then + skip "${p:2}" + elif [ "$p" = -I ] && badPath "$p2"; then + n+=1; skip "$p2" + elif [ "${p:0:4}" = -aI/ ] && badPath "${p:3}"; then + skip "${p:3}" + elif [ "$p" = -aI ] && badPath "$p2"; then + n+=1; skip "$p2" + elif [ "${p:0:4}" = -aO/ ] && badPath "${p:3}"; then + skip "${p:3}" + elif [ "$p" = -aO ] && badPath "$p2"; then + n+=1; skip "$p2" + elif [ "$p" = -isystem ] && badPath "$p2"; then + n+=1; skip "$p2" + else + rest+=("$p") + fi + n+=1 + done + # Old bash empty array hack + params=(${rest+"${rest[@]}"}) +fi + + +# Clear march/mtune=native -- they bring impurity. +if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then + rest=() + # Old bash empty array hack + for p in ${params+"${params[@]}"}; do + if [[ "$p" = -m*=native ]]; then + skip "$p" + else + rest+=("$p") + fi + done + # Old bash empty array hack + params=(${rest+"${rest[@]}"}) +fi + +if [ "$(basename $0)x" = "gnatmakex" ]; then + extraBefore=("--GNATBIND=@out@/bin/gnatbind" "--GNATLINK=@out@/bin/gnatlink") + extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE) +fi + +if [ "$(basename $0)x" = "gnatbindx" ]; then + extraBefore=() + extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE) +fi + +if [ "$(basename $0)x" = "gnatlinkx" ]; then + extraBefore=() + extraAfter=("--GCC=@out@/bin/gcc") +fi + +# As a very special hack, if the arguments are just `-v', then don't +# add anything. This is to prevent `gcc -v' (which normally prints +# out the version number and returns exit code 0) from printing out +# `No input files specified' and returning exit code 1. +if [ "$*" = -v ]; then + extraAfter=() + extraBefore=() +fi + +# Optionally print debug info. +if (( "${NIX_DEBUG:-0}" >= 1 )); then + # Old bash workaround, see ld-wrapper for explanation. + echo "extra flags before to @prog@:" >&2 + printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 + echo "original flags to @prog@:" >&2 + printf " %q\n" ${params+"${params[@]}"} >&2 + echo "extra flags after to @prog@:" >&2 + printf " %q\n" ${extraAfter+"${extraAfter[@]}"} >&2 +fi + +PATH="$path_backup" +# Old bash workaround, see above. +exec @prog@ \ + ${extraBefore+"${extraBefore[@]}"} \ + ${params+"${params[@]}"} \ + ${extraAfter+"${extraAfter[@]}"} diff --git a/nixpkgs/pkgs/build-support/docker/default.nix b/nixpkgs/pkgs/build-support/docker/default.nix index 28c0d2dfcae1..bee6e37cccbb 100644 --- a/nixpkgs/pkgs/build-support/docker/default.nix +++ b/nixpkgs/pkgs/build-support/docker/default.nix @@ -32,7 +32,29 @@ }: # WARNING: this API is unstable and may be subject to backwards-incompatible changes in the future. +let + + mkDbExtraCommand = contents: let + contentsList = if builtins.isList contents then contents else [ contents ]; + in '' + echo "Generating the nix database..." + echo "Warning: only the database of the deepest Nix layer is loaded." + echo " If you want to use nix commands in the container, it would" + echo " be better to only have one layer that contains a nix store." + + export NIX_REMOTE=local?root=$PWD + # A user is required by nix + # https://github.com/NixOS/nix/blob/9348f9291e5d9e4ba3c4347ea1b235640f54fd79/src/libutil/util.cc#L478 + export USER=nobody + ${nix}/bin/nix-store --load-db < ${closureInfo {rootPaths = contentsList;}}/registration + + mkdir -p nix/var/nix/gcroots/docker/ + for i in ${lib.concatStringsSep " " contentsList}; do + ln -s $i nix/var/nix/gcroots/docker/$(basename $i) + done; + ''; +in rec { examples = callPackage ./examples.nix { @@ -874,25 +896,16 @@ rec { # contents. The main purpose is to be able to use nix commands in # the container. # Be careful since this doesn't work well with multilayer. - buildImageWithNixDb = args@{ contents ? null, extraCommands ? "", ... }: - let contentsList = if builtins.isList contents then contents else [ contents ]; - in buildImage (args // { - extraCommands = '' - echo "Generating the nix database..." - echo "Warning: only the database of the deepest Nix layer is loaded." - echo " If you want to use nix commands in the container, it would" - echo " be better to only have one layer that contains a nix store." - - export NIX_REMOTE=local?root=$PWD - # A user is required by nix - # https://github.com/NixOS/nix/blob/9348f9291e5d9e4ba3c4347ea1b235640f54fd79/src/libutil/util.cc#L478 - export USER=nobody - ${nix}/bin/nix-store --load-db < ${closureInfo {rootPaths = contentsList;}}/registration - - mkdir -p nix/var/nix/gcroots/docker/ - for i in ${lib.concatStringsSep " " contentsList}; do - ln -s $i nix/var/nix/gcroots/docker/$(basename $i) - done; - '' + extraCommands; - }); + buildImageWithNixDb = args@{ contents ? null, extraCommands ? "", ... }: ( + buildImage (args // { + extraCommands = (mkDbExtraCommand contents) + extraCommands; + }) + ); + + buildLayeredImageWithNixDb = args@{ contents ? null, extraCommands ? "", ... }: ( + buildLayeredImage (args // { + extraCommands = (mkDbExtraCommand contents) + extraCommands; + }) + ); + } diff --git a/nixpkgs/pkgs/build-support/docker/nix-prefetch-docker.nix b/nixpkgs/pkgs/build-support/docker/nix-prefetch-docker.nix index c1d86adc6d81..6341eb0154b0 100644 --- a/nixpkgs/pkgs/build-support/docker/nix-prefetch-docker.nix +++ b/nixpkgs/pkgs/build-support/docker/nix-prefetch-docker.nix @@ -1,4 +1,4 @@ -{ stdenv, makeWrapper, nix, skopeo }: +{ stdenv, makeWrapper, nix, skopeo, jq }: with stdenv.lib; @@ -12,7 +12,7 @@ stdenv.mkDerivation { installPhase = '' install -vD ${./nix-prefetch-docker} $out/bin/$name; wrapProgram $out/bin/$name \ - --prefix PATH : ${makeBinPath [ nix skopeo ]} \ + --prefix PATH : ${makeBinPath [ nix skopeo jq ]} \ --set HOME /homeless-shelter ''; diff --git a/nixpkgs/pkgs/build-support/fetchgit/nix-prefetch-git b/nixpkgs/pkgs/build-support/fetchgit/nix-prefetch-git index abba76bd1ac9..43f7c5acd5ad 100755 --- a/nixpkgs/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/nixpkgs/pkgs/build-support/fetchgit/nix-prefetch-git @@ -373,6 +373,7 @@ print_results() { "url": "$(json_escape "$url")", "rev": "$(json_escape "$fullRev")", "date": "$(json_escape "$commitDateStrict8601")", + "path": "$(json_escape "$finalPath")", "$(json_escape "$hashType")": "$(json_escape "$hash")", "fetchSubmodules": $([[ -n "$fetchSubmodules" ]] && echo true || echo false), "deepClone": $([[ -n "$deepClone" ]] && echo true || echo false), diff --git a/nixpkgs/pkgs/build-support/fetchurl/builder.sh b/nixpkgs/pkgs/build-support/fetchurl/builder.sh index 74fdc320835f..e93c98419a67 100644 --- a/nixpkgs/pkgs/build-support/fetchurl/builder.sh +++ b/nixpkgs/pkgs/build-support/fetchurl/builder.sh @@ -47,13 +47,18 @@ tryDownload() { finish() { + local skipPostFetch="$1" + set +o noglob if [[ $executable == "1" ]]; then chmod +x $downloadedFile fi - runHook postFetch + if [ -z "$skipPostFetch" ]; then + runHook postFetch + fi + exit 0 } @@ -69,7 +74,13 @@ tryHashedMirrors() { --fail --silent --show-error --head "$url" \ --write-out "%{http_code}" --output /dev/null > code 2> log; then tryDownload "$url" - if test -n "$success"; then finish; fi + + # We skip postFetch here, because hashed-mirrors are + # already content addressed. So if $outputHash is in the + # hashed-mirror, changes from ‘postFetch’ would already be + # made. So, running postFetch will end up applying the + # change /again/, which we don’t want. + if test -n "$success"; then finish skipPostFetch; fi else # Be quiet about 404 errors, which we interpret as the file # not being present on this particular mirror. diff --git a/nixpkgs/pkgs/build-support/fetchurl/default.nix b/nixpkgs/pkgs/build-support/fetchurl/default.nix index 7d23a3a7f8f1..a0c48468dfac 100644 --- a/nixpkgs/pkgs/build-support/fetchurl/default.nix +++ b/nixpkgs/pkgs/build-support/fetchurl/default.nix @@ -65,7 +65,7 @@ in , # Shell code to build a netrc file for BASIC auth netrcPhase ? null -, # Impure env vars (http://nixos.org/nix/manual/#sec-advanced-attributes) +, # Impure env vars (https://nixos.org/nix/manual/#sec-advanced-attributes) # needed for netrcPhase netrcImpureEnvVars ? [] diff --git a/nixpkgs/pkgs/build-support/ocaml/dune.nix b/nixpkgs/pkgs/build-support/ocaml/dune.nix index 435bbe89c1c4..b134effab8ac 100644 --- a/nixpkgs/pkgs/build-support/ocaml/dune.nix +++ b/nixpkgs/pkgs/build-support/ocaml/dune.nix @@ -1,6 +1,6 @@ { stdenv, ocaml, findlib, dune, dune_2, opaline }: -{ pname, version, buildInputs ? [], ... }@args: +{ pname, version, buildInputs ? [], enableParallelBuilding ? true, ... }@args: let Dune = if args.useDune2 or false then dune_2 else dune; in @@ -11,14 +11,16 @@ else stdenv.mkDerivation ({ + inherit enableParallelBuilding; + buildPhase = '' runHook preBuild - dune build -p ${pname} + dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} runHook postBuild ''; checkPhase = '' runHook preCheck - dune runtest -p ${pname} + dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} runHook postCheck ''; installPhase = '' diff --git a/nixpkgs/pkgs/build-support/setup-hooks/auto-patchelf.sh b/nixpkgs/pkgs/build-support/setup-hooks/auto-patchelf.sh index 52c50091d08c..72970623ed79 100644 --- a/nixpkgs/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/nixpkgs/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -15,7 +15,7 @@ isExecutable() { # *or* there is an INTERP section. This also catches position-independent # executables, as they typically have an INTERP section but their ELF type # is DYN. - isExeResult="$(LANG=C readelf -h -l "$1" 2> /dev/null \ + isExeResult="$(LANG=C $READELF -h -l "$1" 2> /dev/null \ | grep '^ *Type: *EXEC\>\|^ *INTERP\>')" # not using grep -q, because it can cause Broken pipe [ -n "$isExeResult" ] @@ -207,7 +207,7 @@ autoPatchelf() { # outside of this function. while IFS= read -r -d $'\0' file; do isELF "$file" || continue - segmentHeaders="$(LANG=C readelf -l "$file")" + segmentHeaders="$(LANG=C $READELF -l "$file")" # Skip if the ELF file doesn't have segment headers (eg. object files). # not using grep -q, because it can cause Broken pipe [ -n "$(echo "$segmentHeaders" | grep '^Program Headers:')" ] || continue diff --git a/nixpkgs/pkgs/build-support/src-only/default.nix b/nixpkgs/pkgs/build-support/src-only/default.nix index c2f7cfb93998..c721fdf40c69 100644 --- a/nixpkgs/pkgs/build-support/src-only/default.nix +++ b/nixpkgs/pkgs/build-support/src-only/default.nix @@ -1,6 +1,31 @@ -{ stdenv, name, src, patches ? [], buildInputs ? [] }: +{ stdenv }@orig: +# srcOnly is a utility builder that only fetches and unpacks the given `src`, +# maybe pathings it in the process with the optional `patches` and +# `buildInputs` attributes. +# +# It can be invoked directly, or be used to wrap an existing derivation. Eg: +# +# > srcOnly pkgs.hello +# +{ name +, src +, stdenv ? orig.stdenv +, patches ? [] +, # deprecated, use the nativeBuildInputs + buildInputs ? [] +, # used to pass extra unpackers + nativeBuildInputs ? [] +, # needed when passing an existing derivation + ... +}: stdenv.mkDerivation { - inherit src buildInputs patches name; + inherit + buildInputs + name + nativeBuildInputs + patches + src + ; installPhase = "cp -r . $out"; phases = ["unpackPhase" "patchPhase" "installPhase"]; } diff --git a/nixpkgs/pkgs/build-support/trivial-builders.nix b/nixpkgs/pkgs/build-support/trivial-builders.nix index c67f5845135b..3c81a4ece657 100644 --- a/nixpkgs/pkgs/build-support/trivial-builders.nix +++ b/nixpkgs/pkgs/build-support/trivial-builders.nix @@ -4,7 +4,8 @@ let runCommand' = runLocal: stdenv: name: env: buildCommand: stdenv.mkDerivation ({ - inherit name buildCommand; + name = lib.strings.sanitizeDerivationName name; + inherit buildCommand; passAsFile = [ "buildCommand" ]; } // (lib.optionalAttrs runLocal { |