From 1da8df70f6058e34e92129e5b9fbc430d2ef29c0 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 27 Mar 2025 12:42:10 -0400 Subject: [PATCH] waf: make executable runnable (#388010) --- doc/hooks/waf.section.md | 2 +- pkgs/by-name/wa/waf/package.nix | 12 ++++++++++-- pkgs/by-name/wa/waf/setup-hook.sh | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/hooks/waf.section.md b/doc/hooks/waf.section.md index b58887b6b647..437a98920790 100644 --- a/doc/hooks/waf.section.md +++ b/doc/hooks/waf.section.md @@ -14,7 +14,7 @@ The variables below are exclusive of `wafHook`. Location of the `waf` tool. It defaults to `./waf`, to honor software projects that include it directly inside their source trees. -If `wafPath` doesn't exist, then `wafHook` will copy the `waf` provided from Nixpkgs to it. +If the file pointed by `wafPath` doesn't exist, then `waf` provided by Nixpkgs will be used. #### `wafFlags` {#waf-flags} diff --git a/pkgs/by-name/wa/waf/package.nix b/pkgs/by-name/wa/waf/package.nix index 7a2e4298a0d8..bf0d1bb4922f 100644 --- a/pkgs/by-name/wa/waf/package.nix +++ b/pkgs/by-name/wa/waf/package.nix @@ -4,6 +4,7 @@ , callPackage , ensureNewerSourcesForZipFilesHook , python3 +, makeWrapper # optional list of extra waf tools, e.g. `[ "doxygen" "pytest" ]` , extraTools ? [] }: @@ -22,6 +23,7 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ ensureNewerSourcesForZipFilesHook python3 + makeWrapper ]; buildInputs = [ @@ -49,14 +51,20 @@ stdenv.mkDerivation (finalAttrs: { python waf-light build ${extraToolsList} + substituteInPlace waf \ + --replace "w = test(i + '/lib/' + dirname)" \ + "w = test('$out/${python3.sitePackages}')" + runHook postBuild ''; installPhase = '' runHook preInstall - install -D waf $out/bin/waf - + install -D waf "$out"/bin/waf + wrapProgram "$out"/bin/waf --set PYTHONPATH "$out"/${python3.sitePackages} + mkdir -p "$out"/${python3.sitePackages}/ + cp -r waflib "$out"/${python3.sitePackages}/ runHook postInstall ''; diff --git a/pkgs/by-name/wa/waf/setup-hook.sh b/pkgs/by-name/wa/waf/setup-hook.sh index 692341fb5a04..5d7c3dc61eda 100644 --- a/pkgs/by-name/wa/waf/setup-hook.sh +++ b/pkgs/by-name/wa/waf/setup-hook.sh @@ -4,8 +4,7 @@ wafConfigurePhase() { runHook preConfigure if ! [ -f "${wafPath:=./waf}" ]; then - echo "copying waf to $wafPath..." - cp @waf@/bin/waf "$wafPath" + wafPath="@waf@/bin/waf" fi if [ -z "${dontAddPrefix:-}" ] && [ -n "$prefix" ]; then