summaryrefslogtreecommitdiffstats
path: root/pkgs/development/compilers/rust/cargo-auditable-cargo-wrapper.nix
blob: 420b3bc8205262da73729d3d652bd325aaa4245e (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
{
  lib,
  runCommand,
  makeBinaryWrapper,
  rust-audit-info,
  cargo,
  cargo-auditable,
}:

if cargo-auditable.meta.broken then
  cargo
else
  runCommand "auditable-${cargo.name}"
    {
      nativeBuildInputs = [ makeBinaryWrapper ];

      passthru.tests =
        runCommand "rust-audit-info-test"
          {
            nativeBuildInputs = [ rust-audit-info ];
          }
          ''
            rust-audit-info ${lib.getBin rust-audit-info}/bin/rust-audit-info > $out
          '';

      meta = cargo-auditable.meta // {
        mainProgram = "cargo";
      };
    }
    ''
      mkdir -p $out/bin
      makeWrapper ${cargo}/bin/cargo $out/bin/cargo \
        --set CARGO_AUDITABLE_IGNORE_UNSUPPORTED 1 \
        --prefix PATH : ${
          lib.makeBinPath [
            cargo
            cargo-auditable
          ]
        } \
        --add-flags auditable
    ''