@@ -0,0 +1,54 @@
1+{ lib
2+, stdenv
3+, fetchFromGitHub
4+, cmake
5+, rustPlatform
6+}:
7+
8+stdenv.mkDerivation rec {
9+ pname = "corrosion";
10+ version = "unstable-2021-02-23";
11+
12+ src = fetchFromGitHub {
13+ owner = "AndrewGaspar";
14+ repo = "corrosion";
15+ rev = "e6c35c7e55a59c8223577b5abc4d253b4a82898b";
16+ sha256 = "0vq6g3ggnqiln0q8gsr8rr5rrdgpfcgfly79jwcygxrviw37m44d";
17+ };
18+
19+ patches = [
20+ # https://github.com/AndrewGaspar/corrosion/issues/84
21+ ./cmake-install-full-dir.patch
22+ ];
23+
24+ cargoRoot = "generator";
25+
26+ cargoDeps = rustPlatform.fetchCargoTarball {
27+ inherit src;
28+ sourceRoot = "${src.name}/${cargoRoot}";
29+ name = "${pname}-${version}";
30+ sha256 = "1fsq8zzzq28fj2fh92wmg8kmdj4y10mcpdmlgxsygy5lbh4xs13f";
31+ };
32+
33+ nativeBuildInputs = [
34+ cmake
35+ ] ++ (with rustPlatform; [
36+ cargoSetupHook
37+ rust.cargo
38+ rust.rustc
39+ ]);
40+
41+ cmakeFlags = [
42+ "-DRust_CARGO=${rustPlatform.rust.cargo}/bin/cargo"
43+
44+ # tests cannot find cargo because Rust_CARGO is unset before tests
45+ "-DCORROSION_BUILD_TESTS=OFF"
46+ ];
47+
48+ meta = with lib; {
49+ description = "Tool for integrating Rust into an existing CMake project";
50+ homepage = "https://github.com/AndrewGaspar/corrosion";
51+ license = licenses.mit;
52+ maintainers = with maintainers; [ dotlambda ];
53+ };
54+}