doc: Fix missing pre/post hooks everywhere

This commit is contained in:
Niklas Hambüchen 2024-06-10 10:45:36 +02:00
parent 2795c506fe
commit ee6c2bd2eb
10 changed files with 51 additions and 4 deletions

View file

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

View file

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

View file

@ -118,7 +118,13 @@ pkgs.stdenv.mkDerivation {
runHook postBuild 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 *.json $out/share
cp *.rng $out/share cp *.rng $out/share
cp README.md $doc/share/${name} cp README.md $doc/share/${name}
runHook postInstall runHook postInstall
''; '';

View file

@ -69,9 +69,13 @@ script to run it using a JRE. You can use `makeWrapper` for this:
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
makeWrapper ${jre}/bin/java $out/bin/foo \ makeWrapper ${jre}/bin/java $out/bin/foo \
--add-flags "-cp $out/share/java/foo.jar org.foo.Main" --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 ```nix
{ {
configurePhase = '' configurePhase = ''
runHook preConfigure
ln -s $node_modules node_modules ln -s $node_modules node_modules
runHook postConfigure
''; '';
} }
``` ```
@ -700,8 +704,12 @@ or if you need a writeable node_modules directory:
```nix ```nix
{ {
configurePhase = '' configurePhase = ''
runHook preConfigure
cp -r $node_modules node_modules cp -r $node_modules node_modules
chmod +w 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 ```nix
{ {
buildPhase = '' buildPhase = ''
runHook preBuild
${sbcl'}/bin/sbcl --load my-build-file.lisp ${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 # The helper provides a configure snippet that will prepare all dependencies
# in the correct place, where SwiftPM expects them. # in the correct place, where SwiftPM expects them.
configurePhase = generated.configure; configurePhase = ''
runHook preConfigure
${generated.configure}
runHook postConfigure
'';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
@ -168,11 +174,17 @@ with a writable copy:
```nix ```nix
{ {
configurePhase = generated.configure ++ '' configurePhase = ''
runHook preConfigure
${generated.configure}
# Replace the dependency symlink with a writable copy. # Replace the dependency symlink with a writable copy.
swiftpmMakeMutable swift-crypto swiftpmMakeMutable swift-crypto
# Now apply a patch. # Now apply a patch.
patch -p1 -d .build/checkouts/swift-crypto -i ${./some-fix.patch} patch -p1 -d .build/checkouts/swift-crypto -i ${./some-fix.patch}
runHook postConfigure
''; '';
} }
``` ```

View file

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

View file

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