From 21c0129841005c2887037d3e2468944cd92b977e Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Tue, 3 Sep 2024 04:14:28 +0800 Subject: [PATCH 1/6] treewide: handle prePhases __structuredAttrs-agnostically Always specify the prePhases attribute as a list instead of a string. Append elements to the prePhases Bash variable using appendToVar instead of string or Bash array concatenation. --- pkgs/applications/graphics/gimp/plugins/default.nix | 4 ++-- pkgs/build-support/release/debian-build.nix | 2 +- pkgs/build-support/setup-hooks/keep-build-tree.sh | 2 +- pkgs/build-support/setup-hooks/move-build-tree.sh | 2 +- pkgs/by-name/ha/hare/setup-hook.sh | 2 +- pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh | 2 +- pkgs/development/libraries/qt-5/hooks/qmake-hook.sh | 2 +- pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh | 2 +- pkgs/development/libraries/qt-6/hooks/qmake-hook.sh | 2 +- pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/applications/graphics/gimp/plugins/default.nix b/pkgs/applications/graphics/gimp/plugins/default.nix index 667a1d505751..5280a1ae719e 100644 --- a/pkgs/applications/graphics/gimp/plugins/default.nix +++ b/pkgs/applications/graphics/gimp/plugins/default.nix @@ -17,7 +17,7 @@ let pluginDerivation = attrs: let name = attrs.name or "${attrs.pname}-${attrs.version}"; in stdenv.mkDerivation ({ - prePhases = "extraLib"; + prePhases = [ "extraLib" ]; extraLib = '' installScripts(){ mkdir -p $out/${gimp.targetScriptDir}/${name}; @@ -54,7 +54,7 @@ let }); scriptDerivation = {src, ...}@attrs : pluginDerivation ({ - prePhases = "extraLib"; + prePhases = [ "extraLib" ]; dontUnpack = true; installPhase = '' runHook preInstall diff --git a/pkgs/build-support/release/debian-build.nix b/pkgs/build-support/release/debian-build.nix index ab84a504b54c..e73b39c4e6b6 100644 --- a/pkgs/build-support/release/debian-build.nix +++ b/pkgs/build-support/release/debian-build.nix @@ -18,7 +18,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation ( prefix = "/usr"; - prePhases = "installExtraDebsPhase sysInfoPhase"; + prePhases = [ "installExtraDebsPhase" "sysInfoPhase" ]; } // removeAttrs args ["vmTools" "lib"] // diff --git a/pkgs/build-support/setup-hooks/keep-build-tree.sh b/pkgs/build-support/setup-hooks/keep-build-tree.sh index 754900bfc337..653149bdf26f 100644 --- a/pkgs/build-support/setup-hooks/keep-build-tree.sh +++ b/pkgs/build-support/setup-hooks/keep-build-tree.sh @@ -1,4 +1,4 @@ -prePhases+=" moveBuildDir" +appendToVar prePhases moveBuildDir moveBuildDir() { mkdir -p $out/.build diff --git a/pkgs/build-support/setup-hooks/move-build-tree.sh b/pkgs/build-support/setup-hooks/move-build-tree.sh index 2718070f3933..625f87965f39 100644 --- a/pkgs/build-support/setup-hooks/move-build-tree.sh +++ b/pkgs/build-support/setup-hooks/move-build-tree.sh @@ -1,4 +1,4 @@ -prePhases+=" moveBuildDir" +appendToVar prePhases moveBuildDir moveBuildDir() { mkdir -p $out/.build diff --git a/pkgs/by-name/ha/hare/setup-hook.sh b/pkgs/by-name/ha/hare/setup-hook.sh index 3a427fd70328..388ed9bcf25f 100644 --- a/pkgs/by-name/ha/hare/setup-hook.sh +++ b/pkgs/by-name/ha/hare/setup-hook.sh @@ -18,7 +18,7 @@ echoCmd "HAREPATH" "$HAREPATH" echoCmd "hare" "$(command -v hare)" echoCmd "hare-native" "$(command -v hare-native)" ' -prePhases+=("hareSetStdlibPhase" "hareInfoPhase") +appendToVar prePhases hareSetStdlibPhase hareInfoPhase readonly hare_unconditional_flags="@hare_unconditional_flags@" case "${hareBuildType:-"release"}" in diff --git a/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh b/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh index cac55cb56017..512070df83fa 100644 --- a/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh +++ b/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh @@ -73,6 +73,6 @@ configureNuget() { } if [[ -z ${dontConfigureNuget-} ]]; then - prePhases+=(createNugetDirs) + appendToVar prePhases createNugetDirs preConfigurePhases+=(configureNuget) fi diff --git a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh index f52de4e51df2..855efb5e6c0f 100644 --- a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh @@ -20,7 +20,7 @@ qmakePrePhase() { # do the stripping ourselves (needed for separateDebugInfo) prependToVar qmakeFlags "CONFIG+=nostrip" } -prePhases+=" qmakePrePhase" +appendToVar prePhases qmakePrePhase qmakeConfigurePhase() { runHook preConfigure 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 1b57d676e1fc..8f1fe0e6c6ff 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -107,6 +107,6 @@ qtPreHook() { exit 1 fi } -prePhases+=" qtPreHook" +appendToVar prePhases qtPreHook fi diff --git a/pkgs/development/libraries/qt-6/hooks/qmake-hook.sh b/pkgs/development/libraries/qt-6/hooks/qmake-hook.sh index 84b2fb153d9f..1f696be3e738 100644 --- a/pkgs/development/libraries/qt-6/hooks/qmake-hook.sh +++ b/pkgs/development/libraries/qt-6/hooks/qmake-hook.sh @@ -13,7 +13,7 @@ qmakePrePhase() { "NIX_OUTPUT_QML=${!outputBin}/${qtQmlPrefix:?}" \ "NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?}" } -prePhases+=" qmakePrePhase" +appendToVar prePhases qmakePrePhase qmakeConfigurePhase() { runHook preConfigure diff --git a/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh index 5006d6b65530..15a824f1cb45 100644 --- a/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh @@ -81,7 +81,7 @@ else # Only set up Qt once. exit 1 fi } - prePhases+=" qtPreHook" + appendToVar prePhases qtPreHook addQtModulePrefix() { addToSearchPath QT_ADDITIONAL_PACKAGES_PREFIX_PATH $1 From 5d42a8b38c1ae022307a9eed02d655720bca7481 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Tue, 3 Sep 2024 04:14:28 +0800 Subject: [PATCH 2/6] treewide: handle preConfigurePhases __structuredAttrs-agnostically Always specify the preConfigurePhases attribute as a list instead of a string. Append elements to the preConfigurePhases Bash variable using appendToVar instead of string or Bash array concatenation. --- pkgs/build-support/coq/default.nix | 2 +- pkgs/build-support/release/source-tarball.nix | 2 +- pkgs/build-support/setup-hooks/autoreconf.sh | 2 +- .../setup-hooks/update-autotools-gnu-config-scripts.sh | 2 +- pkgs/desktops/xfce/core/xfce4-dev-tools/setup-hook.sh | 2 +- pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh | 2 +- pkgs/development/libraries/liquidfun/default.nix | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/build-support/coq/default.nix b/pkgs/build-support/coq/default.nix index e55e22215daa..cafd2421f21d 100644 --- a/pkgs/build-support/coq/default.nix +++ b/pkgs/build-support/coq/default.nix @@ -146,7 +146,7 @@ stdenv.mkDerivation (removeAttrs ({ }) // (optionalAttrs (args?useMelquiondRemake) rec { COQUSERCONTRIB = "$out/lib/coq/${coq.coq-version}/user-contrib"; - preConfigurePhases = "autoconf"; + preConfigurePhases = [ "autoconf" ]; configureFlags = [ "--libdir=${COQUSERCONTRIB}/${useMelquiondRemake.logpath or ""}" ]; buildPhase = "./remake -j$NIX_BUILD_CORES"; installPhase = "./remake install"; diff --git a/pkgs/build-support/release/source-tarball.nix b/pkgs/build-support/release/source-tarball.nix index fbc8bc6b258b..3c88ca980ba0 100644 --- a/pkgs/build-support/release/source-tarball.nix +++ b/pkgs/build-support/release/source-tarball.nix @@ -31,7 +31,7 @@ stdenv.mkDerivation ( showBuildStats = true; - preConfigurePhases = "autoconfPhase"; + preConfigurePhases = [ "autoconfPhase" ]; postPhases = "finalPhase"; # Autoconfiscate the sources. diff --git a/pkgs/build-support/setup-hooks/autoreconf.sh b/pkgs/build-support/setup-hooks/autoreconf.sh index bb168aad4c51..3d12a17b78c1 100644 --- a/pkgs/build-support/setup-hooks/autoreconf.sh +++ b/pkgs/build-support/setup-hooks/autoreconf.sh @@ -1,4 +1,4 @@ -preConfigurePhases="${preConfigurePhases:-} autoreconfPhase" +appendToVar preConfigurePhases autoreconfPhase autoreconfPhase() { runHook preAutoreconf 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 ebd3afa05d94..0c5e1a81c7af 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,4 +1,4 @@ -preConfigurePhases+=" updateAutotoolsGnuConfigScriptsPhase" +appendToVar preConfigurePhases updateAutotoolsGnuConfigScriptsPhase updateAutotoolsGnuConfigScriptsPhase() { if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then return; fi diff --git a/pkgs/desktops/xfce/core/xfce4-dev-tools/setup-hook.sh b/pkgs/desktops/xfce/core/xfce4-dev-tools/setup-hook.sh index 05ddc6a172ff..57a7a6c8995a 100644 --- a/pkgs/desktops/xfce/core/xfce4-dev-tools/setup-hook.sh +++ b/pkgs/desktops/xfce/core/xfce4-dev-tools/setup-hook.sh @@ -10,5 +10,5 @@ xdtAutogenPhase() { } if [ -z "${dontUseXdtAutogenPhase-}" ]; then - preConfigurePhases+=(xdtAutogenPhase) + appendToVar preConfigurePhases xdtAutogenPhase fi diff --git a/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh b/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh index 512070df83fa..d635d1670336 100644 --- a/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh +++ b/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh @@ -74,5 +74,5 @@ configureNuget() { if [[ -z ${dontConfigureNuget-} ]]; then appendToVar prePhases createNugetDirs - preConfigurePhases+=(configureNuget) + appendToVar preConfigurePhases configureNuget fi diff --git a/pkgs/development/libraries/liquidfun/default.nix b/pkgs/development/libraries/liquidfun/default.nix index 6ab138016d19..2e12f5903444 100644 --- a/pkgs/development/libraries/liquidfun/default.nix +++ b/pkgs/development/libraries/liquidfun/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { sourceRoot = "liquidfun/Box2D"; - preConfigurePhases = "preConfigure"; + preConfigurePhases = [ "preConfigure" ]; preConfigure = '' sed -i Box2D/Common/b2Settings.h -e 's@b2_maxPolygonVertices .*@b2_maxPolygonVertices 15@' From 385d523a8e578dbd046b2345c8b034ddc164e12d Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Tue, 3 Sep 2024 04:14:28 +0800 Subject: [PATCH 3/6] treewide: handle preInstallPhases __structuredAttrs-agnostically Always specify the preInstallPhases attribute as a list instead of a string. Append elements to the preInstallPhases Bash variable using appendToVar instead of string or Bash array concatenation. --- pkgs/desktops/gnustep/make/setup-hook.sh | 2 +- .../interpreters/python/hooks/python-runtime-deps-check-hook.sh | 2 +- pkgs/development/libraries/glib/setup-hook.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/desktops/gnustep/make/setup-hook.sh b/pkgs/desktops/gnustep/make/setup-hook.sh index 0bfbd35f45f5..202084cc671d 100644 --- a/pkgs/desktops/gnustep/make/setup-hook.sh +++ b/pkgs/desktops/gnustep/make/setup-hook.sh @@ -18,7 +18,7 @@ addGnustepInstallFlags() { ) } -preInstallPhases+=" addGnustepInstallFlags" +appendToVar preInstallPhases addGnustepInstallFlags addGNUstepEnvVars() { local filename diff --git a/pkgs/development/interpreters/python/hooks/python-runtime-deps-check-hook.sh b/pkgs/development/interpreters/python/hooks/python-runtime-deps-check-hook.sh index 43a2f9b88745..dc888262ea0d 100644 --- a/pkgs/development/interpreters/python/hooks/python-runtime-deps-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-runtime-deps-check-hook.sh @@ -16,5 +16,5 @@ pythonRuntimeDepsCheckHook() { if [ -z "${dontCheckRuntimeDeps-}" ]; then echo "Using pythonRuntimeDepsCheckHook" - preInstallPhases+=" pythonRuntimeDepsCheckHook" + appendToVar preInstallPhases pythonRuntimeDepsCheckHook fi diff --git a/pkgs/development/libraries/glib/setup-hook.sh b/pkgs/development/libraries/glib/setup-hook.sh index 8ead5510ec4f..9eabf8a679a9 100644 --- a/pkgs/development/libraries/glib/setup-hook.sh +++ b/pkgs/development/libraries/glib/setup-hook.sh @@ -12,7 +12,7 @@ addEnvHooks "$targetOffset" make_glib_find_gsettings_schemas glibPreInstallPhase() { makeFlagsArray+=("gsettingsschemadir=${!outputLib}/share/gsettings-schemas/$name/glib-2.0/schemas/") } -preInstallPhases+=" glibPreInstallPhase" +appendToVar preInstallPhases glibPreInstallPhase glibPreFixupPhase() { # Move gschemas in case the install flag didn't help From 054c5f0e106d8a0169582fed4c1b2ba86647f73d Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Tue, 3 Sep 2024 04:14:28 +0800 Subject: [PATCH 4/6] treewide: handle preDistPhases __structuredAttrs-agnostically Always specify the preDistPhases attribute as a list instead of a string. Append elements to the preDistPhases Bash variable using appendToVar instead of string or Bash array concatenation. Handle element insertion before a specific element using string substitution as before, but handle both structured and unstructured attributes. --- .../vim/plugins/neovim-require-check-hook.sh | 2 +- .../editors/vim/plugins/vim-command-check-hook.sh | 2 +- pkgs/build-support/make-darwin-bundle/default.nix | 2 +- .../octave-write-required-octave-packages-hook.sh | 2 +- .../hooks/write-required-octave-packages-hook.sh | 2 +- .../python/hooks/pytest-check-hook.sh | 2 +- .../python/hooks/python-catch-conflicts-hook.sh | 2 +- .../python/hooks/python-imports-check-hook.sh | 2 +- .../hooks/python-remove-bin-bytecode-hook.sh | 2 +- .../interpreters/python/hooks/sphinx-hook.sh | 2 +- .../python/hooks/unittest-check-hook.sh | 2 +- .../python-modules/pytest-forked/setup-hook.sh | 15 +++++++++++---- .../python-modules/pytest-xdist/setup-hook.sh | 15 +++++++++++---- pkgs/development/python-modules/pytest/7.nix | 4 ++-- .../development/python-modules/pytest/default.nix | 4 ++-- .../python2-modules/pytest/default.nix | 4 ++-- .../manifest-requirements-check-hook.sh | 2 +- 17 files changed, 40 insertions(+), 26 deletions(-) diff --git a/pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh b/pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh index 0c6a0010845d..e901e4fd2774 100644 --- a/pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh +++ b/pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh @@ -16,6 +16,6 @@ neovimRequireCheckHook () { } echo "Using neovimRequireCheckHook" -preDistPhases+=" neovimRequireCheckHook" +appendToVar preDistPhases neovimRequireCheckHook diff --git a/pkgs/applications/editors/vim/plugins/vim-command-check-hook.sh b/pkgs/applications/editors/vim/plugins/vim-command-check-hook.sh index c4ddd8e0c5af..402910fd0cbd 100644 --- a/pkgs/applications/editors/vim/plugins/vim-command-check-hook.sh +++ b/pkgs/applications/editors/vim/plugins/vim-command-check-hook.sh @@ -21,5 +21,5 @@ vimCommandCheckHook () { } echo "Using vimCommandCheckHook" -preDistPhases+=" vimCommandCheckHook" +appendToVar preDistPhases vimCommandCheckHook diff --git a/pkgs/build-support/make-darwin-bundle/default.nix b/pkgs/build-support/make-darwin-bundle/default.nix index 52dd54b0b2c4..a80ebf8fac9e 100644 --- a/pkgs/build-support/make-darwin-bundle/default.nix +++ b/pkgs/build-support/make-darwin-bundle/default.nix @@ -22,5 +22,5 @@ writeShellScript "make-darwin-bundle-${name}" ('' ${writeDarwinBundle}/bin/write-darwin-bundle "''${!outputBin}" "${name}" "${exec}" } - preDistPhases+=" makeDarwinBundlePhase" + appendToVar preDistPhases makeDarwinBundlePhase '') diff --git a/pkgs/development/interpreters/octave/hooks/octave-write-required-octave-packages-hook.sh b/pkgs/development/interpreters/octave/hooks/octave-write-required-octave-packages-hook.sh index 64e87d68246f..fb808485a36a 100644 --- a/pkgs/development/interpreters/octave/hooks/octave-write-required-octave-packages-hook.sh +++ b/pkgs/development/interpreters/octave/hooks/octave-write-required-octave-packages-hook.sh @@ -13,5 +13,5 @@ octaveWriteRequiredOctavePackagesPhase() { # Yes its a bit long... if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then echo "Using octaveWriteRequiredOctavePackagesPhase" - preDistPhases+=" octaveWriteRequiredOctavePackagesPhase" + appendToVar preDistPhases octaveWriteRequiredOctavePackagesPhase fi diff --git a/pkgs/development/interpreters/octave/hooks/write-required-octave-packages-hook.sh b/pkgs/development/interpreters/octave/hooks/write-required-octave-packages-hook.sh index 032ea398ac56..6c5de6e4fc4f 100644 --- a/pkgs/development/interpreters/octave/hooks/write-required-octave-packages-hook.sh +++ b/pkgs/development/interpreters/octave/hooks/write-required-octave-packages-hook.sh @@ -13,5 +13,5 @@ writeRequiredOctavePackagesPhase() { # Yes its a bit long... if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then echo "Using writeRequiredOctavePackagesPhase" - preDistPhases+=" writeRequiredOctavePackagesPhase" + appendToVar preDistPhases writeRequiredOctavePackagesPhase fi diff --git a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh index 06694e79e492..a9e82674c5f8 100644 --- a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh @@ -58,5 +58,5 @@ function pytestCheckPhase() { if [ -z "${dontUsePytestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then echo "Using pytestCheckPhase" - preDistPhases+=" pytestCheckPhase" + appendToVar 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 0abcad3c42f2..6ba3d7f65cb4 100644 --- a/pkgs/development/interpreters/python/hooks/python-catch-conflicts-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-catch-conflicts-hook.sh @@ -6,5 +6,5 @@ pythonCatchConflictsPhase() { } if [ -z "${dontUsePythonCatchConflicts-}" ]; then - preDistPhases+=" pythonCatchConflictsPhase" + appendToVar 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 b65d6e745247..f4ef271ac1b2 100644 --- a/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh @@ -18,5 +18,5 @@ pythonImportsCheckPhase () { if [ -z "${dontUsePythonImportsCheck-}" ]; then echo "Using pythonImportsCheckPhase" - preDistPhases+=" pythonImportsCheckPhase" + appendToVar 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 1180694294db..d67c0c557353 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 @@ -13,5 +13,5 @@ pythonRemoveBinBytecodePhase () { } if [ -z "${dontUsePythonRemoveBinBytecode-}" ]; then - preDistPhases+=" pythonRemoveBinBytecodePhase" + appendToVar preDistPhases pythonRemoveBinBytecodePhase fi diff --git a/pkgs/development/interpreters/python/hooks/sphinx-hook.sh b/pkgs/development/interpreters/python/hooks/sphinx-hook.sh index 0307e83d9479..0f32a6ec0e82 100644 --- a/pkgs/development/interpreters/python/hooks/sphinx-hook.sh +++ b/pkgs/development/interpreters/python/hooks/sphinx-hook.sh @@ -69,4 +69,4 @@ installSphinxPhase() { runHook postInstallSphinx } -preDistPhases+=" buildSphinxPhase installSphinxPhase" +appendToVar preDistPhases buildSphinxPhase installSphinxPhase diff --git a/pkgs/development/interpreters/python/hooks/unittest-check-hook.sh b/pkgs/development/interpreters/python/hooks/unittest-check-hook.sh index f4bd34747730..64ecb13cbc71 100644 --- a/pkgs/development/interpreters/python/hooks/unittest-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/unittest-check-hook.sh @@ -13,5 +13,5 @@ unittestCheckPhase() { if [ -z "${dontUseUnittestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then echo "Using unittestCheckPhase" - preDistPhases+=" unittestCheckPhase" + appendToVar preDistPhases unittestCheckPhase fi diff --git a/pkgs/development/python-modules/pytest-forked/setup-hook.sh b/pkgs/development/python-modules/pytest-forked/setup-hook.sh index e613feadf834..0eff690e9079 100644 --- a/pkgs/development/python-modules/pytest-forked/setup-hook.sh +++ b/pkgs/development/python-modules/pytest-forked/setup-hook.sh @@ -16,10 +16,17 @@ pytestForkedHook() { # until we have dependency mechanism in generic builder, we need to use this ugly hack. if [ -z "${dontUsePytestForked-}" ] && [ -z "${dontUsePytestCheck-}" ]; then - if [[ " ${preDistPhases:-} " =~ " pytestCheckPhase " ]]; then - preDistPhases+=" " - preDistPhases="${preDistPhases/ pytestCheckPhase / pytestForkedHook pytestCheckPhase }" + if [[ " ${preDistPhases[*]:-} " =~ " pytestCheckPhase " ]]; then + _preDistPhases="${preDistPhases[*]} " + _preDistPhases="${_preDistPhases/ pytestCheckPhase / pytestForkedHook pytestCheckPhase }" + if [[ -n "${__structuredAttrs-}" ]]; then + preDistPhases=() + else + preDistPhases="" + fi + appendToVar preDistPhases $_preDistPhases + unset _preDistPhases else - preDistPhases+=" pytestForkedHook" + appendToVar preDistPhases pytestForkedHook fi fi diff --git a/pkgs/development/python-modules/pytest-xdist/setup-hook.sh b/pkgs/development/python-modules/pytest-xdist/setup-hook.sh index 4c6473cea64d..9819e0d3ec7d 100644 --- a/pkgs/development/python-modules/pytest-xdist/setup-hook.sh +++ b/pkgs/development/python-modules/pytest-xdist/setup-hook.sh @@ -8,10 +8,17 @@ pytestXdistHook() { # until we have dependency mechanism in generic builder, we need to use this ugly hack. if [ -z "${dontUsePytestXdist-}" ] && [ -z "${dontUsePytestCheck-}" ]; then - if [[ " ${preDistPhases:-} " =~ " pytestCheckPhase " ]]; then - preDistPhases+=" " - preDistPhases="${preDistPhases/ pytestCheckPhase / pytestXdistHook pytestCheckPhase }" + if [[ " ${preDistPhases[*]:-} " =~ " pytestCheckPhase " ]]; then + _preDistPhases="${preDistPhases[*]} " + _preDistPhases="${_preDistPhases/ pytestCheckPhase / pytestXdistHook pytestCheckPhase }" + if [[ -n "${__structuredAttrs-}" ]]; then + preDistPhases=() + else + preDistPhases="" + fi + appendToVar preDistPhases $_preDistPhases + unset _preDistPhases else - preDistPhases+=" pytestXdistHook" + appendToVar preDistPhases pytestXdistHook fi fi diff --git a/pkgs/development/python-modules/pytest/7.nix b/pkgs/development/python-modules/pytest/7.nix index 8ca33b158e5c..3468bc73c098 100644 --- a/pkgs/development/python-modules/pytest/7.nix +++ b/pkgs/development/python-modules/pytest/7.nix @@ -87,7 +87,7 @@ let pytestcachePhase() { find $out -name .pytest_cache -type d -exec rm -rf {} + } - preDistPhases+=" pytestcachePhase" + appendToVar preDistPhases pytestcachePhase # pytest generates it's own bytecode files to improve assertion messages. # These files similar to cpython's bytecode files but are never laoded @@ -100,7 +100,7 @@ let # https://github.com/pytest-dev/pytest/blob/7.2.1/src/_pytest/assertion/rewrite.py#L51-L53 find $out -name "*-pytest-*.py[co]" -delete } - preDistPhases+=" pytestRemoveBytecodePhase" + appendToVar preDistPhases pytestRemoveBytecodePhase ''; pythonImportsCheck = [ "pytest" ]; diff --git a/pkgs/development/python-modules/pytest/default.nix b/pkgs/development/python-modules/pytest/default.nix index fc5ca9c2a37b..1dcc23658394 100644 --- a/pkgs/development/python-modules/pytest/default.nix +++ b/pkgs/development/python-modules/pytest/default.nix @@ -84,7 +84,7 @@ buildPythonPackage rec { pytestcachePhase() { find $out -name .pytest_cache -type d -exec rm -rf {} + } - preDistPhases+=" pytestcachePhase" + appendToVar preDistPhases pytestcachePhase # pytest generates it's own bytecode files to improve assertion messages. # These files similar to cpython's bytecode files but are never laoded @@ -97,7 +97,7 @@ buildPythonPackage rec { # https://github.com/pytest-dev/pytest/blob/7.2.1/src/_pytest/assertion/rewrite.py#L51-L53 find $out -name "*-pytest-*.py[co]" -delete } - preDistPhases+=" pytestRemoveBytecodePhase" + appendToVar preDistPhases pytestRemoveBytecodePhase ''; pythonImportsCheck = [ "pytest" ]; diff --git a/pkgs/development/python2-modules/pytest/default.nix b/pkgs/development/python2-modules/pytest/default.nix index 0edfd3039112..fa086eb46c7c 100644 --- a/pkgs/development/python2-modules/pytest/default.nix +++ b/pkgs/development/python2-modules/pytest/default.nix @@ -42,7 +42,7 @@ buildPythonPackage rec { find $out -name .pytest_cache -type d -exec rm -rf {} + } - preDistPhases+=" pytestcachePhase" + appendToVar preDistPhases pytestcachePhase # pytest generates it's own bytecode files to improve assertion messages. # These files similar to cpython's bytecode files but are never laoded @@ -55,7 +55,7 @@ buildPythonPackage rec { # https://github.com/pytest-dev/pytest/blob/4.6.11/src/_pytest/assertion/rewrite.py#L32-L47 find $out -name "*-PYTEST.py[co]" -delete } - preDistPhases+=" pytestRemoveBytecodePhase" + appendToVar preDistPhases pytestRemoveBytecodePhase ''; meta = with lib; { diff --git a/pkgs/servers/home-assistant/build-custom-component/manifest-requirements-check-hook.sh b/pkgs/servers/home-assistant/build-custom-component/manifest-requirements-check-hook.sh index 74f29ca399ed..1fb366d13b43 100644 --- a/pkgs/servers/home-assistant/build-custom-component/manifest-requirements-check-hook.sh +++ b/pkgs/servers/home-assistant/build-custom-component/manifest-requirements-check-hook.sh @@ -21,5 +21,5 @@ function manifestCheckPhase() { if [ -z "${dontCheckManifest-}" ] && [ -z "${installCheckPhase-}" ]; then echo "Using manifestCheckPhase" - preDistPhases+=" manifestCheckPhase" + appendToVar preDistPhases manifestCheckPhase fi From 758056dac763e5368470673ae63c6fa637ba93d1 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Tue, 3 Sep 2024 04:14:28 +0800 Subject: [PATCH 5/6] treewide: handle postPhases __structuredAttrs-agnostically Always specify the postPhases attribute as a list instead of a string. Append elements to the postPhases Bash variable using appendToVar instead of string or Bash array concatenation. --- pkgs/build-support/release/binary-tarball.nix | 2 +- pkgs/build-support/release/source-tarball.nix | 2 +- .../setup-hooks/enable-coverage-instrumentation.sh | 2 +- pkgs/build-support/setup-hooks/make-coverage-analysis-report.sh | 2 +- pkgs/build-support/setup-hooks/move-build-tree.sh | 2 +- .../interpreters/python/hooks/python-recompile-bytecode-hook.sh | 2 +- pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh | 2 +- pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/build-support/release/binary-tarball.nix b/pkgs/build-support/release/binary-tarball.nix index 37c5f8c7ee86..aeaa8edb52be 100644 --- a/pkgs/build-support/release/binary-tarball.nix +++ b/pkgs/build-support/release/binary-tarball.nix @@ -24,7 +24,7 @@ stdenv.mkDerivation ( prefix = "/usr/local"; - postPhases = "finalPhase"; + postPhases = [ "finalPhase" ]; } // args // diff --git a/pkgs/build-support/release/source-tarball.nix b/pkgs/build-support/release/source-tarball.nix index 3c88ca980ba0..4effd63f740b 100644 --- a/pkgs/build-support/release/source-tarball.nix +++ b/pkgs/build-support/release/source-tarball.nix @@ -32,7 +32,7 @@ stdenv.mkDerivation ( showBuildStats = true; preConfigurePhases = [ "autoconfPhase" ]; - postPhases = "finalPhase"; + postPhases = [ "finalPhase" ]; # Autoconfiscate the sources. autoconfPhase = '' diff --git a/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh b/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh index 2b48fea4ff0b..61e9ed5705f4 100644 --- a/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh +++ b/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh @@ -1,4 +1,4 @@ -postPhases+=" cleanupBuildDir" +appendToVar postPhases cleanupBuildDir # Force GCC to build with coverage instrumentation. Also disable # optimisation, since it may confuse things. diff --git a/pkgs/build-support/setup-hooks/make-coverage-analysis-report.sh b/pkgs/build-support/setup-hooks/make-coverage-analysis-report.sh index 9108b4c50355..d6a03019dc51 100644 --- a/pkgs/build-support/setup-hooks/make-coverage-analysis-report.sh +++ b/pkgs/build-support/setup-hooks/make-coverage-analysis-report.sh @@ -1,4 +1,4 @@ -postPhases+=" coverageReportPhase" +appendToVar postPhases coverageReportPhase coverageReportPhase() { lcov --directory . --capture --output-file app.info diff --git a/pkgs/build-support/setup-hooks/move-build-tree.sh b/pkgs/build-support/setup-hooks/move-build-tree.sh index 625f87965f39..29495e1d9f29 100644 --- a/pkgs/build-support/setup-hooks/move-build-tree.sh +++ b/pkgs/build-support/setup-hooks/move-build-tree.sh @@ -5,7 +5,7 @@ moveBuildDir() { cd $out/.build } -postPhases+=" removeBuildDir" +appendToVar postPhases removeBuildDir removeBuildDir() { rm -rf $out/.build diff --git a/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh b/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh index 649d0c17ea0c..7ac8c2d5cc72 100644 --- a/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh @@ -20,5 +20,5 @@ pythonRecompileBytecodePhase () { } if [ -z "${dontUsePythonRecompileBytecode-}" ]; then - postPhases+=" pythonRecompileBytecodePhase" + appendToVar postPhases pythonRecompileBytecodePhase fi 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 8f1fe0e6c6ff..1b189d24d9ee 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -97,7 +97,7 @@ postPatchMkspecs() { fi } if [ -z "${dontPatchMkspecs-}" ]; then - postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs" + appendToVar postPhases postPatchMkspecs fi qtPreHook() { diff --git a/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh index 15a824f1cb45..1ccfbd0cba38 100644 --- a/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-6/hooks/qtbase-setup-hook.sh @@ -71,7 +71,7 @@ else # Only set up Qt once. fi } if [ -z "${dontPatchMkspecs-}" ]; then - postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs" + appendToVar postPhases postPatchMkspecs fi qtPreHook() { From 5ec4f676b47936aa3ccf7122ead2002ab67a5008 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Tue, 3 Sep 2024 05:52:40 +0800 Subject: [PATCH 6/6] doc/stdenv: document the format of *Phases Require the elements of *Phases not to contain spaces. Require the *Phases attribute to be specified as Nix Language lists. --- doc/stdenv/stdenv.chapter.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index 35330305f189..2ef71687b2c6 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -518,8 +518,10 @@ There are a number of variables that control what phases are executed and in wha Specifies the phases. You can change the order in which phases are executed, or add new phases, by setting this variable. If it’s not set, the default value is used, which is `$prePhases unpackPhase patchPhase $preConfigurePhases configurePhase $preBuildPhases buildPhase checkPhase $preInstallPhases installPhase fixupPhase installCheckPhase $preDistPhases distPhase $postPhases`. +The elements of `phases` must not contain spaces. If `phases` is specified as a Nix Language attribute, it should be specified as lists instead of strings. The same rules apply to the `*Phases` variables. + It is discouraged to set this variable, as it is easy to miss some important functionality hidden in some of the less obviously needed phases (like `fixupPhase` which patches the shebang of scripts). -Usually, if you just want to add a few phases, it’s more convenient to set one of the variables below (such as `preInstallPhases`). +Usually, if you just want to add a few phases, it’s more convenient to set one of the `*Phases` variables below. ##### `prePhases` {#var-stdenv-prePhases}