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