From ee6c2bd2eb1345e00fa65ff69ea9a0481a8406ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Mon, 10 Jun 2024 10:45:36 +0200 Subject: [PATCH] doc: Fix missing pre/post hooks everywhere --- .../special/checkpoint-build.section.md | 4 ++++ doc/doc-support/lib-function-docs.nix | 4 ++++ doc/languages-frameworks/bower.section.md | 8 +++++++- doc/languages-frameworks/emscripten.section.md | 1 + doc/languages-frameworks/java.section.md | 4 ++++ doc/languages-frameworks/javascript.section.md | 8 ++++++++ doc/languages-frameworks/lisp.section.md | 4 ++++ doc/languages-frameworks/swift.section.md | 16 ++++++++++++++-- doc/packages/weechat.section.md | 4 ++++ doc/stdenv/stdenv.chapter.md | 2 +- 10 files changed, 51 insertions(+), 4 deletions(-) diff --git a/doc/build-helpers/special/checkpoint-build.section.md b/doc/build-helpers/special/checkpoint-build.section.md index 036fee286a99..d2496ab37610 100644 --- a/doc/build-helpers/special/checkpoint-build.section.md +++ b/doc/build-helpers/special/checkpoint-build.section.md @@ -38,7 +38,11 @@ let changedHello = pkgs.hello.overrideAttrs (_: { doCheck = false; patchPhase = '' + runHook prePatch + sed -i 's/Hello, world!/Hello, Nix!/g' src/hello.c + + runHook postPatch ''; }); in diff --git a/doc/doc-support/lib-function-docs.nix b/doc/doc-support/lib-function-docs.nix index e6c08dabb5b0..bb81b50fddef 100644 --- a/doc/doc-support/lib-function-docs.nix +++ b/doc/doc-support/lib-function-docs.nix @@ -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 ''; } diff --git a/doc/languages-frameworks/bower.section.md b/doc/languages-frameworks/bower.section.md index 3783773e2bf2..dc4aeb16d626 100644 --- a/doc/languages-frameworks/bower.section.md +++ b/doc/languages-frameworks/bower.section.md @@ -118,7 +118,13 @@ pkgs.stdenv.mkDerivation { runHook postBuild ''; - installPhase = "mv gulpdist $out"; + installPhase = '' + runHook preInstall + + mv gulpdist $out + + runHook postInstall + ''; } ``` diff --git a/doc/languages-frameworks/emscripten.section.md b/doc/languages-frameworks/emscripten.section.md index 0fca82f70aed..b36ec5fc32a5 100644 --- a/doc/languages-frameworks/emscripten.section.md +++ b/doc/languages-frameworks/emscripten.section.md @@ -192,6 +192,7 @@ pkgs.buildEmscriptenPackage { cp *.json $out/share cp *.rng $out/share cp README.md $doc/share/${name} + runHook postInstall ''; diff --git a/doc/languages-frameworks/java.section.md b/doc/languages-frameworks/java.section.md index 05203c378ae9..9b052a7cfce5 100644 --- a/doc/languages-frameworks/java.section.md +++ b/doc/languages-frameworks/java.section.md @@ -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 ''; } ``` diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index e076984db000..e327eb43ea40 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -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 ''; } ``` diff --git a/doc/languages-frameworks/lisp.section.md b/doc/languages-frameworks/lisp.section.md index 7f6fe99419bd..35d2b33a0ae0 100644 --- a/doc/languages-frameworks/lisp.section.md +++ b/doc/languages-frameworks/lisp.section.md @@ -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 ''; } ``` diff --git a/doc/languages-frameworks/swift.section.md b/doc/languages-frameworks/swift.section.md index b9d4b5a7cba8..c269517609f1 100644 --- a/doc/languages-frameworks/swift.section.md +++ b/doc/languages-frameworks/swift.section.md @@ -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 ''; } ``` diff --git a/doc/packages/weechat.section.md b/doc/packages/weechat.section.md index f175547de825..c535cfb9ba4e 100644 --- a/doc/packages/weechat.section.md +++ b/doc/packages/weechat.section.md @@ -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 ''; } ``` diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index 6851294ddf96..29b57e9f6d31 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -261,7 +261,7 @@ stdenv.mkDerivation (finalAttrs: { util-linux qemu ]; - checkPhase = ''[elided]''; + # `checkPhase` elided }) ```