about summary refs log tree commit diff
path: root/nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix
blob: 92cb240c5f164c7cb638fb1c0141ca5929182f74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, tinycc
, gnumake
, gnugrep
, gawk
, sed
}:
let
  pname = "xz";
  # >=5.2 uses poll.h, unsupported by meslibc
  version = "5.0.8";

  src = fetchurl {
    url = "https://tukaani.org/xz/xz-${version}.tar.bz2";
    sha256 = "1nkb68dyrf16xwyqichcy1vhgbfg20dxz459rcsdx85h1gczk1i2";
  };
in
bash.runCommand "${pname}-${version}" {
  inherit pname version;

  nativeBuildInputs = [
    tinycc.compiler
    gnumake
    gnugrep
    gawk
    sed
  ];

  passthru.tests.get-version = result:
    bash.runCommand "${pname}-get-version-${version}" {} ''
      ${result}/bin/xz --version
      mkdir $out
    '';

  meta = with lib; {
    description = "A general-purpose data compression software, successor of LZMA";
    homepage = "https://tukaani.org/xz";
    license = with licenses; [ gpl2Plus lgpl21Plus ];
    maintainers = teams.minimal-bootstrap.members;
    platforms = platforms.unix;
  };
} ''
  # Unpack
  unbz2 --file ${src} --output xz.tar
  untar --file xz.tar
  rm xz.tar
  cd xz-${version}

  # Configure
  export CC="tcc -B ${tinycc.libs}/lib -include${./stubs.h}"
  export CPP="tcc -E"
  export LD=tcc
  export AR="tcc -ar"
  export SED=sed
  export ac_cv_prog_cc_c99=
  export ac_cv_header_fcntl_h=yes
  export ac_cv_header_limits_h=yes
  export ac_cv_header_sys_time_h=yes
  export ac_cv_func_utime=no
  bash ./configure \
    --prefix=$out \
    --build=${buildPlatform.config} \
    --host=${hostPlatform.config} \
    --disable-shared \
    --disable-nls \
    --disable-threads \
    --disable-assembler

  # Build
  make all

  # Install
  make install
''