Merge pull request #209371 from Artturin/gziprepro

gzip: make reproducible when GZIP_NO_TIMESTAMPS is set
This commit is contained in:
Artturi 2023-01-15 00:04:51 +02:00 committed by GitHub
commit f338f1422e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View file

@ -1525,6 +1525,10 @@ showPhaseFooter() {
genericBuild() {
# variable used by our gzip wrapper to add -n.
# gzip is in common-path.nix and is added to nix-shell but we only want to change its behaviour in nix builds. do not move to a setupHook in gzip.
export GZIP_NO_TIMESTAMPS=1
if [ -f "${buildCommandPath:-}" ]; then
source "$buildCommandPath"
return

View file

@ -1,7 +1,7 @@
{ lib, stdenv
, fetchurl
, makeWrapper
, xz
, writeText
}:
# Note: this package is used for bootstrapping fetchurl, and thus
@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
nativeBuildInputs = [ xz.bin ];
nativeBuildInputs = [ xz.bin makeWrapper ];
makeFlags = [
"SHELL=/bin/sh"
@ -40,12 +40,12 @@ stdenv.mkDerivation rec {
preFixup = ''
sed -i '1{;/#!\/bin\/sh/aPATH="'$out'/bin:$PATH"
}' $out/bin/*
'';
# set GZIP env variable to "-n" to stop gzip from adding timestamps
''
# run gzip with "-n" when $GZIP_NO_TIMESTAMPS (set by stdenv's setup.sh) is set to stop gzip from adding timestamps
# to archive headers: https://github.com/NixOS/nixpkgs/issues/86348
setupHook = writeText "setup-hook" ''
export GZIP="-n"
+ ''
wrapProgram $out/bin/gzip \
--add-flags "\''${GZIP_NO_TIMESTAMPS:+-n}"
'';
meta = {