doc: Fix missing pre/post hooks everywhere (#318737)

This commit is contained in:
Niklas Hambüchen 2025-05-25 00:12:13 +02:00 committed by GitHub
commit 4684fd6b0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 48 additions and 5 deletions

View file

@ -37,7 +37,7 @@ let
helloCheckpoint = prepareCheckpointBuild pkgs.hello;
changedHello = pkgs.hello.overrideAttrs (_: {
doCheck = false;
patchPhase = ''
postPatch = ''
sed -i 's/Hello, world!/Hello, Nix!/g' src/hello.c
'';
});

View file

@ -102,6 +102,8 @@ stdenvNoCC.mkDerivation {
];
installPhase = ''
runHook preInstall
cd ..
export NIX_STATE_DIR=$(mktemp -d)
@ -143,5 +145,7 @@ stdenvNoCC.mkDerivation {
) libsets}
echo '```' >> "$out/index.md"
runHook postInstall
'';
}

View file

@ -118,7 +118,13 @@ pkgs.stdenv.mkDerivation {
runHook postBuild
'';
installPhase = "mv gulpdist $out";
installPhase = ''
runHook preInstall
mv gulpdist $out
runHook postInstall
'';
}
```

View file

@ -192,6 +192,7 @@ pkgs.buildEmscriptenPackage {
cp *.json $out/share
cp *.rng $out/share
cp README.md $doc/share/${name}
runHook postInstall
'';

View file

@ -69,9 +69,13 @@ script to run it using a JRE. You can use `makeWrapper` for this:
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
makeWrapper ${jre}/bin/java $out/bin/foo \
--add-flags "-cp $out/share/java/foo.jar org.foo.Main"
runHook postInstall
'';
}
```

View file

@ -690,7 +690,11 @@ The configure phase can sometimes fail because it makes many assumptions which m
```nix
{
configurePhase = ''
runHook preConfigure
ln -s $node_modules node_modules
runHook postConfigure
'';
}
```
@ -700,8 +704,12 @@ or if you need a writeable node_modules directory:
```nix
{
configurePhase = ''
runHook preConfigure
cp -r $node_modules node_modules
chmod +w node_modules
runHook postConfigure
'';
}
```

View file

@ -59,7 +59,11 @@ Such a Lisp can be now used e.g. to compile your sources:
```nix
{
buildPhase = ''
runHook preBuild
${sbcl'}/bin/sbcl --load my-build-file.lisp
runHook postBuild
'';
}
```

View file

@ -103,7 +103,13 @@ stdenv.mkDerivation (finalAttrs: {
# The helper provides a configure snippet that will prepare all dependencies
# in the correct place, where SwiftPM expects them.
configurePhase = generated.configure;
configurePhase = ''
runHook preConfigure
${generated.configure}
runHook postConfigure
'';
installPhase = ''
runHook preInstall
@ -168,11 +174,17 @@ with a writable copy:
```nix
{
configurePhase = generated.configure ++ ''
configurePhase = ''
runHook preConfigure
${generated.configure}
# Replace the dependency symlink with a writable copy.
swiftpmMakeMutable swift-crypto
# Now apply a patch.
patch -p1 -d .build/checkouts/swift-crypto -i ${./some-fix.patch}
runHook postConfigure
'';
}
```

View file

@ -113,9 +113,13 @@ stdenv.mkDerivation {
"bar.lua"
];
installPhase = ''
runHook preInstall
mkdir $out/share
cp foo.py $out/share
cp bar.lua $out/share
runHook postInstall
'';
}
```

View file

@ -261,7 +261,7 @@ stdenv.mkDerivation (finalAttrs: {
util-linux
qemu
];
checkPhase = ''[elided]'';
# `checkPhase` elided
})
```