about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/perl-modules/strip-nondeterminism/default.nix
blob: 31b3fad47b4562929c9ab5f2e04ea0fb688b9aa5 (plain) (blame)
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
{ lib
, stdenv
, file
, fetchFromGitLab
, buildPerlPackage
, ArchiveZip
, ArchiveCpio
, SubOverride
, shortenPerlShebang
}:

buildPerlPackage rec {
  pname = "strip-nondeterminism";
  version = "1.13.1";

  outputs = [ "out" "dev" ]; # no "devdoc"

  src = fetchFromGitLab {
    owner = "reproducible-builds";
    repo = "strip-nondeterminism";
    domain = "salsa.debian.org";
    rev = version;
    sha256 = "czx9UhdgTsQSfDNo1mMOXCM/3/nuNe+cPZeyy2xdnKs=";
  };

  strictDeps = true;
  nativeBuildInputs = lib.optionals stdenv.isDarwin [ shortenPerlShebang ];
  buildInputs = [
    ArchiveZip
    ArchiveCpio
    SubOverride
  ];

  postPatch = ''
    substituteInPlace lib/File/StripNondeterminism.pm \
      --replace "exec('file'" "exec('${lib.getExe file}'"
  '';


  postBuild = ''
    patchShebangs ./bin
  '';

  postInstall = ''
    # we don’t need the debhelper script
    rm $out/bin/dh_strip_nondeterminism
    rm $out/share/man/man1/dh_strip_nondeterminism.1
  '' + lib.optionalString stdenv.isDarwin ''
    shortenPerlShebang $out/bin/strip-nondeterminism
  '';

  installCheckPhase = ''
    runHook preInstallCheck
    ($out/bin/strip-nondeterminism --help 2>&1 | grep -q "verbose") || (echo "'$out/bin/strip-nondeterminism --help' failed" && exit 1)
    runHook postInstallCheck
  '';

  # running shortenPerlShebang in postBuild results in non-functioning binary 'exec format error'
  doCheck = !stdenv.isDarwin;
  doInstallCheck = true;

  meta = with lib; {
    description = "A Perl module for stripping bits of non-deterministic information";
    mainProgram = "strip-nondeterminism";
    homepage = "https://reproducible-builds.org/";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ pSub artturin ];
  };
}