From 43a98868ae1c202e6151e05e25f5d038c17cbd4e Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 29 Oct 2019 19:42:31 -0400 Subject: [PATCH 01/13] common setup hooks: set -u robustness Explicitly handle `dont*` and friends not being defined. --- pkgs/build-support/setup-hooks/audit-tmpdir.sh | 2 +- pkgs/build-support/setup-hooks/compress-man-pages.sh | 2 +- pkgs/build-support/setup-hooks/move-lib64.sh | 2 +- pkgs/build-support/setup-hooks/move-sbin.sh | 2 +- pkgs/build-support/setup-hooks/multiple-outputs.sh | 6 +++--- pkgs/build-support/setup-hooks/prune-libtool-files.sh | 2 +- pkgs/build-support/setup-hooks/strip.sh | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/build-support/setup-hooks/audit-tmpdir.sh b/pkgs/build-support/setup-hooks/audit-tmpdir.sh index 5264ce398511..c9dd32d1dd22 100644 --- a/pkgs/build-support/setup-hooks/audit-tmpdir.sh +++ b/pkgs/build-support/setup-hooks/audit-tmpdir.sh @@ -7,7 +7,7 @@ # the moment that would produce too many spurious errors (e.g. debug # info or assertion messages that refer to $TMPDIR). -fixupOutputHooks+=('if [ -z "$noAuditTmpdir" -a -e "$prefix" ]; then auditTmpdir "$prefix"; fi') +fixupOutputHooks+=('if [[ -z "${noAuditTmpdir-}" && -e "$prefix" ]]; then auditTmpdir "$prefix"; fi') auditTmpdir() { local dir="$1" diff --git a/pkgs/build-support/setup-hooks/compress-man-pages.sh b/pkgs/build-support/setup-hooks/compress-man-pages.sh index d10a898d6e46..82e48cd8aa77 100644 --- a/pkgs/build-support/setup-hooks/compress-man-pages.sh +++ b/pkgs/build-support/setup-hooks/compress-man-pages.sh @@ -1,4 +1,4 @@ -fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi') +fixupOutputHooks+=('if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi') compressManPages() { local dir="$1" diff --git a/pkgs/build-support/setup-hooks/move-lib64.sh b/pkgs/build-support/setup-hooks/move-lib64.sh index 7724be369c9c..9517af797323 100644 --- a/pkgs/build-support/setup-hooks/move-lib64.sh +++ b/pkgs/build-support/setup-hooks/move-lib64.sh @@ -8,7 +8,7 @@ fixupOutputHooks+=(_moveLib64) _moveLib64() { - if [ "$dontMoveLib64" = 1 ]; then return; fi + if [ "${dontMoveLib64-}" = 1 ]; then return; fi if [ ! -e "$prefix/lib64" -o -L "$prefix/lib64" ]; then return; fi echo "moving $prefix/lib64/* to $prefix/lib" mkdir -p $prefix/lib diff --git a/pkgs/build-support/setup-hooks/move-sbin.sh b/pkgs/build-support/setup-hooks/move-sbin.sh index cc51c27cafdf..1c0c4dc9f2d9 100644 --- a/pkgs/build-support/setup-hooks/move-sbin.sh +++ b/pkgs/build-support/setup-hooks/move-sbin.sh @@ -5,7 +5,7 @@ fixupOutputHooks+=(_moveSbin) _moveSbin() { - if [ "$dontMoveSbin" = 1 ]; then return; fi + if [ "${dontMoveSbin-}" = 1 ]; then return; fi if [ ! -e "$prefix/sbin" -o -L "$prefix/sbin" ]; then return; fi echo "moving $prefix/sbin/* to $prefix/bin" mkdir -p $prefix/bin diff --git a/pkgs/build-support/setup-hooks/multiple-outputs.sh b/pkgs/build-support/setup-hooks/multiple-outputs.sh index d43b18776742..32d4e065875b 100644 --- a/pkgs/build-support/setup-hooks/multiple-outputs.sh +++ b/pkgs/build-support/setup-hooks/multiple-outputs.sh @@ -9,8 +9,8 @@ _assignFirst() { local varName="$1" local REMOVE=REMOVE # slightly hacky - we allow REMOVE (i.e. not a variable name) shift - while [ $# -ge 1 ]; do - if [ -n "${!1}" ]; then eval "${varName}"="$1"; return; fi + while (( $# )); do + if [ -n "${!1-}" ]; then eval "${varName}"="$1"; return; fi shift done echo "Error: _assignFirst found no valid variant!" @@ -19,7 +19,7 @@ _assignFirst() { # Same as _assignFirst, but only if "$1" = "" _overrideFirst() { - if [ -z "${!1}" ]; then + if [ -z "${!1-}" ]; then _assignFirst "$@" fi } diff --git a/pkgs/build-support/setup-hooks/prune-libtool-files.sh b/pkgs/build-support/setup-hooks/prune-libtool-files.sh index 5d7432e8f09a..0ec56549645c 100644 --- a/pkgs/build-support/setup-hooks/prune-libtool-files.sh +++ b/pkgs/build-support/setup-hooks/prune-libtool-files.sh @@ -8,7 +8,7 @@ fixupOutputHooks+=(_pruneLibtoolFiles) _pruneLibtoolFiles() { - if [ "$dontPruneLibtoolFiles" ] || [ ! -e "$prefix" ]; then + if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then return fi diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh index fc4c7bfbaf95..f5fa9378fd7e 100644 --- a/pkgs/build-support/setup-hooks/strip.sh +++ b/pkgs/build-support/setup-hooks/strip.sh @@ -10,7 +10,7 @@ _doStrip() { local -ra stripCmds=(STRIP TARGET_STRIP) # Optimization - if [[ "$STRIP" == "$TARGET_STRIP" ]]; then + if [[ "${STRIP-}" == "${TARGET_STRIP-}" ]]; then dontStripTarget+=1 fi @@ -20,7 +20,7 @@ _doStrip() { local -n stripCmd="${stripCmds[$i]}" # `dontStrip` disables them all - if [[ "$dontStrip" || "$flag" ]] || ! type -f "$stripCmd" 2>/dev/null + if [[ "${dontStrip-}" || "${flag-}" ]] || ! type -f "${stripCmd-}" 2>/dev/null then continue; fi stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin} From 545e7518a808081261a6331c19ec9c5cffea4a81 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 29 Oct 2019 19:44:44 -0400 Subject: [PATCH 02/13] bintools-wrapper: Don't stop `set -u`-ing Same justification as previous commit. --- pkgs/build-support/bintools-wrapper/default.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index e02e77de45e4..9f5395b635e0 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -111,17 +111,13 @@ stdenv.mkDerivation { installPhase = '' - set -u - mkdir -p $out/bin $out/nix-support wrap() { local dst="$1" local wrapper="$2" export prog="$3" - set +u substituteAll "$wrapper" "$out/bin/$dst" - set -u chmod +x "$out/bin/$dst" } '' @@ -163,8 +159,6 @@ stdenv.mkDerivation { [[ -e "$underlying" ]] || continue wrap ${targetPrefix}$variant ${./ld-wrapper.sh} $underlying done - - set +u ''; emulation = let @@ -307,7 +301,6 @@ stdenv.mkDerivation { '' + '' - set +u substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash From d21a66064209083a2f14957792028c864cc8b8cf Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 29 Oct 2019 19:58:57 -0400 Subject: [PATCH 03/13] gettext, libiconv: `dontAddExtraLibs` can be legitimately undefined --- pkgs/development/libraries/gettext/gettext-setup-hook.sh | 2 +- pkgs/development/libraries/libiconv/setup-hook.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/gettext/gettext-setup-hook.sh b/pkgs/development/libraries/gettext/gettext-setup-hook.sh index ad3763c29b64..69020146f84d 100644 --- a/pkgs/development/libraries/gettext/gettext-setup-hook.sh +++ b/pkgs/development/libraries/gettext/gettext-setup-hook.sh @@ -10,7 +10,7 @@ addEnvHooks "$hostOffset" gettextDataDirsHook # libintl must be listed in load flags on non-Glibc # it doesn't hurt to have it in Glibc either though -if [ -n "@gettextNeedsLdflags@" -a -z "$dontAddExtraLibs" ]; then +if [ -n "@gettextNeedsLdflags@" -a -z "${dontAddExtraLibs-}" ]; then # See pkgs/build-support/setup-hooks/role.bash getHostRole export NIX_${role_pre}LDFLAGS+=" -lintl" diff --git a/pkgs/development/libraries/libiconv/setup-hook.sh b/pkgs/development/libraries/libiconv/setup-hook.sh index f89361a62998..120cf06c61b5 100644 --- a/pkgs/development/libraries/libiconv/setup-hook.sh +++ b/pkgs/development/libraries/libiconv/setup-hook.sh @@ -2,7 +2,7 @@ # it doesn't hurt to have it in Glibc either though # See pkgs/build-support/setup-hooks/role.bash -if [ -z "$dontAddExtraLibs" ]; then +if [ -z "${dontAddExtraLibs-}" ]; then getHostRole export NIX_${role_pre}LDFLAGS+=" -liconv" fi From 3835442cf0973f435b6f543977fe40b7a2b9c51c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 30 Oct 2019 14:40:07 +0000 Subject: [PATCH 04/13] patchelf: `dontPatchELF` in setup hook is allowed to be undefined --- pkgs/development/tools/misc/patchelf/setup-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/misc/patchelf/setup-hook.sh b/pkgs/development/tools/misc/patchelf/setup-hook.sh index bc1cddd4879c..576b9ca2103e 100644 --- a/pkgs/development/tools/misc/patchelf/setup-hook.sh +++ b/pkgs/development/tools/misc/patchelf/setup-hook.sh @@ -2,7 +2,7 @@ # directories from the RPATH of every library or executable in every # output. -fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi') +fixupOutputHooks+=('if [ -z "${dontPatchELF-}" ]; then patchELF "$prefix"; fi') patchELF() { local dir="$1" From 1290e532eac8f8a1815c0aedee94796509e04e3d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 30 Oct 2019 15:16:20 +0000 Subject: [PATCH 05/13] treewide: Make more `dont*` variables OK to be undefined in setup hooks --- .../libraries/qt-5/hooks/qtbase-setup-hook.sh | 2 +- .../tools/build-managers/cmake/setup-hook.sh | 10 +++++----- pkgs/development/tools/build-managers/gn/setup-hook.sh | 2 +- .../tools/build-managers/meson/setup-hook.sh | 4 ++-- .../tools/build-managers/ninja/setup-hook.sh | 6 +++--- .../tools/build-managers/scons/setup-hook.sh | 2 +- pkgs/servers/x11/xorg/imake-setup-hook.sh | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index 436c2e1d032a..836e154148be 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -61,6 +61,6 @@ postPatchMkspecs() { fixQtBuiltinPaths "$dev/mkspecs" '*.pr?' fi } -if [ -z "$dontPatchMkspecs" ]; then +if [ -z "${dontPatchMkspecs-}" ]; then postPhases="${postPhases}${postPhases:+ }postPatchMkspecs" fi diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh index b8716c5251eb..dbd40bf71242 100755 --- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh +++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh @@ -20,17 +20,17 @@ cmakeConfigurePhase() { export CTEST_PARALLEL_LEVEL=$NIX_BUILD_CORES fi - if [ -z "$dontFixCmake" ]; then + if [ -z "${dontFixCmake-}" ]; then fixCmakeFiles . fi - if [ -z "$dontUseCmakeBuildDir" ]; then + if [ -z "${dontUseCmakeBuildDir-}" ]; then mkdir -p build cd build cmakeDir=${cmakeDir:-..} fi - if [ -z "$dontAddPrefix" ]; then + if [ -z "${dontAddPrefix-}" ]; then cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags" fi @@ -84,7 +84,7 @@ cmakeConfigurePhase() { cmakeFlags="-DCMAKE_INSTALL_LOCALEDIR=${!outputLib}/share/locale $cmakeFlags" # Don’t build tests when doCheck = false - if [ -z "$doCheck" ]; then + if [ -z "${doCheck-}" ]; then cmakeFlags="-DBUILD_TESTING=OFF $cmakeFlags" fi @@ -115,7 +115,7 @@ cmakeConfigurePhase() { runHook postConfigure } -if [ -z "$dontUseCmakeConfigure" -a -z "$configurePhase" ]; then +if [ -z "${dontUseCmakeConfigure-}" -a -z "$configurePhase" ]; then setOutputFlags= configurePhase=cmakeConfigurePhase fi diff --git a/pkgs/development/tools/build-managers/gn/setup-hook.sh b/pkgs/development/tools/build-managers/gn/setup-hook.sh index 75d2edcaf1c6..4f772d2369ba 100644 --- a/pkgs/development/tools/build-managers/gn/setup-hook.sh +++ b/pkgs/development/tools/build-managers/gn/setup-hook.sh @@ -9,6 +9,6 @@ gnConfigurePhase() { runHook postConfigure } -if [ -z "$dontUseGnConfigure" -a -z "$configurePhase" ]; then +if [ -z "${dontUseGnConfigure-}" -a -z "$configurePhase" ]; then configurePhase=gnConfigurePhase fi diff --git a/pkgs/development/tools/build-managers/meson/setup-hook.sh b/pkgs/development/tools/build-managers/meson/setup-hook.sh index 6e8d94523e14..bfb40303cd85 100644 --- a/pkgs/development/tools/build-managers/meson/setup-hook.sh +++ b/pkgs/development/tools/build-managers/meson/setup-hook.sh @@ -1,7 +1,7 @@ mesonConfigurePhase() { runHook preConfigure - if [ -z "$dontAddPrefix" ]; then + if [ -z "${dontAddPrefix-}" ]; then mesonFlags="--prefix=$prefix $mesonFlags" fi @@ -36,7 +36,7 @@ mesonConfigurePhase() { runHook postConfigure } -if [ -z "$dontUseMesonConfigure" -a -z "$configurePhase" ]; then +if [ -z "${dontUseMesonConfigure-}" -a -z "$configurePhase" ]; then setOutputFlags= configurePhase=mesonConfigurePhase fi diff --git a/pkgs/development/tools/build-managers/ninja/setup-hook.sh b/pkgs/development/tools/build-managers/ninja/setup-hook.sh index e3c67bd139dd..76de25aaabf1 100644 --- a/pkgs/development/tools/build-managers/ninja/setup-hook.sh +++ b/pkgs/development/tools/build-managers/ninja/setup-hook.sh @@ -19,7 +19,7 @@ ninjaBuildPhase() { runHook postBuild } -if [ -z "$dontUseNinjaBuild" -a -z "$buildPhase" ]; then +if [ -z "${dontUseNinjaBuild-}" -a -z "$buildPhase" ]; then buildPhase=ninjaBuildPhase fi @@ -38,7 +38,7 @@ ninjaInstallPhase() { runHook postInstall } -if [ -z "$dontUseNinjaInstall" -a -z "$installPhase" ]; then +if [ -z "${dontUseNinjaInstall-}" -a -z "$installPhase" ]; then installPhase=ninjaInstallPhase fi @@ -73,6 +73,6 @@ ninjaCheckPhase() { runHook postCheck } -if [ -z "$dontUseNinjaCheck" -a -z "$checkPhase" ]; then +if [ -z "${dontUseNinjaCheck-}" -a -z "$checkPhase" ]; then checkPhase=ninjaCheckPhase fi diff --git a/pkgs/development/tools/build-managers/scons/setup-hook.sh b/pkgs/development/tools/build-managers/scons/setup-hook.sh index 55159aa5a93a..428852ac574a 100644 --- a/pkgs/development/tools/build-managers/scons/setup-hook.sh +++ b/pkgs/development/tools/build-managers/scons/setup-hook.sh @@ -75,7 +75,7 @@ if [ -z "$buildPhase" ]; then buildPhase=sconsBuildPhase fi -if [ -z "$dontUseSconsInstall" -a -z "$installPhase" ]; then +if [ -z "${dontUseSconsInstall-}" -a -z "$installPhase" ]; then installPhase=sconsInstallPhase fi diff --git a/pkgs/servers/x11/xorg/imake-setup-hook.sh b/pkgs/servers/x11/xorg/imake-setup-hook.sh index 10f54198f7fb..e743093af0ec 100644 --- a/pkgs/servers/x11/xorg/imake-setup-hook.sh +++ b/pkgs/servers/x11/xorg/imake-setup-hook.sh @@ -14,6 +14,6 @@ imakeConfigurePhase() { runHook postConfigure } -if [ -z "$dontUseImakeConfigure" -a -z "$configurePhase" ]; then +if [ -z "${dontUseImakeConfigure-}" -a -z "$configurePhase" ]; then configurePhase=imakeConfigurePhase fi From 2811b032d639684d3983282e9d10d89f37d161d5 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 31 Oct 2019 16:50:15 +0000 Subject: [PATCH 06/13] treewide: Make still dont* Variables are optional in most cases Go beyond the obvious setup hooks now, with a bit of sed, with a skipped case: - cc-wrapper's `dontlink`, because it already is handled. Also, in nix files escaping was manually added. EMP --- pkgs/build-support/build-dotnet-package/default.nix | 8 ++++---- pkgs/build-support/setup-hooks/auto-patchelf.sh | 2 +- pkgs/build-support/setup-hooks/patch-shebangs.sh | 2 +- .../setup-hooks/update-autotools-gnu-config-scripts.sh | 2 +- pkgs/build-support/setup-hooks/wrap-gapps-hook.sh | 2 +- .../interpreters/python/hooks/flit-build-hook.sh | 2 +- .../interpreters/python/hooks/pip-build-hook.sh | 2 +- .../interpreters/python/hooks/pip-install-hook.sh | 2 +- .../interpreters/python/hooks/pytest-check-hook.sh | 2 +- .../python/hooks/python-catch-conflicts-hook.sh | 2 +- .../python/hooks/python-imports-check-hook.sh | 2 +- .../python/hooks/python-remove-bin-bytecode-hook.sh | 2 +- .../interpreters/python/hooks/setuptools-build-hook.sh | 4 ++-- .../interpreters/python/hooks/setuptools-check-hook.sh | 2 +- .../interpreters/python/hooks/wheel-unpack-hook.sh | 2 +- pkgs/development/libraries/qt-5/hooks/qmake-hook.sh | 2 +- .../development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh | 4 ++-- pkgs/development/node-packages/node-env.nix | 2 +- pkgs/development/python-modules/pythonnet/default.nix | 4 ++-- pkgs/development/ruby-modules/gem/default.nix | 2 +- pkgs/development/tools/ocaml/opam/opam-shebangs.patch | 2 +- pkgs/os-specific/linux/kernel/manual-config.nix | 2 +- pkgs/stdenv/cygwin/rebase-i686.sh | 2 +- pkgs/stdenv/cygwin/rebase-x86_64.sh | 2 +- 24 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pkgs/build-support/build-dotnet-package/default.nix b/pkgs/build-support/build-dotnet-package/default.nix index f36c69e43392..dae9ed888c75 100644 --- a/pkgs/build-support/build-dotnet-package/default.nix +++ b/pkgs/build-support/build-dotnet-package/default.nix @@ -29,9 +29,9 @@ attrsOrig @ configurePhase = '' runHook preConfigure - [ -z "$dontPlacateNuget" ] && placate-nuget.sh - [ -z "$dontPlacatePaket" ] && placate-paket.sh - [ -z "$dontPatchFSharpTargets" ] && patch-fsharp-targets.sh + [ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh + [ -z "''${dontPlacatePaket-}" ] && placate-paket.sh + [ -z "''${dontPatchFSharpTargets-}" ] && patch-fsharp-targets.sh runHook postConfigure ''; @@ -69,7 +69,7 @@ attrsOrig @ cp -rv ${arrayToShell outputFiles} "''${outputFilesArray[@]}" "$target" - if [ -z "$dontRemoveDuplicatedDlls" ] + if [ -z "''${dontRemoveDuplicatedDlls-}" ] then pushd "$out" remove-duplicated-dlls.sh diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 6af8eb1aed99..52c50091d08c 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -228,7 +228,7 @@ autoPatchelf() { # behaviour as fixupOutputHooks because the setup hook for patchelf is run in # fixupOutput and the postFixup hook runs later. postFixupHooks+=(' - if [ -z "$dontAutoPatchelf" ]; then + if [ -z "${dontAutoPatchelf-}" ]; then autoPatchelf -- $(for output in $outputs; do [ -e "${!output}" ] || continue echo "${!output}" diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index 3e900d0704cf..29fed7ad7940 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -105,7 +105,7 @@ patchShebangs() { } patchShebangsAuto () { - if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then + if [ -z "${dontPatchShebangs-}" -a -e "$prefix" ]; then # Dev output will end up being run on the build platform. An # example case of this is sdl2-config. Otherwise, we can just diff --git a/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh b/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh index 66f4e91c7bb6..ebd3afa05d94 100644 --- a/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh +++ b/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh @@ -1,7 +1,7 @@ preConfigurePhases+=" updateAutotoolsGnuConfigScriptsPhase" updateAutotoolsGnuConfigScriptsPhase() { - if [ -n "$dontUpdateAutotoolsGnuConfigScripts" ]; then return; fi + if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then return; fi for script in config.sub config.guess; do for f in $(find . -type f -name "$script"); do diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh index 717740f1f20f..a05d4f689db9 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh @@ -15,7 +15,7 @@ wrapGApp() { wrapProgram "$program" "${gappsWrapperArgs[@]}" "$@" } -# Note: $gappsWrapperArgs still gets defined even if $dontWrapGApps is set. +# Note: $gappsWrapperArgs still gets defined even if ${dontWrapGApps-} is set. wrapGAppsHook() { # guard against running multiple times (e.g. due to propagation) [ -z "$wrapGAppsHookHasRun" ] || return 0 diff --git a/pkgs/development/interpreters/python/hooks/flit-build-hook.sh b/pkgs/development/interpreters/python/hooks/flit-build-hook.sh index 48295dc36430..23198bd711b8 100644 --- a/pkgs/development/interpreters/python/hooks/flit-build-hook.sh +++ b/pkgs/development/interpreters/python/hooks/flit-build-hook.sh @@ -9,7 +9,7 @@ flitBuildPhase () { echo "Finished executing flitBuildPhase" } -if [ -z "$dontUseFlitBuild" ] && [ -z "$buildPhase" ]; then +if [ -z "${dontUseFlitBuild-}" ] && [ -z "$buildPhase" ]; then echo "Using flitBuildPhase" buildPhase=flitBuildPhase fi diff --git a/pkgs/development/interpreters/python/hooks/pip-build-hook.sh b/pkgs/development/interpreters/python/hooks/pip-build-hook.sh index c297bfffb1e2..ac025165410a 100644 --- a/pkgs/development/interpreters/python/hooks/pip-build-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pip-build-hook.sh @@ -31,7 +31,7 @@ pipShellHook() { echo "Finished executing pipShellHook" } -if [ -z "$dontUsePipBuild" ] && [ -z "$buildPhase" ]; then +if [ -z "${dontUsePipBuild-}" ] && [ -z "$buildPhase" ]; then echo "Using pipBuildPhase" buildPhase=pipBuildPhase fi diff --git a/pkgs/development/interpreters/python/hooks/pip-install-hook.sh b/pkgs/development/interpreters/python/hooks/pip-install-hook.sh index f528ec63cb8e..ca5aa2f983b2 100644 --- a/pkgs/development/interpreters/python/hooks/pip-install-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pip-install-hook.sh @@ -18,7 +18,7 @@ pipInstallPhase() { echo "Finished executing pipInstallPhase" } -if [ -z "$dontUsePipInstall" ] && [ -z "$installPhase" ]; then +if [ -z "${dontUsePipInstall-}" ] && [ -z "$installPhase" ]; then echo "Using pipInstallPhase" installPhase=pipInstallPhase fi diff --git a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh index 24510b9f9931..9065b69fc09c 100644 --- a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh @@ -43,7 +43,7 @@ function pytestCheckPhase() { echo "Finished executing pytestCheckPhase" } -if [ -z "$dontUsePytestCheck" ] && [ -z "$installCheckPhase" ]; then +if [ -z "${dontUsePytestCheck-}" ] && [ -z "$installCheckPhase" ]; then echo "Using pytestCheckPhase" preDistPhases+=" pytestCheckPhase" fi diff --git a/pkgs/development/interpreters/python/hooks/python-catch-conflicts-hook.sh b/pkgs/development/interpreters/python/hooks/python-catch-conflicts-hook.sh index e9065cf17934..374a2eddb407 100644 --- a/pkgs/development/interpreters/python/hooks/python-catch-conflicts-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-catch-conflicts-hook.sh @@ -5,6 +5,6 @@ pythonCatchConflictsPhase() { @pythonInterpreter@ @catchConflicts@ } -if [ -z "$dontUsePythonCatchConflicts" ]; then +if [ -z "${dontUsePythonCatchConflicts-}" ]; then preDistPhases+=" pythonCatchConflictsPhase" fi diff --git a/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh b/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh index 7e2b3f69d6dd..0fc55145a8eb 100644 --- a/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh @@ -10,7 +10,7 @@ pythonImportsCheckPhase () { fi } -if [ -z "$dontUsePythonImportsCheck" ]; then +if [ -z "${dontUsePythonImportsCheck-}" ]; then echo "Using pythonImportsCheckPhase" preDistPhases+=" pythonImportsCheckPhase" fi diff --git a/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh b/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh index 960de767be79..2add23f23165 100644 --- a/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh @@ -12,6 +12,6 @@ pythonRemoveBinBytecodePhase () { fi } -if [ -z "$dontUsePythonRemoveBinBytecode" ]; then +if [ -z "${dontUsePythonRemoveBinBytecode-}" ]; then preDistPhases+=" pythonRemoveBinBytecodePhase" fi diff --git a/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh b/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh index c99ef313c102..648f19efb363 100644 --- a/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh +++ b/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh @@ -36,12 +36,12 @@ setuptoolsShellHook() { echo "Finished executing setuptoolsShellHook" } -if [ -z "$dontUseSetuptoolsBuild" ] && [ -z "$buildPhase" ]; then +if [ -z "${dontUseSetuptoolsBuild-}" ] && [ -z "$buildPhase" ]; then echo "Using setuptoolsBuildPhase" buildPhase=setuptoolsBuildPhase fi -if [ -z "$dontUseSetuptoolsShellHook" ] && [ -z "$shellHook" ]; then +if [ -z "${dontUseSetuptoolsShellHook-}" ] && [ -z "$shellHook" ]; then echo "Using setuptoolsShellHook" shellHook=setuptoolsShellHook fi diff --git a/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh b/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh index 71bb036a91ad..5b07155ff4d6 100644 --- a/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh @@ -12,7 +12,7 @@ setuptoolsCheckPhase() { echo "Finished executing setuptoolsCheckPhase" } -if [ -z "$dontUseSetuptoolsCheck" ] && [ -z "$installCheckPhase" ]; then +if [ -z "${dontUseSetuptoolsCheck-}" ] && [ -z "$installCheckPhase" ]; then echo "Using setuptoolsCheckPhase" preDistPhases+=" setuptoolsCheckPhase" fi diff --git a/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh b/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh index 6dd0c5be4cb2..81efdb0d4110 100644 --- a/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh +++ b/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh @@ -12,7 +12,7 @@ wheelUnpackPhase(){ echo "Finished executing wheelUnpackPhase" } -if [ -z "$dontUseWheelUnpack" ] && [ -z "$unpackPhase" ]; then +if [ -z "${dontUseWheelUnpack-}" ] && [ -z "$unpackPhase" ]; then echo "Using wheelUnpackPhase" unpackPhase=wheelUnpackPhase fi diff --git a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh index c3373983e325..fc4a0be62826 100644 --- a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh @@ -31,6 +31,6 @@ qmakeConfigurePhase() { runHook postConfigure } -if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then +if [ -z "${dontUseQmakeConfigure-}" -a -z "$configurePhase" ]; then configurePhase=qmakeConfigurePhase fi diff --git a/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh index d2aadbd956a8..d9e5880289dc 100644 --- a/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh @@ -64,10 +64,10 @@ qtOwnPathsHook() { preFixupPhases+=" qtOwnPathsHook" -# Note: $qtWrapperArgs still gets defined even if $dontWrapQtApps is set. +# Note: $qtWrapperArgs still gets defined even if ${dontWrapQtApps-} is set. wrapQtAppsHook() { # skip this hook when requested - [ -z "$dontWrapQtApps" ] || return 0 + [ -z "${dontWrapQtApps-}" ] || return 0 # guard against running multiple times (e.g. due to propagation) [ -z "$wrapQtAppsHookHasRun" ] || return 0 diff --git a/pkgs/development/node-packages/node-env.nix b/pkgs/development/node-packages/node-env.nix index 670556bf271a..7cc212c41bd6 100644 --- a/pkgs/development/node-packages/node-env.nix +++ b/pkgs/development/node-packages/node-env.nix @@ -363,7 +363,7 @@ let npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild - if [ "$dontNpmInstall" != "1" ] + if [ "''${dontNpmInstall-}" != "1" ] then # NPM tries to download packages even when they already exist if npm-shrinkwrap is used. rm -f npm-shrinkwrap.json diff --git a/pkgs/development/python-modules/pythonnet/default.nix b/pkgs/development/python-modules/pythonnet/default.nix index 9bcbaf3e6f72..f916ec63b30b 100644 --- a/pkgs/development/python-modules/pythonnet/default.nix +++ b/pkgs/development/python-modules/pythonnet/default.nix @@ -43,8 +43,8 @@ buildPythonPackage rec { ''; preConfigure = '' - [ -z "$dontPlacateNuget" ] && placate-nuget.sh - [ -z "$dontPlacatePaket" ] && placate-paket.sh + [ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh + [ -z "''${dontPlacatePaket-}" ] && placate-paket.sh ''; nativeBuildInputs = [ diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index 7b92a586b54c..af38160a5fa2 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -99,7 +99,7 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // { runHook preUnpack if [[ -f $src && $src == *.gem ]]; then - if [[ -z "$dontBuild" ]]; then + if [[ -z "''${dontBuild-}" ]]; then # we won't know the name of the directory that RubyGems creates, # so we'll just use a glob to find it and move it over. gempkg="$src" diff --git a/pkgs/development/tools/ocaml/opam/opam-shebangs.patch b/pkgs/development/tools/ocaml/opam/opam-shebangs.patch index f74ac84ca6b2..13aa7a895708 100644 --- a/pkgs/development/tools/ocaml/opam/opam-shebangs.patch +++ b/pkgs/development/tools/ocaml/opam/opam-shebangs.patch @@ -64,7 +64,7 @@ index 00000000..3ea84e2d +header() { echo "$1"; } +stopNest() { true; } + -+fixupOutputHooks+=('if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then patchShebangs "$prefix"; fi') ++fixupOutputHooks+=('if [ -z "${dontPatchShebangs-}" -a -e "$prefix" ]; then patchShebangs "$prefix"; fi') + +patchShebangs() { + local dir="$1" diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 87fa9c8f08e2..d206910732c2 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -179,7 +179,7 @@ let '' else "") + (if isModular then '' mkdir -p $dev cp vmlinux $dev/ - if [ -z "$dontStrip" ]; then + if [ -z "''${dontStrip-}" ]; then installFlagsArray+=("INSTALL_MOD_STRIP=1") fi make modules_install $makeFlags "''${makeFlagsArray[@]}" \ diff --git a/pkgs/stdenv/cygwin/rebase-i686.sh b/pkgs/stdenv/cygwin/rebase-i686.sh index 091c9044d93f..6b8ec441ca7f 100644 --- a/pkgs/stdenv/cygwin/rebase-i686.sh +++ b/pkgs/stdenv/cygwin/rebase-i686.sh @@ -1,7 +1,7 @@ fixupOutputHooks+=(_cygwinFixAutoImageBase) _cygwinFixAutoImageBase() { - if [ "$dontRebase" == 1 ] || [ ! -d "$prefix" ]; then + if [ "${dontRebase-}" == 1 ] || [ ! -d "$prefix" ]; then return fi find "$prefix" -name "*.dll" -type f | while read DLL; do diff --git a/pkgs/stdenv/cygwin/rebase-x86_64.sh b/pkgs/stdenv/cygwin/rebase-x86_64.sh index 4c8f8ebd7eb2..6dccdc40c722 100644 --- a/pkgs/stdenv/cygwin/rebase-x86_64.sh +++ b/pkgs/stdenv/cygwin/rebase-x86_64.sh @@ -1,7 +1,7 @@ fixupOutputHooks+=(_cygwinFixAutoImageBase) _cygwinFixAutoImageBase() { - if [ "$dontRebase" == 1 ] || [ ! -d "$prefix" ]; then + if [ "${dontRebase-}" == 1 ] || [ ! -d "$prefix" ]; then return fi find "$prefix" -name "*.dll" -type f | while read DLL; do From 7eecf4f8fb288dcc4a32595036421bfcc38699e6 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 31 Oct 2019 17:57:33 +0000 Subject: [PATCH 07/13] find-xml-catalogues: Ensure XML_CATALOG_FILES is defined --- pkgs/build-support/setup-hooks/find-xml-catalogs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/setup-hooks/find-xml-catalogs.sh b/pkgs/build-support/setup-hooks/find-xml-catalogs.sh index 85364a61f612..f446a6f27fd9 100644 --- a/pkgs/build-support/setup-hooks/find-xml-catalogs.sh +++ b/pkgs/build-support/setup-hooks/find-xml-catalogs.sh @@ -11,12 +11,12 @@ addXMLCatalogs () { done } -if [ -z "$libxmlHookDone" ]; then +if [ -z "${libxmlHookDone-}" ]; then libxmlHookDone=1 # Set up XML_CATALOG_FILES. An empty initial value prevents # xmllint and xsltproc from looking in /etc/xml/catalog. - export XML_CATALOG_FILES + export XML_CATALOG_FILES='' if [ -z "$XML_CATALOG_FILES" ]; then XML_CATALOG_FILES=" "; fi addEnvHooks "$hostOffset" addXMLCatalogs fi From b7f4bda2827e4adc76dd30d6fd5257ed4f49b21d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 31 Oct 2019 17:59:18 +0000 Subject: [PATCH 08/13] treewide: `*Phase(s)?` variables are optional If these aren't defined, the stdenv defaults are used in the `*Phase` case, or no extra phases are done, in the `*Phases` case. --- .../interpreters/python/hooks/flit-build-hook.sh | 2 +- .../development/interpreters/python/hooks/pip-build-hook.sh | 2 +- .../interpreters/python/hooks/pip-install-hook.sh | 2 +- .../interpreters/python/hooks/pytest-check-hook.sh | 2 +- .../interpreters/python/hooks/setuptools-build-hook.sh | 4 ++-- .../interpreters/python/hooks/setuptools-check-hook.sh | 2 +- .../interpreters/python/hooks/wheel-unpack-hook.sh | 2 +- .../libraries/gtk/hooks/drop-icon-theme-cache.sh | 2 +- pkgs/development/libraries/qt-5/hooks/qmake-hook.sh | 2 +- pkgs/development/tools/build-managers/cmake/setup-hook.sh | 4 ++-- pkgs/development/tools/build-managers/gn/setup-hook.sh | 2 +- pkgs/development/tools/build-managers/meson/setup-hook.sh | 2 +- pkgs/development/tools/build-managers/ninja/setup-hook.sh | 6 +++--- pkgs/development/tools/build-managers/scons/setup-hook.sh | 6 +++--- pkgs/development/tools/misc/premake/setup-hook.sh | 2 +- pkgs/development/tools/xcbuild/setup-hook.sh | 2 +- pkgs/servers/x11/xorg/imake-setup-hook.sh | 2 +- pkgs/tools/misc/desktop-file-utils/setup-hook.sh | 2 +- 18 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pkgs/development/interpreters/python/hooks/flit-build-hook.sh b/pkgs/development/interpreters/python/hooks/flit-build-hook.sh index 23198bd711b8..45893aae00f4 100644 --- a/pkgs/development/interpreters/python/hooks/flit-build-hook.sh +++ b/pkgs/development/interpreters/python/hooks/flit-build-hook.sh @@ -9,7 +9,7 @@ flitBuildPhase () { echo "Finished executing flitBuildPhase" } -if [ -z "${dontUseFlitBuild-}" ] && [ -z "$buildPhase" ]; then +if [ -z "${dontUseFlitBuild-}" ] && [ -z "${buildPhase-}" ]; then echo "Using flitBuildPhase" buildPhase=flitBuildPhase fi diff --git a/pkgs/development/interpreters/python/hooks/pip-build-hook.sh b/pkgs/development/interpreters/python/hooks/pip-build-hook.sh index ac025165410a..a58c01ce808c 100644 --- a/pkgs/development/interpreters/python/hooks/pip-build-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pip-build-hook.sh @@ -31,7 +31,7 @@ pipShellHook() { echo "Finished executing pipShellHook" } -if [ -z "${dontUsePipBuild-}" ] && [ -z "$buildPhase" ]; then +if [ -z "${dontUsePipBuild-}" ] && [ -z "${buildPhase-}" ]; then echo "Using pipBuildPhase" buildPhase=pipBuildPhase fi diff --git a/pkgs/development/interpreters/python/hooks/pip-install-hook.sh b/pkgs/development/interpreters/python/hooks/pip-install-hook.sh index ca5aa2f983b2..4eefe22d3f28 100644 --- a/pkgs/development/interpreters/python/hooks/pip-install-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pip-install-hook.sh @@ -18,7 +18,7 @@ pipInstallPhase() { echo "Finished executing pipInstallPhase" } -if [ -z "${dontUsePipInstall-}" ] && [ -z "$installPhase" ]; then +if [ -z "${dontUsePipInstall-}" ] && [ -z "${installPhase-}" ]; then echo "Using pipInstallPhase" installPhase=pipInstallPhase fi diff --git a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh index 9065b69fc09c..18f05b6d218c 100644 --- a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh @@ -43,7 +43,7 @@ function pytestCheckPhase() { echo "Finished executing pytestCheckPhase" } -if [ -z "${dontUsePytestCheck-}" ] && [ -z "$installCheckPhase" ]; then +if [ -z "${dontUsePytestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then echo "Using pytestCheckPhase" preDistPhases+=" pytestCheckPhase" fi diff --git a/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh b/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh index 648f19efb363..ebda9e8b5230 100644 --- a/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh +++ b/pkgs/development/interpreters/python/hooks/setuptools-build-hook.sh @@ -36,12 +36,12 @@ setuptoolsShellHook() { echo "Finished executing setuptoolsShellHook" } -if [ -z "${dontUseSetuptoolsBuild-}" ] && [ -z "$buildPhase" ]; then +if [ -z "${dontUseSetuptoolsBuild-}" ] && [ -z "${buildPhase-}" ]; then echo "Using setuptoolsBuildPhase" buildPhase=setuptoolsBuildPhase fi -if [ -z "${dontUseSetuptoolsShellHook-}" ] && [ -z "$shellHook" ]; then +if [ -z "${dontUseSetuptoolsShellHook-}" ] && [ -z "${shellHook-}" ]; then echo "Using setuptoolsShellHook" shellHook=setuptoolsShellHook fi diff --git a/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh b/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh index 5b07155ff4d6..88b7b11931b0 100644 --- a/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/setuptools-check-hook.sh @@ -12,7 +12,7 @@ setuptoolsCheckPhase() { echo "Finished executing setuptoolsCheckPhase" } -if [ -z "${dontUseSetuptoolsCheck-}" ] && [ -z "$installCheckPhase" ]; then +if [ -z "${dontUseSetuptoolsCheck-}" ] && [ -z "${installCheckPhase-}" ]; then echo "Using setuptoolsCheckPhase" preDistPhases+=" setuptoolsCheckPhase" fi diff --git a/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh b/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh index 81efdb0d4110..fca808a933ba 100644 --- a/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh +++ b/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh @@ -12,7 +12,7 @@ wheelUnpackPhase(){ echo "Finished executing wheelUnpackPhase" } -if [ -z "${dontUseWheelUnpack-}" ] && [ -z "$unpackPhase" ]; then +if [ -z "${dontUseWheelUnpack-}" ] && [ -z "${unpackPhase-}" ]; then echo "Using wheelUnpackPhase" unpackPhase=wheelUnpackPhase fi diff --git a/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh b/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh index 8f2cb8a334ae..f28a856c4f50 100644 --- a/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh +++ b/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh @@ -16,4 +16,4 @@ dropIconThemeCache() { fi } -preFixupPhases="$preFixupPhases dropIconThemeCache" +preFixupPhases="${preFixupPhases-} dropIconThemeCache" diff --git a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh index fc4a0be62826..b785a779c8bc 100644 --- a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh @@ -31,6 +31,6 @@ qmakeConfigurePhase() { runHook postConfigure } -if [ -z "${dontUseQmakeConfigure-}" -a -z "$configurePhase" ]; then +if [ -z "${dontUseQmakeConfigure-}" -a -z "${configurePhase-}" ]; then configurePhase=qmakeConfigurePhase fi diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh index dbd40bf71242..8bd54d3bc13d 100755 --- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh +++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh @@ -99,7 +99,7 @@ cmakeConfigurePhase() { cmakeFlags="-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON $cmakeFlags" cmakeFlags="-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON $cmakeFlags" - if [ "$buildPhase" = ninjaBuildPhase ]; then + if [ "${buildPhase-}" = ninjaBuildPhase ]; then cmakeFlags="-GNinja $cmakeFlags" fi @@ -115,7 +115,7 @@ cmakeConfigurePhase() { runHook postConfigure } -if [ -z "${dontUseCmakeConfigure-}" -a -z "$configurePhase" ]; then +if [ -z "${dontUseCmakeConfigure-}" -a -z "${configurePhase-}" ]; then setOutputFlags= configurePhase=cmakeConfigurePhase fi diff --git a/pkgs/development/tools/build-managers/gn/setup-hook.sh b/pkgs/development/tools/build-managers/gn/setup-hook.sh index 4f772d2369ba..850f18948cad 100644 --- a/pkgs/development/tools/build-managers/gn/setup-hook.sh +++ b/pkgs/development/tools/build-managers/gn/setup-hook.sh @@ -9,6 +9,6 @@ gnConfigurePhase() { runHook postConfigure } -if [ -z "${dontUseGnConfigure-}" -a -z "$configurePhase" ]; then +if [ -z "${dontUseGnConfigure-}" -a -z "${configurePhase-}" ]; then configurePhase=gnConfigurePhase fi diff --git a/pkgs/development/tools/build-managers/meson/setup-hook.sh b/pkgs/development/tools/build-managers/meson/setup-hook.sh index bfb40303cd85..8d76ecdaf32b 100644 --- a/pkgs/development/tools/build-managers/meson/setup-hook.sh +++ b/pkgs/development/tools/build-managers/meson/setup-hook.sh @@ -36,7 +36,7 @@ mesonConfigurePhase() { runHook postConfigure } -if [ -z "${dontUseMesonConfigure-}" -a -z "$configurePhase" ]; then +if [ -z "${dontUseMesonConfigure-}" -a -z "${configurePhase-}" ]; then setOutputFlags= configurePhase=mesonConfigurePhase fi diff --git a/pkgs/development/tools/build-managers/ninja/setup-hook.sh b/pkgs/development/tools/build-managers/ninja/setup-hook.sh index 76de25aaabf1..7d8087ad1342 100644 --- a/pkgs/development/tools/build-managers/ninja/setup-hook.sh +++ b/pkgs/development/tools/build-managers/ninja/setup-hook.sh @@ -19,7 +19,7 @@ ninjaBuildPhase() { runHook postBuild } -if [ -z "${dontUseNinjaBuild-}" -a -z "$buildPhase" ]; then +if [ -z "${dontUseNinjaBuild-}" -a -z "${buildPhase-}" ]; then buildPhase=ninjaBuildPhase fi @@ -38,7 +38,7 @@ ninjaInstallPhase() { runHook postInstall } -if [ -z "${dontUseNinjaInstall-}" -a -z "$installPhase" ]; then +if [ -z "${dontUseNinjaInstall-}" -a -z "${installPhase-}" ]; then installPhase=ninjaInstallPhase fi @@ -73,6 +73,6 @@ ninjaCheckPhase() { runHook postCheck } -if [ -z "${dontUseNinjaCheck-}" -a -z "$checkPhase" ]; then +if [ -z "${dontUseNinjaCheck-}" -a -z "${checkPhase-}" ]; then checkPhase=ninjaCheckPhase fi diff --git a/pkgs/development/tools/build-managers/scons/setup-hook.sh b/pkgs/development/tools/build-managers/scons/setup-hook.sh index 428852ac574a..0b908f68286b 100644 --- a/pkgs/development/tools/build-managers/scons/setup-hook.sh +++ b/pkgs/development/tools/build-managers/scons/setup-hook.sh @@ -71,14 +71,14 @@ sconsCheckPhase() { runHook postCheck } -if [ -z "$buildPhase" ]; then +if [ -z "${buildPhase-}" ]; then buildPhase=sconsBuildPhase fi -if [ -z "${dontUseSconsInstall-}" -a -z "$installPhase" ]; then +if [ -z "${dontUseSconsInstall-}" -a -z "${installPhase-}" ]; then installPhase=sconsInstallPhase fi -if [ -z "$checkPhase" ]; then +if [ -z "${checkPhase-}" ]; then checkPhase=sconsCheckPhase fi diff --git a/pkgs/development/tools/misc/premake/setup-hook.sh b/pkgs/development/tools/misc/premake/setup-hook.sh index ba06ea2c7617..6e65e9e8c73f 100644 --- a/pkgs/development/tools/misc/premake/setup-hook.sh +++ b/pkgs/development/tools/misc/premake/setup-hook.sh @@ -14,6 +14,6 @@ premakeConfigurePhase() { runHook postConfigure } -if [ -z "$configurePhase" ]; then +if [ -z "${configurePhase-}" ]; then configurePhase=premakeConfigurePhase fi diff --git a/pkgs/development/tools/xcbuild/setup-hook.sh b/pkgs/development/tools/xcbuild/setup-hook.sh index 9dc03a61f62e..f4b5abf2d8d3 100644 --- a/pkgs/development/tools/xcbuild/setup-hook.sh +++ b/pkgs/development/tools/xcbuild/setup-hook.sh @@ -20,7 +20,7 @@ xcbuildInstallPhase () { } buildPhase=xcbuildBuildPhase -if [ -z "$installPhase" ]; then +if [ -z "${installPhase-}" ]; then installPhase=xcbuildInstallPhase fi diff --git a/pkgs/servers/x11/xorg/imake-setup-hook.sh b/pkgs/servers/x11/xorg/imake-setup-hook.sh index e743093af0ec..351ffab34d0f 100644 --- a/pkgs/servers/x11/xorg/imake-setup-hook.sh +++ b/pkgs/servers/x11/xorg/imake-setup-hook.sh @@ -14,6 +14,6 @@ imakeConfigurePhase() { runHook postConfigure } -if [ -z "${dontUseImakeConfigure-}" -a -z "$configurePhase" ]; then +if [ -z "${dontUseImakeConfigure-}" -a -z "${configurePhase-}" ]; then configurePhase=imakeConfigurePhase fi diff --git a/pkgs/tools/misc/desktop-file-utils/setup-hook.sh b/pkgs/tools/misc/desktop-file-utils/setup-hook.sh index 004d635cff0e..728070e34581 100644 --- a/pkgs/tools/misc/desktop-file-utils/setup-hook.sh +++ b/pkgs/tools/misc/desktop-file-utils/setup-hook.sh @@ -3,4 +3,4 @@ mimeinfoPreFixupPhase() { rm -f $out/share/applications/mimeinfo.cache } -preFixupPhases="$preFixupPhases mimeinfoPreFixupPhase" +preFixupPhases="${preFixupPhases-} mimeinfoPreFixupPhase" From 45e5e68c5352768b877c52e79536b4e95e3fb32e Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 1 Nov 2019 11:09:02 -0400 Subject: [PATCH 09/13] rust: Allow IN_NIX_SHELL to be undefined --- pkgs/development/compilers/rust/setup-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/rust/setup-hook.sh b/pkgs/development/compilers/rust/setup-hook.sh index 7078ec7060b9..5d4eb642fec0 100644 --- a/pkgs/development/compilers/rust/setup-hook.sh +++ b/pkgs/development/compilers/rust/setup-hook.sh @@ -1,4 +1,4 @@ # Fix 'failed to open: /homeless-shelter/.cargo/.package-cache' in rust 1.36. -if [[ -z $IN_NIX_SHELL && -z $CARGO_HOME ]]; then +if [[ -z ${IN_NIX_SHELL-} && -z ${CARGO_HOME-} ]]; then export CARGO_HOME=$TMPDIR fi From 373236ccfffe7053b1503a8992ddff7ebae3ed6f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 1 Nov 2019 15:30:09 -0400 Subject: [PATCH 10/13] treewide: JAVA_HOME may not always be defined --- .../compilers/adoptopenjdk-bin/jdk-darwin-base.nix | 2 +- .../development/compilers/adoptopenjdk-bin/jdk-linux-base.nix | 2 +- pkgs/development/compilers/graalvm/default.nix | 2 +- pkgs/development/compilers/graalvm/enterprise-edition.nix | 2 +- pkgs/development/compilers/openjdk/11.nix | 2 +- pkgs/development/compilers/openjdk/8.nix | 2 +- pkgs/development/compilers/openjdk/darwin/11.nix | 2 +- pkgs/development/compilers/openjdk/darwin/8.nix | 2 +- pkgs/development/compilers/openjdk/darwin/default.nix | 2 +- pkgs/development/compilers/openjdk/default.nix | 2 +- pkgs/development/compilers/oraclejdk/jdk-linux-base.nix | 2 +- pkgs/development/compilers/zulu/8.nix | 2 +- pkgs/development/compilers/zulu/default.nix | 2 +- pkgs/development/tools/build-managers/apache-ant/1.9.nix | 4 ++-- pkgs/development/tools/build-managers/apache-ant/default.nix | 4 ++-- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix b/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix index 03857627952d..3b9cb752b9b8 100644 --- a/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix +++ b/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix @@ -37,7 +37,7 @@ let cpuName = stdenv.hostPlatform.parsed.cpu.name; # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix index 509050209fb2..fe38f2b21633 100644 --- a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix +++ b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix @@ -54,7 +54,7 @@ let result = stdenv.mkDerivation rec { # Set JAVA_HOME automatically. cat <> "$out/nix-support/setup-hook" - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/graalvm/default.nix b/pkgs/development/compilers/graalvm/default.nix index 61e3b6c16aee..5108ce185449 100644 --- a/pkgs/development/compilers/graalvm/default.nix +++ b/pkgs/development/compilers/graalvm/default.nix @@ -270,7 +270,7 @@ in rec { # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat < $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; postFixup = openjdk.postFixup or null; diff --git a/pkgs/development/compilers/graalvm/enterprise-edition.nix b/pkgs/development/compilers/graalvm/enterprise-edition.nix index 84cb38aa8d11..e180455cb7cd 100644 --- a/pkgs/development/compilers/graalvm/enterprise-edition.nix +++ b/pkgs/development/compilers/graalvm/enterprise-edition.nix @@ -72,7 +72,7 @@ let # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat < $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/11.nix b/pkgs/development/compilers/openjdk/11.nix index 57911f2d58e6..e365b9b28b35 100644 --- a/pkgs/development/compilers/openjdk/11.nix +++ b/pkgs/development/compilers/openjdk/11.nix @@ -106,7 +106,7 @@ let # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat < $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/8.nix b/pkgs/development/compilers/openjdk/8.nix index 1a5848cd1a68..ff3d03321e21 100644 --- a/pkgs/development/compilers/openjdk/8.nix +++ b/pkgs/development/compilers/openjdk/8.nix @@ -231,7 +231,7 @@ let # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat < $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/darwin/11.nix b/pkgs/development/compilers/openjdk/darwin/11.nix index 4c808302b4fa..0b659b95aa8b 100644 --- a/pkgs/development/compilers/openjdk/darwin/11.nix +++ b/pkgs/development/compilers/openjdk/darwin/11.nix @@ -44,7 +44,7 @@ let # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix index 045901b1bae6..f804046b83dd 100644 --- a/pkgs/development/compilers/openjdk/darwin/8.nix +++ b/pkgs/development/compilers/openjdk/darwin/8.nix @@ -44,7 +44,7 @@ let # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/darwin/default.nix b/pkgs/development/compilers/openjdk/darwin/default.nix index 58e4ba990149..c954a8e2cf85 100644 --- a/pkgs/development/compilers/openjdk/darwin/default.nix +++ b/pkgs/development/compilers/openjdk/darwin/default.nix @@ -44,7 +44,7 @@ let # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/default.nix b/pkgs/development/compilers/openjdk/default.nix index 094bd57e6e98..03121daf961f 100644 --- a/pkgs/development/compilers/openjdk/default.nix +++ b/pkgs/development/compilers/openjdk/default.nix @@ -114,7 +114,7 @@ let # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat < $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi EOF ''; diff --git a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix index e80d81dc5a00..2f1e827a26a5 100644 --- a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix +++ b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix @@ -156,7 +156,7 @@ let result = stdenv.mkDerivation rec { # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/zulu/8.nix b/pkgs/development/compilers/zulu/8.nix index d4caabc6cb83..d05ec1a682aa 100644 --- a/pkgs/development/compilers/zulu/8.nix +++ b/pkgs/development/compilers/zulu/8.nix @@ -58,7 +58,7 @@ in stdenv.mkDerivation { # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/zulu/default.nix b/pkgs/development/compilers/zulu/default.nix index 5f345c87355f..5fe2473bac6d 100644 --- a/pkgs/development/compilers/zulu/default.nix +++ b/pkgs/development/compilers/zulu/default.nix @@ -55,7 +55,7 @@ in stdenv.mkDerivation { # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/tools/build-managers/apache-ant/1.9.nix b/pkgs/development/tools/build-managers/apache-ant/1.9.nix index 0a86aaeb6ca0..661e16d83e82 100644 --- a/pkgs/development/tools/build-managers/apache-ant/1.9.nix +++ b/pkgs/development/tools/build-managers/apache-ant/1.9.nix @@ -46,14 +46,14 @@ stdenv.mkDerivation { # JRE by looking for java. The latter allows just the JRE to be # used with (say) ECJ as the compiler. Finally, allow the GNU # JVM. - if [ -z "\$JAVA_HOME" ]; then + if [ -z "\''${JAVA_HOME-}" ]; then for i in javac java gij; do if p="\$(type -p \$i)"; then export JAVA_HOME="\$(${coreutils}/bin/dirname \$(${coreutils}/bin/dirname \$(${coreutils}/bin/readlink -f \$p)))" break fi done - if [ -z "\$JAVA_HOME" ]; then + if [ -z "\''${JAVA_HOME-}" ]; then echo "\$0: cannot find the JDK or JRE" >&2 exit 1 fi diff --git a/pkgs/development/tools/build-managers/apache-ant/default.nix b/pkgs/development/tools/build-managers/apache-ant/default.nix index 8d1e09eeb338..28e86e291755 100644 --- a/pkgs/development/tools/build-managers/apache-ant/default.nix +++ b/pkgs/development/tools/build-managers/apache-ant/default.nix @@ -46,14 +46,14 @@ stdenv.mkDerivation { # JRE by looking for java. The latter allows just the JRE to be # used with (say) ECJ as the compiler. Finally, allow the GNU # JVM. - if [ -z "\$JAVA_HOME" ]; then + if [ -z "\''${JAVA_HOME-}" ]; then for i in javac java gij; do if p="\$(type -p \$i)"; then export JAVA_HOME="\$(${coreutils}/bin/dirname \$(${coreutils}/bin/dirname \$(${coreutils}/bin/readlink -f \$p)))" break fi done - if [ -z "\$JAVA_HOME" ]; then + if [ -z "\''${JAVA_HOME-}" ]; then echo "\$0: cannot find the JDK or JRE" >&2 exit 1 fi From 9df7efe0c6bf936240d2cc83b57331c1c565ad01 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 29 Oct 2019 19:43:34 -0400 Subject: [PATCH 11/13] stdenv: Don't stop `set -u`-ing Before, we very carefully unapplied and reapplied `set -u` so the rest of Nixpkgs could continue to not fail on undefined variables. Let's rip off the band-aid. --- nixos/doc/manual/release-notes/rl-2003.xml | 7 ++++ pkgs/stdenv/generic/setup.sh | 45 ++-------------------- 2 files changed, 10 insertions(+), 42 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2003.xml b/nixos/doc/manual/release-notes/rl-2003.xml index f001a18b1c1f..3e6a5d6d6fa5 100644 --- a/nixos/doc/manual/release-notes/rl-2003.xml +++ b/nixos/doc/manual/release-notes/rl-2003.xml @@ -125,6 +125,13 @@ networking.interfaces.<name>.… options. + + + The stdenv now runs all bash with set -u, to catch the use of undefined variables. + Before, it itself used set -u but was careful to unset it so other packages' code ran as before. + Now, all bash code is held to the same high standard, and the rather complex stateful manipulation of the options can be discarded. + + diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 0962a1ec2fc0..c381f6e106ec 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -17,10 +17,6 @@ fi # code). The hooks for are the shell function or variable # , and the values of the shell array ‘Hooks’. runHook() { - local oldOpts="-u" - shopt -qo nounset || oldOpts="+u" - set -u # May be called from elsewhere, so do `set -u`. - local hookName="$1" shift local hooksSlice="${hookName%Hook}Hooks[@]" @@ -30,10 +26,8 @@ runHook() { # undefined. for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do _eval "$hook" "$@" - set -u # To balance `_eval` done - set "$oldOpts" return 0 } @@ -41,10 +35,6 @@ runHook() { # Run all hooks with the specified name, until one succeeds (returns a # zero exit code). If none succeed, return a non-zero exit code. runOneHook() { - local oldOpts="-u" - shopt -qo nounset || oldOpts="+u" - set -u # May be called from elsewhere, so do `set -u`. - local hookName="$1" shift local hooksSlice="${hookName%Hook}Hooks[@]" @@ -56,10 +46,8 @@ runOneHook() { ret=0 break fi - set -u # To balance `_eval` done - set "$oldOpts" return "$ret" } @@ -70,17 +58,13 @@ runOneHook() { # environment variables) and from shell scripts (as functions). If you # want to allow multiple hooks, use runHook instead. _callImplicitHook() { - set -u local def="$1" local hookName="$2" if declare -F "$hookName" > /dev/null; then - set +u "$hookName" elif type -p "$hookName" > /dev/null; then - set +u source "$hookName" elif [ -n "${!hookName:-}" ]; then - set +u eval "${!hookName}" else return "$def" @@ -96,13 +80,10 @@ _callImplicitHook() { # command can take them _eval() { if declare -F "$1" > /dev/null 2>&1; then - set +u "$@" # including args else - set +u eval "$1" fi - # `run*Hook` reenables `set -u` } @@ -190,12 +171,12 @@ addToSearchPath() { # so it is defined here but tried after the hook. _addRpathPrefix() { if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then - export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS" + export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}" if [ -n "${NIX_LIB64_IN_SELF_RPATH:-}" ]; then - export NIX_LDFLAGS="-rpath $1/lib64 $NIX_LDFLAGS" + export NIX_LDFLAGS="-rpath $1/lib64 ${NIX_LDFLAGS-}" fi if [ -n "${NIX_LIB32_IN_SELF_RPATH:-}" ]; then - export NIX_LDFLAGS="-rpath $1/lib32 $NIX_LDFLAGS" + export NIX_LDFLAGS="-rpath $1/lib32 ${NIX_LDFLAGS-}" fi fi } @@ -489,11 +470,7 @@ activatePackage() { (( "$hostOffset" <= "$targetOffset" )) || exit -1 if [ -f "$pkg" ]; then - local oldOpts="-u" - shopt -qo nounset || oldOpts="+u" - set +u source "$pkg" - set "$oldOpts" fi # Only dependencies whose host platform is guaranteed to match the @@ -512,11 +489,7 @@ activatePackage() { fi if [[ -f "$pkg/nix-support/setup-hook" ]]; then - local oldOpts="-u" - shopt -qo nounset || oldOpts="+u" - set +u source "$pkg/nix-support/setup-hook" - set "$oldOpts" fi } @@ -1264,19 +1237,11 @@ showPhaseHeader() { genericBuild() { if [ -f "${buildCommandPath:-}" ]; then - local oldOpts="-u" - shopt -qo nounset || oldOpts="+u" - set +u source "$buildCommandPath" - set "$oldOpts" return fi if [ -n "${buildCommand:-}" ]; then - local oldOpts="-u" - shopt -qo nounset || oldOpts="+u" - set +u eval "$buildCommand" - set "$oldOpts" return fi @@ -1306,11 +1271,7 @@ genericBuild() { # Evaluate the variable named $curPhase if it exists, otherwise the # function named $curPhase. - local oldOpts="-u" - shopt -qo nounset || oldOpts="+u" - set +u eval "${!curPhase:-$curPhase}" - set "$oldOpts" if [ "$curPhase" = unpackPhase ]; then cd "${sourceRoot:-.}" From 9b274e2962d9d133930a4fd03b2691fc4f6f56cd Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 2 Nov 2019 19:22:36 -0400 Subject: [PATCH 12/13] qtbase-setup-hook: `postPhases` may be undefined My earlier sed missed this because it already had `{..}`. --- pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index 836e154148be..9f2a9f06f1ab 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -62,5 +62,5 @@ postPatchMkspecs() { fi } if [ -z "${dontPatchMkspecs-}" ]; then - postPhases="${postPhases}${postPhases:+ }postPatchMkspecs" + postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs" fi From c5cf0099967e0f5011b9188d56de22c376465b88 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 4 Nov 2019 19:51:04 -0500 Subject: [PATCH 13/13] multiple-outputs setup hook: Remove accidentally added tab I don't want to just rebase this away because the original commit is also in #72074. --- pkgs/build-support/setup-hooks/multiple-outputs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/setup-hooks/multiple-outputs.sh b/pkgs/build-support/setup-hooks/multiple-outputs.sh index 32d4e065875b..2e95495c96fd 100644 --- a/pkgs/build-support/setup-hooks/multiple-outputs.sh +++ b/pkgs/build-support/setup-hooks/multiple-outputs.sh @@ -9,7 +9,7 @@ _assignFirst() { local varName="$1" local REMOVE=REMOVE # slightly hacky - we allow REMOVE (i.e. not a variable name) shift - while (( $# )); do + while (( $# )); do if [ -n "${!1-}" ]; then eval "${varName}"="$1"; return; fi shift done