1{
2 lib,
3 stdenv,
4 fetchurl,
5 makeShellWrapper,
6 updateAutotoolsGnuConfigScriptsHook,
7 runtimeShellPackage,
8}:
9
10# Note: this package is used for bootstrapping fetchurl, and thus
11# cannot use fetchpatch! All mutable patches (generated by GitHub or
12# cgit) that are needed here should be included directly in Nixpkgs as
13# files.
14
15stdenv.mkDerivation rec {
16 pname = "gzip";
17 version = "1.14";
18
19 src = fetchurl {
20 url = "mirror://gnu/gzip/${pname}-${version}.tar.xz";
21 hash = "sha256-Aae4gb0iC/32Ffl7hxj4C9/T9q3ThbmT3Pbv0U6MCsY=";
22 };
23
24 outputs = [
25 "out"
26 "man"
27 "info"
28 ];
29
30 enableParallelBuilding = true;
31
32 nativeBuildInputs = [
33 updateAutotoolsGnuConfigScriptsHook
34 makeShellWrapper
35 ];
36 buildInputs = [ runtimeShellPackage ];
37
38 makeFlags = [
39 "SHELL=/bin/sh"
40 "GREP=grep"
41 # gzip 1.12 doesn't build `zless` unless it can find `less`, but we
42 # can avoid having `less` as a build input if we just override these.
43 "ZLESS_MAN=zless.1"
44 "ZLESS_PROG=zless"
45 ];
46
47 # Many gzip executables are shell scripts that depend upon other gzip
48 # executables being in $PATH. Rather than try to re-write all the
49 # internal cross-references, just add $out/bin to PATH at the top of
50 # all the executables that are shell scripts.
51 preFixup = ''
52 sed -i '1{;/#!\/bin\/sh/aPATH="'$out'/bin:$PATH"
53 }' $out/bin/*
54 ''
55 # run gzip with "-n" when $GZIP_NO_TIMESTAMPS (set by stdenv's setup.sh) is set to stop gzip from adding timestamps
56 # to archive headers: https://github.com/NixOS/nixpkgs/issues/86348
57 # if changing so that there's no longer a .gzip-wrapped then update copy in make-bootstrap-tools.nix
58 + ''
59 wrapProgram $out/bin/gzip \
60 --add-flags "\''${GZIP_NO_TIMESTAMPS:+-n}"
61 '';
62
63 meta = {
64 homepage = "https://www.gnu.org/software/gzip/";
65 description = "GNU zip compression program";
66
67 longDescription = ''
68 gzip (GNU zip) is a popular data compression program written by
69 Jean-loup Gailly for the GNU project. Mark Adler wrote the
70 decompression part.
71
72 We developed this program as a replacement for compress because of
73 the Unisys and IBM patents covering the LZW algorithm used by
74 compress. These patents made it impossible for us to use compress,
75 and we needed a replacement. The superior compression ratio of gzip
76 is just a bonus.
77 '';
78
79 platforms = lib.platforms.all;
80
81 license = lib.licenses.gpl3Plus;
82
83 mainProgram = "gzip";
84 };
85}