summary refs log tree commit diff
path: root/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix
blob: 05da061ac263d8ad4a60d8e50407150016e30210 (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
{ lib
, fetchurl
, bash
, tinycc
, gnumake
, gnutar
, gzip
}:
let
  pname = "bzip2";
  version = "1.0.8";

  src = fetchurl {
    url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
    sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
  };
in
bash.runCommand "${pname}-${version}" {
  inherit pname version;

  nativeBuildInputs = [
    tinycc.compiler
    gnumake
    gnutar
    gzip
  ];

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

  meta = with lib; {
    description = "High-quality data compression program";
    homepage = "https://www.sourceware.org/bzip2";
    license = licenses.bsdOriginal;
    maintainers = teams.minimal-bootstrap.members;
    platforms = platforms.unix;
  };
} ''
  # Unpack
  tar xzf ${src}
  cd bzip2-${version}

  # Build
  make \
    -j $NIX_BUILD_CORES \
    CC="tcc -B ${tinycc.libs}/lib" \
    AR="tcc -ar" \
    bzip2 bzip2recover

  # Install
  make install -j $NIX_BUILD_CORES PREFIX=$out
''