1{
2 lib,
3 cacert,
4 curl,
5 rustPlatform,
6 fetchFromGitHub,
7 makeWrapper,
8 pkg-config,
9 openssl,
10 stdenv,
11 zig_0_13,
12 nix-update-script,
13}:
14
15rustPlatform.buildRustPackage rec {
16 pname = "cargo-lambda";
17 version = "1.8.6";
18
19 src = fetchFromGitHub {
20 owner = "cargo-lambda";
21 repo = "cargo-lambda";
22 tag = "v${version}";
23 hash = "sha256-ocFD2FK1nlEJ8xXhDSxpSKYU8oZk/QwfojveypVt1GU=";
24 };
25
26 cargoHash = "sha256-yE0pr7RZb015d51QtwVNfqXd8yEETvDdKJ5M7Oqc4Ds=";
27
28 nativeCheckInputs = [ cacert ];
29
30 nativeBuildInputs = [
31 makeWrapper
32 pkg-config
33 ];
34
35 buildInputs = [
36 openssl
37 ]
38 ++ lib.optionals stdenv.hostPlatform.isDarwin [
39 curl
40 ];
41
42 # Remove files that don't make builds reproducible:
43 # - Remove build.rs file that adds the build date to the version.
44 # - Remove cargo_lambda.rs that contains tests that reach the network.
45 postPatch = ''
46 rm crates/cargo-lambda-cli/build.rs
47 rm crates/cargo-lambda-cli/tests/cargo_lambda.rs
48 '';
49
50 postInstall = ''
51 wrapProgram $out/bin/cargo-lambda --prefix PATH : ${lib.makeBinPath [ zig_0_13 ]}
52 '';
53
54 CARGO_LAMBDA_BUILD_INFO = "(nixpkgs)";
55
56 cargoBuildFlags = [ "--features=skip-build-banner" ];
57 cargoCheckFlags = [ "--features=skip-build-banner" ];
58
59 checkFlags = lib.optionals stdenv.hostPlatform.isDarwin [
60 # Fails in darwin sandbox, first because of trying to listen to a port on
61 # localhost. While this would be fixed by `__darwinAllowLocalNetworking = true;`,
62 # they then fail with other I/O issues.
63 "--skip=test::test_download_example"
64 "--skip=test::test_download_example_with_cache"
65 ];
66
67 passthru.updateScript = nix-update-script { };
68
69 meta = {
70 description = "Cargo subcommand to help you work with AWS Lambda";
71 mainProgram = "cargo-lambda";
72 homepage = "https://cargo-lambda.info";
73 license = lib.licenses.mit;
74 maintainers = with lib.maintainers; [
75 taylor1791
76 calavera
77 matthiasbeyer
78 ];
79 };
80}