lol
1{ lib
2, rustPlatform
3, fetchFromGitHub
4, pkg-config
5, libgit2
6, openssl
7, stdenv
8, Security
9}:
10
11rustPlatform.buildRustPackage rec {
12 pname = "cargo-generate";
13 version = "0.17.3";
14
15 src = fetchFromGitHub {
16 owner = "cargo-generate";
17 repo = "cargo-generate";
18 rev = "v${version}";
19 sha256 = "sha256-7F6Pqq/iFmI3JzDKoMmSyVm6BUr+Ev9GPidOofcLNV4=";
20 };
21
22 # patch Cargo.toml to not vendor libgit2 and openssl
23 cargoPatches = [ ./no-vendor.patch ];
24
25 cargoSha256 = "sha256-kC8BGobS1iMq+vIwE24Lip+HGdVnA/NjHFAb6cqOz44=";
26
27 nativeBuildInputs = [ pkg-config ];
28
29 buildInputs = [ libgit2 openssl ]
30 ++ lib.optionals stdenv.isDarwin [ Security ];
31
32 preCheck = ''
33 export HOME=$(mktemp -d) USER=nixbld
34 git config --global user.name Nixbld
35 git config --global user.email nixbld@localhost.localnet
36 '';
37
38 # Exclude some tests that don't work in sandbox:
39 # - favorites_default_to_git_if_not_defined: requires network access to github.com
40 # - should_canonicalize: the test assumes that it will be called from the /Users/<project_dir>/ folder on darwin variant.
41 checkFlags = [
42 "--skip=favorites::favorites_default_to_git_if_not_defined"
43 ] ++ lib.optionals stdenv.isDarwin [
44 "--skip=git::utils::should_canonicalize"
45 ];
46
47 meta = with lib; {
48 description = "A tool to generaet a new Rust project by leveraging a pre-existing git repository as a template";
49 homepage = "https://github.com/cargo-generate/cargo-generate";
50 changelog = "https://github.com/cargo-generate/cargo-generate/blob/v${version}/CHANGELOG.md";
51 license = with licenses; [ asl20 /* or */ mit ];
52 maintainers = with maintainers; [ figsoda turbomack ];
53 };
54}