summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ca/cargo-auditable/builder.nix
blob: 1f3034e511c6d2c4683f33f2676f44f596e3fc7a (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
{
  lib,
  stdenv,
  rustPlatform,
  fetchFromGitHub,
  installShellFiles,
  auditable-bootstrap,
}:
lib.extendMkDerivation {
  constructDrv = rustPlatform.buildRustPackage.override { cargo-auditable = auditable-bootstrap; };

  extendDrvArgs =
    finalAttrs:
    {
      pname ? "cargo-auditable",
      auditable ? true,
      hash ? "",
      cargoHash ? "",
      passthru ? { },
      ...
    }:
    {
      inherit auditable pname;

      __structuredAttrs = true;

      src = fetchFromGitHub {
        owner = "rust-secure-code";
        repo = "cargo-auditable";
        tag = "v${finalAttrs.version}";
        inherit hash;
      };

      nativeBuildInputs = [
        installShellFiles
      ];

      checkFlags = [
        # requires wasm32-unknown-unknown target
        "--skip=test_wasm"
        # Seems to be a bug in tests of locked vs. semver compatible packages
        # https://github.com/rust-secure-code/cargo-auditable/issues/235
        "--skip=test_proc_macro"
        "--skip=test_self_hosting"
        # Expects `linker = "rust-lld"` to work.
        "--skip=test_bare_linker"
      ];

      postInstall = ''
        installManPage cargo-auditable/cargo-auditable.1
      '';

      passthru = passthru // {
        bootstrap = auditable-bootstrap;
      };

      meta = {
        description = "Tool to make production Rust binaries auditable";
        mainProgram = "cargo-auditable";
        homepage = "https://github.com/rust-secure-code/cargo-auditable";
        changelog = "https://github.com/rust-secure-code/cargo-auditable/blob/v${finalAttrs.version}/cargo-auditable/CHANGELOG.md";
        license = with lib.licenses; [
          mit # or
          asl20
        ];
        maintainers = with lib.maintainers; [ RossSmyth ];
        broken = stdenv.hostPlatform != stdenv.buildPlatform;
      };
    };
}