nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 rustPlatform,
3 stdenv,
4 cargo,
5}:
6{
7 /*
8 test each hook individually, to make sure that:
9 - each hook works properly outside of buildRustPackage
10 - each hook is usable independently from each other
11 */
12 cargoSetupHook = stdenv.mkDerivation {
13 name = "test-cargoSetupHook";
14 src = ./example-rust-project;
15 cargoVendorDir = "hello";
16 nativeBuildInputs = [
17 rustPlatform.cargoSetupHook
18 cargo
19 ];
20 buildPhase = ''
21 cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
22 '';
23 installPhase = ''
24 mkdir -p $out/bin
25 mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
26 '';
27 };
28
29 cargoBuildHook = stdenv.mkDerivation {
30 name = "test-cargoBuildHook";
31 src = ./example-rust-project;
32 cargoBuildType = "release";
33 "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
34 "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
35 nativeBuildInputs = [
36 rustPlatform.cargoBuildHook
37 cargo
38 ];
39 installPhase = ''
40 mkdir -p $out/bin
41 mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
42 '';
43 };
44
45 cargoInstallHook = stdenv.mkDerivation {
46 name = "test-cargoInstallHook";
47 src = ./example-rust-project;
48 cargoBuildType = "release";
49 "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
50 "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
51 nativeBuildInputs = [
52 rustPlatform.cargoInstallHook
53 cargo
54 ];
55 buildPhase = ''
56 cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
57 runHook postBuild
58 '';
59 };
60
61 cargoCheckHook = stdenv.mkDerivation {
62 name = "test-cargoCheckHook";
63 src = ./example-rust-project;
64 cargoBuildType = "release";
65 "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
66 "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
67 nativeBuildInputs = [
68 rustPlatform.cargoCheckHook
69 cargo
70 ];
71 buildPhase = ''
72 cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
73 runHook postBuild
74 '';
75 installPhase = ''
76 mkdir -p $out/bin
77 mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
78 '';
79 cargoCheckType = "release";
80 doCheck = true;
81 };
82
83 cargoNextestHook = stdenv.mkDerivation {
84 name = "test-cargoNextestHook";
85 src = ./example-rust-project;
86 cargoBuildType = "release";
87 "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
88 "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
89 nativeBuildInputs = [
90 rustPlatform.cargoNextestHook
91 cargo
92 ];
93 buildPhase = ''
94 cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
95 runHook postBuild
96 '';
97 installPhase = ''
98 mkdir -p $out/bin
99 mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
100 '';
101 cargoCheckType = "release";
102 doCheck = true;
103 };
104}