summaryrefslogtreecommitdiffstats
path: root/maintainers/scripts/nixpkgs-lint.nix
blob: 4565d81a87064728a8e2252fec858041871c938c (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
{
  stdenv,
  lib,
  makeWrapper,
  perl,
  perlPackages,
}:

stdenv.mkDerivation {
  pname = "nixpkgs-lint";
  version = "1";

  __structuredAttrs = true;
  strictDeps = true;

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [
    perl
    perlPackages.XMLSimple
  ];

  dontUnpack = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp ${./nixpkgs-lint.pl} $out/bin/nixpkgs-lint
    # make the built version hermetic
    substituteInPlace  $out/bin/nixpkgs-lint \
      --replace-fail "#! /usr/bin/env nix-shell" "#! ${lib.getExe perl}"
    wrapProgram $out/bin/nixpkgs-lint --set PERL5LIB $PERL5LIB

    runHook postInstall
  '';

  meta = {
    description = "Utility for Nixpkgs contributors to check Nixpkgs for common errors";
    mainProgram = "nixpkgs-lint";
    platforms = lib.platforms.unix;
    license = lib.licenses.mit;
  };
}