1{
2 lib,
3 stdenv,
4 fetchurl,
5 autoreconfHook,
6 enableStatic ? stdenv.hostPlatform.isStatic,
7 writeScript,
8 testers,
9}:
10
11# Note: this package is used for bootstrapping fetchurl, and thus
12# cannot use fetchpatch! All mutable patches (generated by GitHub or
13# cgit) that are needed here should be included directly in Nixpkgs as
14# files.
15
16stdenv.mkDerivation (finalAttrs: {
17 pname = "xz";
18 version = "5.8.1";
19
20 src = fetchurl {
21 url =
22 with finalAttrs;
23 "https://github.com/tukaani-project/xz/releases/download/v${version}/xz-${version}.tar.xz";
24 hash = "sha256-C1T3nfhZElBN4LFK7Hlx4/lkSRrxgS2DRHAFgHUTzZ4=";
25 };
26
27 strictDeps = true;
28 outputs = [
29 "bin"
30 "dev"
31 "out"
32 "man"
33 "doc"
34 ];
35
36 configureFlags = lib.optional enableStatic "--disable-shared";
37
38 enableParallelBuilding = true;
39 doCheck = true;
40
41 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isOpenBSD [
42 autoreconfHook
43 ];
44
45 # this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion
46 # necessary for FreeBSD code path in configure
47 postPatch = ''
48 substituteInPlace ./build-aux/config.guess --replace-fail /usr/bin/uname uname
49 '';
50
51 preCheck = ''
52 # Tests have a /bin/sh dependency...
53 patchShebangs tests
54 '';
55
56 # In stdenv-linux, prevent a dependency on bootstrap-tools.
57 preConfigure = "CONFIG_SHELL=/bin/sh";
58
59 postInstall = "rm -rf $out/share/doc";
60
61 passthru = {
62 updateScript = writeScript "update-xz" ''
63 #!/usr/bin/env nix-shell
64 #!nix-shell -i bash -p curl pcre common-updater-scripts
65
66 set -eu -o pipefail
67
68 # Expect the text in format of '>xz-5.2.6.tar.xz</a>'
69 # We pick first match where a stable release goes first.
70 new_version="$(curl -s https://tukaani.org/xz/ |
71 pcregrep -o1 '>xz-([0-9.]+)[.]tar[.]xz</a>' |
72 head -n1)"
73 update-source-version ${finalAttrs.pname} "$new_version"
74 '';
75 tests.pkg-config = testers.hasPkgConfigModules {
76 package = finalAttrs.finalPackage;
77 };
78 };
79
80 meta = with lib; {
81 changelog = "https://github.com/tukaani-project/xz/releases/tag/v${finalAttrs.version}";
82 description = "General-purpose data compression software, successor of LZMA";
83 homepage = "https://tukaani.org/xz/";
84 longDescription = ''
85 XZ Utils is free general-purpose data compression software with high
86 compression ratio. XZ Utils were written for POSIX-like systems,
87 but also work on some not-so-POSIX systems. XZ Utils are the
88 successor to LZMA Utils.
89
90 The core of the XZ Utils compression code is based on LZMA SDK, but
91 it has been modified quite a lot to be suitable for XZ Utils. The
92 primary compression algorithm is currently LZMA2, which is used
93 inside the .xz container format. With typical files, XZ Utils
94 create 30 % smaller output than gzip and 15 % smaller output than
95 bzip2.
96 '';
97 license = with licenses; [
98 gpl2Plus
99 lgpl21Plus
100 ];
101 maintainers = with maintainers; [ sander ];
102 platforms = platforms.all;
103 pkgConfigModules = [ "liblzma" ];
104 };
105})