summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ca/cargo-lambda/package.nix
blob: a71ef9ced3a4c5316b21dfa72c58738ceb346e01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
  lib,
  cacert,
  curl,
  rustPlatform,
  fetchFromGitHub,
  makeWrapper,
  pkg-config,
  openssl,
  stdenv,
  zig,
  nix-update-script,
}:

rustPlatform.buildRustPackage (finalAttrs: {
  pname = "cargo-lambda";
  version = "1.9.2";

  src = fetchFromGitHub {
    owner = "cargo-lambda";
    repo = "cargo-lambda";
    tag = "v${finalAttrs.version}";
    hash = "sha256-WF/s+bSwFG94ooFNBmbZVXCrCzDFxWDBQ7QMXUrcCzg=";
  };

  cargoHash = "sha256-vJBviHdHMtff7QA7xW2D7rX7UYtaYFnW2zB6wvvEtOU=";

  nativeCheckInputs = [ cacert ];

  nativeBuildInputs = [
    makeWrapper
    pkg-config
  ];

  buildInputs = [
    openssl
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    curl
  ];

  # Remove files that don't make builds reproducible:
  # - Remove build.rs file that adds the build date to the version.
  # - Remove cargo_lambda.rs that contains tests that reach the network.
  postPatch = ''
    rm crates/cargo-lambda-cli/build.rs
    rm crates/cargo-lambda-cli/tests/cargo_lambda.rs
  '';

  postInstall = ''
    wrapProgram $out/bin/cargo-lambda --prefix PATH : ${lib.makeBinPath [ zig ]}
  '';

  env.CARGO_LAMBDA_BUILD_INFO = "(nixpkgs)";

  cargoBuildFlags = [ "--features=skip-build-banner" ];
  cargoCheckFlags = [ "--features=skip-build-banner" ];

  checkFlags = lib.optionals stdenv.hostPlatform.isDarwin [
    # Fails in darwin sandbox, first because of trying to listen to a port on
    # localhost. While this would be fixed by `__darwinAllowLocalNetworking = true;`,
    # they then fail with other I/O issues.
    "--skip=test::test_download_example"
    "--skip=test::test_download_example_with_cache"
  ];

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Cargo subcommand to help you work with AWS Lambda";
    mainProgram = "cargo-lambda";
    homepage = "https://cargo-lambda.info";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      taylor1791
      calavera
      matthiasbeyer
    ];
  };
})