lol
1{ lib, stdenv
2, fetchurl
3, xz
4, writeText
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.12";
15
16 src = fetchurl {
17 url = "mirror://gnu/gzip/${pname}-${version}.tar.xz";
18 sha256 = "sha256-zl4D5Rn2N+H4FAEazjXE+HszwLur7sNbr1+9NHnpGVY=";
19 };
20
21 outputs = [ "out" "man" "info" ];
22
23 enableParallelBuilding = true;
24
25 nativeBuildInputs = [ xz.bin ];
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
45 # set GZIP env variable to "-n" to stop gzip from adding timestamps
46 # to archive headers: https://github.com/NixOS/nixpkgs/issues/86348
47 setupHook = writeText "setup-hook" ''
48 export GZIP="-n"
49 '';
50
51 meta = {
52 homepage = "https://www.gnu.org/software/gzip/";
53 description = "GNU zip compression program";
54
55 longDescription =
56 ''gzip (GNU zip) is a popular data compression program written by
57 Jean-loup Gailly for the GNU project. Mark Adler wrote the
58 decompression part.
59
60 We developed this program as a replacement for compress because of
61 the Unisys and IBM patents covering the LZW algorithm used by
62 compress. These patents made it impossible for us to use compress,
63 and we needed a replacement. The superior compression ratio of gzip
64 is just a bonus.
65 '';
66
67 platforms = lib.platforms.all;
68
69 license = lib.licenses.gpl3Plus;
70 };
71}