diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix index f8feb79000ab..76baa7d18168 100644 --- a/pkgs/build-support/rust/hooks/default.nix +++ b/pkgs/build-support/rust/hooks/default.nix @@ -17,8 +17,9 @@ # `target/` from which to copy the build artifacts. It is derived # from a stdenv platform (or a JSON file). target ? stdenv.targetPlatform.rust.cargoShortTarget, + tests, + pkgsCross, }: - { cargoBuildHook = callPackage ( { }: @@ -27,6 +28,13 @@ substitutions = { inherit (stdenv.targetPlatform.rust) rustcTarget; }; + passthru.tests = + { + test = tests.rust-hooks.cargoBuildHook; + } + // lib.optionalAttrs (stdenv.isLinux) { + testCross = pkgsCross.riscv64.tests.rust-hooks.cargoBuildHook; + }; } ./cargo-build-hook.sh ) { }; @@ -37,6 +45,13 @@ substitutions = { inherit (stdenv.targetPlatform.rust) rustcTarget; }; + passthru.tests = + { + test = tests.rust-hooks.cargoCheckHook; + } + // lib.optionalAttrs (stdenv.isLinux) { + testCross = pkgsCross.riscv64.tests.rust-hooks.cargoCheckHook; + }; } ./cargo-check-hook.sh ) { }; @@ -47,6 +62,13 @@ substitutions = { targetSubdirectory = target; }; + passthru.tests = + { + test = tests.rust-hooks.cargoInstallHook; + } + // lib.optionalAttrs (stdenv.isLinux) { + testCross = pkgsCross.riscv64.tests.rust-hooks.cargoInstallHook; + }; } ./cargo-install-hook.sh ) { }; @@ -58,6 +80,13 @@ substitutions = { inherit (stdenv.targetPlatform.rust) rustcTarget; }; + passthru.tests = + { + test = tests.rust-hooks.cargoNextestHook; + } + // lib.optionalAttrs (stdenv.isLinux) { + testCross = pkgsCross.riscv64.tests.rust-hooks.cargoNextestHook; + }; } ./cargo-nextest-hook.sh ) { }; @@ -86,6 +115,13 @@ }crt-static" ] ''; }; + passthru.tests = + { + test = tests.rust-hooks.cargoSetupHook; + } + // lib.optionalAttrs (stdenv.isLinux) { + testCross = pkgsCross.riscv64.tests.rust-hooks.cargoSetupHook; + }; } ./cargo-setup-hook.sh ) { }; diff --git a/pkgs/test/rust-hooks/default.nix b/pkgs/build-support/rust/hooks/test/default.nix similarity index 94% rename from pkgs/test/rust-hooks/default.nix rename to pkgs/build-support/rust/hooks/test/default.nix index edd2ee29e16d..774f0ee54860 100644 --- a/pkgs/test/rust-hooks/default.nix +++ b/pkgs/build-support/rust/hooks/test/default.nix @@ -11,7 +11,7 @@ */ cargoSetupHook = stdenv.mkDerivation { name = "test-cargoSetupHook"; - src = ./hello; + src = ./example-rust-project; cargoVendorDir = "hello"; nativeBuildInputs = [ rustPlatform.cargoSetupHook @@ -28,7 +28,7 @@ cargoBuildHook = stdenv.mkDerivation { name = "test-cargoBuildHook"; - src = ./hello; + src = ./example-rust-project; cargoBuildType = "release"; "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; @@ -44,7 +44,7 @@ cargoInstallHook = stdenv.mkDerivation { name = "test-cargoInstallHook"; - src = ./hello; + src = ./example-rust-project; cargoBuildType = "release"; "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; @@ -60,7 +60,7 @@ cargoCheckHook = stdenv.mkDerivation { name = "test-cargoCheckHook"; - src = ./hello; + src = ./example-rust-project; cargoBuildType = "release"; "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; @@ -82,7 +82,7 @@ cargoNextestHook = stdenv.mkDerivation { name = "test-cargoNextestHook"; - src = ./hello; + src = ./example-rust-project; cargoBuildType = "release"; "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; diff --git a/pkgs/test/rust-hooks/hello/Cargo.lock b/pkgs/build-support/rust/hooks/test/example-rust-project/Cargo.lock similarity index 100% rename from pkgs/test/rust-hooks/hello/Cargo.lock rename to pkgs/build-support/rust/hooks/test/example-rust-project/Cargo.lock diff --git a/pkgs/test/rust-hooks/hello/Cargo.toml b/pkgs/build-support/rust/hooks/test/example-rust-project/Cargo.toml similarity index 100% rename from pkgs/test/rust-hooks/hello/Cargo.toml rename to pkgs/build-support/rust/hooks/test/example-rust-project/Cargo.toml diff --git a/pkgs/test/rust-hooks/hello/src/hello.rs b/pkgs/build-support/rust/hooks/test/example-rust-project/src/hello.rs similarity index 100% rename from pkgs/test/rust-hooks/hello/src/hello.rs rename to pkgs/build-support/rust/hooks/test/example-rust-project/src/hello.rs diff --git a/pkgs/test/rust-hooks/hello/src/lib.rs b/pkgs/build-support/rust/hooks/test/example-rust-project/src/lib.rs similarity index 100% rename from pkgs/test/rust-hooks/hello/src/lib.rs rename to pkgs/build-support/rust/hooks/test/example-rust-project/src/lib.rs diff --git a/pkgs/test/rust-hooks/hello/src/main.rs b/pkgs/build-support/rust/hooks/test/example-rust-project/src/main.rs similarity index 100% rename from pkgs/test/rust-hooks/hello/src/main.rs rename to pkgs/build-support/rust/hooks/test/example-rust-project/src/main.rs diff --git a/pkgs/test/rust-hooks/hello/tests/my_test.rs b/pkgs/build-support/rust/hooks/test/example-rust-project/tests/my_test.rs similarity index 100% rename from pkgs/test/rust-hooks/hello/tests/my_test.rs rename to pkgs/build-support/rust/hooks/test/example-rust-project/tests/my_test.rs diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 7fc0943ba44e..dfeeef7fcf4f 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -211,5 +211,5 @@ with pkgs; build-environment-info = callPackage ./build-environment-info { }; - rust-hooks = recurseIntoAttrs (callPackages ./rust-hooks { }); + rust-hooks = recurseIntoAttrs (callPackages ../build-support/rust/hooks/test { }); }