1{ lib
2, buildPlatform
3, hostPlatform
4, fetchurl
5, bash
6, tinycc
7, gnumake
8, gnugrep
9, gnused
10, gawk
11, gnutar
12, xz
13}:
14let
15 pname = "diffutils";
16 # last version that can be built by tinycc-musl 0.9.27
17 version = "3.8";
18
19 src = fetchurl {
20 url = "mirror://gnu/diffutils/diffutils-${version}.tar.xz";
21 hash = "sha256-pr3X0bMSZtEcT03mwbdI1GB6sCMa9RiPwlM9CuJDj+w=";
22 };
23in
24bash.runCommand "${pname}-${version}" {
25 inherit pname version;
26
27 nativeBuildInputs = [
28 tinycc.compiler
29 gnumake
30 gnused
31 gnugrep
32 gawk
33 gnutar
34 xz
35 ];
36
37 passthru.tests.get-version = result:
38 bash.runCommand "${pname}-get-version-${version}" {} ''
39 ${result}/bin/diff --version
40 mkdir $out
41 '';
42
43 meta = with lib; {
44 description = "Commands for showing the differences between files (diff, cmp, etc.)";
45 homepage = "https://www.gnu.org/software/diffutils/diffutils.html";
46 license = licenses.gpl3Only;
47 maintainers = teams.minimal-bootstrap.members;
48 platforms = platforms.unix;
49 };
50} ''
51 # Unpack
52 cp ${src} diffutils.tar.xz
53 unxz diffutils.tar.xz
54 tar xf diffutils.tar
55 rm diffutils.tar
56 cd diffutils-${version}
57
58 # Configure
59 export CC="tcc -B ${tinycc.libs}/lib"
60 export LD=tcc
61 bash ./configure \
62 --prefix=$out \
63 --build=${buildPlatform.config} \
64 --host=${hostPlatform.config}
65
66 # Build
67 make -j $NIX_BUILD_CORES AR="tcc -ar"
68
69 # Install
70 make -j $NIX_BUILD_CORES install
71''