@@ -0,0 +1,47 @@
1+{ lib
2+, rustPlatform
3+, fetchFromGitHub
4+, makeWrapper
5+
6+, cargo
7+, nix
8+, nix-prefetch-git
9+}:
10+
11+rustPlatform.buildRustPackage rec {
12+ pname = "crate2nix";
13+ version = "0.8.0";
14+
15+ src = fetchFromGitHub
16+ {
17+ owner = "kolloch";
18+ repo = pname;
19+ rev = version;
20+ sha256 = "sha256-pqg1BsEq3kGmUzt1zpQvXgdnRcIsiuIyvtUBi3VxtZ4=";
21+ } + "/crate2nix";
22+
23+ cargoSha256 = "sha256-dAMWrGNMleQ3lDbG46Hr4qvCyxR+QcPOUZw9r2/CxV4=";
24+
25+ nativeBuildInputs = [ makeWrapper ];
26+
27+ # Tests use nix(1), which tries (and fails) to set up /nix/var inside the
28+ # sandbox
29+ doCheck = false;
30+
31+ postFixup = ''
32+ wrapProgram $out/bin/crate2nix \
33+ --suffix PATH ":" ${lib.makeBinPath [ cargo nix nix-prefetch-git ]}
34+ '';
35+
36+ meta = with lib; {
37+ description = "A Nix build file generator for Rust crates.";
38+ longDescription = ''
39+ Crate2nix generates Nix files from Cargo.toml/lock files
40+ so that you can build every crate individually in a Nix sandbox.
41+ '';
42+ homepage = "https://github.com/kolloch/crate2nix";
43+ license = licenses.asl20;
44+ maintainers = with maintainers; [ kolloch andir cole-h ];
45+ platforms = platforms.all;
46+ };
47+}