summaryrefslogtreecommitdiffstats
path: root/pkgs/development/compilers/rust/clippy-wrapper.nix
blob: 623463a23a97511bbb7852dc4b35ba0619ae8b36 (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
{
  lib,
  runCommand,
  clippy-unwrapped,
  rustc-unwrapped,
  makeWrapper,
}:

runCommand "${clippy-unwrapped.pname}-wrapper-${clippy-unwrapped.version}"
  {
    preferLocalBuild = true;
    strictDeps = true;
    inherit (clippy-unwrapped) outputs;

    nativeBuildInputs = [ makeWrapper ];

    meta = clippy-unwrapped.meta // {
      description = "${clippy-unwrapped.meta.description} (wrapper script)";
      priority = 10;
    };
  }

  ''
    mkdir -p $out/bin
    makeWrapper ${clippy-unwrapped}/bin/cargo-clippy $out/bin/cargo-clippy \
      --set-default SYSROOT ${rustc-unwrapped}

    makeWrapper ${clippy-unwrapped}/bin/clippy-driver $out/bin/clippy-driver \
      --set-default SYSROOT ${rustc-unwrapped}

    ${lib.concatMapStrings (output: "ln -s ${clippy-unwrapped.${output}} \$${output}\n") (
      lib.remove "out" clippy-unwrapped.outputs
    )}
  ''