mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-27 16:15:05 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
70 lines
1.7 KiB
Nix
70 lines
1.7 KiB
Nix
{ 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.hostPlatform.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.hostPlatform.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.hostPlatform.isDarwin;
|
||
doInstallCheck = true;
|
||
|
||
meta = with lib; {
|
||
description = "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 ];
|
||
};
|
||
}
|