summary refs log tree commit diff
path: root/pkgs/os-specific/linux/minimal-bootstrap/diffutils/default.nix
blob: 7545a52524a30121ec43ec658d3792786c935110 (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
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, gcc
, glibc
, binutils
, linux-headers
, gnumake
, gnugrep
, gnused
, gawk
, gnutar
, gzip
}:
let
  pname = "diffutils";
  version = "2.8.1";

  src = fetchurl {
    url = "mirror://gnu/diffutils/diffutils-${version}.tar.gz";
    sha256 = "0nizs9r76aiymzasmj1jngl7s71jfzl9xfziigcls8k9n141f065";
  };
in
bash.runCommand "${pname}-${version}" {
  inherit pname version;

  nativeBuildInputs = [
    gcc
    binutils
    gnumake
    gnused
    gnugrep
    gawk
    gnutar
    gzip
  ];

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

  meta = with lib; {
    description = "Commands for showing the differences between files (diff, cmp, etc.)";
    homepage = "https://www.gnu.org/software/diffutils/diffutils.html";
    license = licenses.gpl3Only;
    maintainers = teams.minimal-bootstrap.members;
    platforms = platforms.unix;
  };
} ''
  # Unpack
  tar xzf ${src}
  cd diffutils-${version}

  # Configure
  export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include"
  export LIBRARY_PATH="${glibc}/lib"
  export LIBS="-lc -lnss_files -lnss_dns -lresolv"
  bash ./configure \
    --prefix=$out \
    --build=${buildPlatform.config} \
    --host=${hostPlatform.config}

  # Build
  make

  # Install
  make install
''