From 0b3a76f8ea452addb1172e718139148bdd3195e3 Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 9 Oct 2025 20:02:19 +0200 Subject: [PATCH] wasmtime: fix multiple-output derivation `propagatedBuildOutputs = [ ]` meant that the `wasmtime` binary didn't get added to `$PATH` when used in devShells. This fixes the problem by moving the libraries into their own `lib` output, to which the `wasmtime.out` output doesn't propagate - achieving the same result without messing up user's devShells. Closes #449638. --- pkgs/by-name/wa/wasmtime/package.nix | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/wa/wasmtime/package.nix b/pkgs/by-name/wa/wasmtime/package.nix index c17c58286024..45f0b5a3cd60 100644 --- a/pkgs/by-name/wa/wasmtime/package.nix +++ b/pkgs/by-name/wa/wasmtime/package.nix @@ -37,6 +37,7 @@ rustPlatform.buildRustPackage (finalAttrs: { outputs = [ "out" "dev" + "lib" ]; nativeBuildInputs = [ @@ -55,27 +56,24 @@ rustPlatform.buildRustPackage (finalAttrs: { # error: linker `rust-lld` not found !isAarch64; - # prevent $out from being propagated to $dev: - # the library and header files are not dependent on the binaries - propagatedBuildOutputs = [ ]; - postInstall = let inherit (stdenv.hostPlatform.rust) cargoShortTarget; in '' - moveToOutput lib $dev - ${lib.optionalString (!enableShared) "rm -f $dev/lib/*.so{,.*}"} - ${lib.optionalString (!enableStatic) "rm -f $dev/lib/*.a"} + moveToOutput lib $lib + ${lib.optionalString (!enableShared) "rm -f $lib/lib/*.so{,.*}"} + ${lib.optionalString (!enableStatic) "rm -f $lib/lib/*.a"} # copy the build.rs generated c-api headers # https://github.com/rust-lang/cargo/issues/9661 + mkdir $dev cp -r target/${cargoShortTarget}/release/build/wasmtime-c-api-impl-*/out/include $dev/include '' + lib.optionalString stdenv.hostPlatform.isDarwin '' install_name_tool -id \ - $dev/lib/libwasmtime.dylib \ - $dev/lib/libwasmtime.dylib + $lib/lib/libwasmtime.dylib \ + $lib/lib/libwasmtime.dylib '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' installShellCompletion --cmd wasmtime \