treewide: handle *Phases
variables __structuredAttrs
-agnostically (#339117)
This commit is contained in:
commit
4160ccc634
@ -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}
|
||||
|
||||
|
@ -16,6 +16,6 @@ neovimRequireCheckHook () {
|
||||
}
|
||||
|
||||
echo "Using neovimRequireCheckHook"
|
||||
preDistPhases+=" neovimRequireCheckHook"
|
||||
appendToVar preDistPhases neovimRequireCheckHook
|
||||
|
||||
|
||||
|
@ -21,5 +21,5 @@ vimCommandCheckHook () {
|
||||
}
|
||||
|
||||
echo "Using vimCommandCheckHook"
|
||||
preDistPhases+=" vimCommandCheckHook"
|
||||
appendToVar preDistPhases vimCommandCheckHook
|
||||
|
||||
|
@ -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
|
||||
|
@ -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";
|
||||
|
@ -22,5 +22,5 @@ writeShellScript "make-darwin-bundle-${name}" (''
|
||||
${writeDarwinBundle}/bin/write-darwin-bundle "''${!outputBin}" "${name}" "${exec}"
|
||||
}
|
||||
|
||||
preDistPhases+=" makeDarwinBundlePhase"
|
||||
appendToVar preDistPhases makeDarwinBundlePhase
|
||||
'')
|
||||
|
@ -24,7 +24,7 @@ stdenv.mkDerivation (
|
||||
|
||||
prefix = "/usr/local";
|
||||
|
||||
postPhases = "finalPhase";
|
||||
postPhases = [ "finalPhase" ];
|
||||
}
|
||||
|
||||
// args //
|
||||
|
@ -18,7 +18,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation (
|
||||
|
||||
prefix = "/usr";
|
||||
|
||||
prePhases = "installExtraDebsPhase sysInfoPhase";
|
||||
prePhases = [ "installExtraDebsPhase" "sysInfoPhase" ];
|
||||
}
|
||||
|
||||
// removeAttrs args ["vmTools" "lib"] //
|
||||
|
@ -31,8 +31,8 @@ stdenv.mkDerivation (
|
||||
|
||||
showBuildStats = true;
|
||||
|
||||
preConfigurePhases = "autoconfPhase";
|
||||
postPhases = "finalPhase";
|
||||
preConfigurePhases = [ "autoconfPhase" ];
|
||||
postPhases = [ "finalPhase" ];
|
||||
|
||||
# Autoconfiscate the sources.
|
||||
autoconfPhase = ''
|
||||
|
@ -1,4 +1,4 @@
|
||||
preConfigurePhases="${preConfigurePhases:-} autoreconfPhase"
|
||||
appendToVar preConfigurePhases autoreconfPhase
|
||||
|
||||
autoreconfPhase() {
|
||||
runHook preAutoreconf
|
||||
|
@ -1,4 +1,4 @@
|
||||
postPhases+=" cleanupBuildDir"
|
||||
appendToVar postPhases cleanupBuildDir
|
||||
|
||||
# Force GCC to build with coverage instrumentation. Also disable
|
||||
# optimisation, since it may confuse things.
|
||||
|
@ -1,4 +1,4 @@
|
||||
prePhases+=" moveBuildDir"
|
||||
appendToVar prePhases moveBuildDir
|
||||
|
||||
moveBuildDir() {
|
||||
mkdir -p $out/.build
|
||||
|
@ -1,4 +1,4 @@
|
||||
postPhases+=" coverageReportPhase"
|
||||
appendToVar postPhases coverageReportPhase
|
||||
|
||||
coverageReportPhase() {
|
||||
lcov --directory . --capture --output-file app.info
|
||||
|
@ -1,11 +1,11 @@
|
||||
prePhases+=" moveBuildDir"
|
||||
appendToVar prePhases moveBuildDir
|
||||
|
||||
moveBuildDir() {
|
||||
mkdir -p $out/.build
|
||||
cd $out/.build
|
||||
}
|
||||
|
||||
postPhases+=" removeBuildDir"
|
||||
appendToVar postPhases removeBuildDir
|
||||
|
||||
removeBuildDir() {
|
||||
rm -rf $out/.build
|
||||
|
@ -1,4 +1,4 @@
|
||||
preConfigurePhases+=" updateAutotoolsGnuConfigScriptsPhase"
|
||||
appendToVar preConfigurePhases updateAutotoolsGnuConfigScriptsPhase
|
||||
|
||||
updateAutotoolsGnuConfigScriptsPhase() {
|
||||
if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then return; fi
|
||||
|
@ -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
|
||||
|
@ -18,7 +18,7 @@ addGnustepInstallFlags() {
|
||||
)
|
||||
}
|
||||
|
||||
preInstallPhases+=" addGnustepInstallFlags"
|
||||
appendToVar preInstallPhases addGnustepInstallFlags
|
||||
|
||||
addGNUstepEnvVars() {
|
||||
local filename
|
||||
|
@ -10,5 +10,5 @@ xdtAutogenPhase() {
|
||||
}
|
||||
|
||||
if [ -z "${dontUseXdtAutogenPhase-}" ]; then
|
||||
preConfigurePhases+=(xdtAutogenPhase)
|
||||
appendToVar preConfigurePhases xdtAutogenPhase
|
||||
fi
|
||||
|
@ -77,6 +77,6 @@ configureNuget() {
|
||||
}
|
||||
|
||||
if [[ -z ${dontConfigureNuget-} ]]; then
|
||||
prePhases+=(createNugetDirs)
|
||||
preConfigurePhases+=(configureNuget)
|
||||
appendToVar prePhases createNugetDirs
|
||||
appendToVar preConfigurePhases configureNuget
|
||||
fi
|
||||
|
@ -13,5 +13,5 @@ octaveWriteRequiredOctavePackagesPhase() {
|
||||
# Yes its a bit long...
|
||||
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
|
||||
echo "Using octaveWriteRequiredOctavePackagesPhase"
|
||||
preDistPhases+=" octaveWriteRequiredOctavePackagesPhase"
|
||||
appendToVar preDistPhases octaveWriteRequiredOctavePackagesPhase
|
||||
fi
|
||||
|
@ -13,5 +13,5 @@ writeRequiredOctavePackagesPhase() {
|
||||
# Yes its a bit long...
|
||||
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
|
||||
echo "Using writeRequiredOctavePackagesPhase"
|
||||
preDistPhases+=" writeRequiredOctavePackagesPhase"
|
||||
appendToVar preDistPhases writeRequiredOctavePackagesPhase
|
||||
fi
|
||||
|
@ -58,5 +58,5 @@ function pytestCheckPhase() {
|
||||
|
||||
if [ -z "${dontUsePytestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
|
||||
echo "Using pytestCheckPhase"
|
||||
preDistPhases+=" pytestCheckPhase"
|
||||
appendToVar preDistPhases pytestCheckPhase
|
||||
fi
|
||||
|
@ -6,5 +6,5 @@ pythonCatchConflictsPhase() {
|
||||
}
|
||||
|
||||
if [ -z "${dontUsePythonCatchConflicts-}" ]; then
|
||||
preDistPhases+=" pythonCatchConflictsPhase"
|
||||
appendToVar preDistPhases pythonCatchConflictsPhase
|
||||
fi
|
||||
|
@ -18,5 +18,5 @@ pythonImportsCheckPhase () {
|
||||
|
||||
if [ -z "${dontUsePythonImportsCheck-}" ]; then
|
||||
echo "Using pythonImportsCheckPhase"
|
||||
preDistPhases+=" pythonImportsCheckPhase"
|
||||
appendToVar preDistPhases pythonImportsCheckPhase
|
||||
fi
|
||||
|
@ -20,5 +20,5 @@ pythonRecompileBytecodePhase () {
|
||||
}
|
||||
|
||||
if [ -z "${dontUsePythonRecompileBytecode-}" ]; then
|
||||
postPhases+=" pythonRecompileBytecodePhase"
|
||||
appendToVar postPhases pythonRecompileBytecodePhase
|
||||
fi
|
||||
|
@ -13,5 +13,5 @@ pythonRemoveBinBytecodePhase () {
|
||||
}
|
||||
|
||||
if [ -z "${dontUsePythonRemoveBinBytecode-}" ]; then
|
||||
preDistPhases+=" pythonRemoveBinBytecodePhase"
|
||||
appendToVar preDistPhases pythonRemoveBinBytecodePhase
|
||||
fi
|
||||
|
@ -16,5 +16,5 @@ pythonRuntimeDepsCheckHook() {
|
||||
|
||||
if [ -z "${dontCheckRuntimeDeps-}" ]; then
|
||||
echo "Using pythonRuntimeDepsCheckHook"
|
||||
preInstallPhases+=" pythonRuntimeDepsCheckHook"
|
||||
appendToVar preInstallPhases pythonRuntimeDepsCheckHook
|
||||
fi
|
||||
|
@ -69,4 +69,4 @@ installSphinxPhase() {
|
||||
runHook postInstallSphinx
|
||||
}
|
||||
|
||||
preDistPhases+=" buildSphinxPhase installSphinxPhase"
|
||||
appendToVar preDistPhases buildSphinxPhase installSphinxPhase
|
||||
|
@ -13,5 +13,5 @@ unittestCheckPhase() {
|
||||
|
||||
if [ -z "${dontUseUnittestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
|
||||
echo "Using unittestCheckPhase"
|
||||
preDistPhases+=" unittestCheckPhase"
|
||||
appendToVar preDistPhases unittestCheckPhase
|
||||
fi
|
||||
|
@ -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
|
||||
|
@ -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@'
|
||||
|
@ -20,7 +20,7 @@ qmakePrePhase() {
|
||||
# do the stripping ourselves (needed for separateDebugInfo)
|
||||
prependToVar qmakeFlags "CONFIG+=nostrip"
|
||||
}
|
||||
prePhases+=" qmakePrePhase"
|
||||
appendToVar prePhases qmakePrePhase
|
||||
|
||||
qmakeConfigurePhase() {
|
||||
runHook preConfigure
|
||||
|
@ -97,7 +97,7 @@ postPatchMkspecs() {
|
||||
fi
|
||||
}
|
||||
if [ -z "${dontPatchMkspecs-}" ]; then
|
||||
postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
|
||||
appendToVar postPhases postPatchMkspecs
|
||||
fi
|
||||
|
||||
qtPreHook() {
|
||||
@ -107,6 +107,6 @@ qtPreHook() {
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
prePhases+=" qtPreHook"
|
||||
appendToVar prePhases qtPreHook
|
||||
|
||||
fi
|
||||
|
@ -13,7 +13,7 @@ qmakePrePhase() {
|
||||
"NIX_OUTPUT_QML=${!outputBin}/${qtQmlPrefix:?}" \
|
||||
"NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?}"
|
||||
}
|
||||
prePhases+=" qmakePrePhase"
|
||||
appendToVar prePhases qmakePrePhase
|
||||
|
||||
qmakeConfigurePhase() {
|
||||
runHook preConfigure
|
||||
|
@ -71,7 +71,7 @@ else # Only set up Qt once.
|
||||
fi
|
||||
}
|
||||
if [ -z "${dontPatchMkspecs-}" ]; then
|
||||
postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
|
||||
appendToVar postPhases postPatchMkspecs
|
||||
fi
|
||||
|
||||
qtPreHook() {
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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" ];
|
||||
|
@ -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" ];
|
||||
|
@ -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; {
|
||||
|
@ -21,5 +21,5 @@ function manifestCheckPhase() {
|
||||
|
||||
if [ -z "${dontCheckManifest-}" ] && [ -z "${installCheckPhase-}" ]; then
|
||||
echo "Using manifestCheckPhase"
|
||||
preDistPhases+=" manifestCheckPhase"
|
||||
appendToVar preDistPhases manifestCheckPhase
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user