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 = "findutils";
16 version = "4.9.0";
17
18 src = fetchurl {
19 url = "mirror://gnu/findutils/findutils-${version}.tar.xz";
20 hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
21 };
22in
23bash.runCommand "${pname}-${version}" {
24 inherit pname version;
25
26 nativeBuildInputs = [
27 tinycc.compiler
28 gnumake
29 gnused
30 gnugrep
31 gawk
32 gnutar
33 xz
34 ];
35
36 passthru.tests.get-version = result:
37 bash.runCommand "${pname}-get-version-${version}" {} ''
38 ${result}/bin/find --version
39 mkdir $out
40 '';
41
42 meta = with lib; {
43 description = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
44 homepage = "https://www.gnu.org/software/findutils";
45 license = licenses.gpl3Plus;
46 maintainers = teams.minimal-bootstrap.members;
47 platforms = platforms.unix;
48 };
49} ''
50 # Unpack
51 cp ${src} findutils.tar.xz
52 unxz findutils.tar.xz
53 tar xf findutils.tar
54 rm findutils.tar
55 cd findutils-${version}
56
57 # Patch
58 # configure fails to accurately detect PATH_MAX support
59 sed -i 's/chdir_long/chdir/' gl/lib/save-cwd.c
60
61 # Configure
62 export CC="tcc -B ${tinycc.libs}/lib"
63 export AR="tcc -ar"
64 export LD=tcc
65 bash ./configure \
66 --prefix=$out \
67 --build=${buildPlatform.config} \
68 --host=${hostPlatform.config}
69
70 # Build
71 make -j $NIX_BUILD_CORES
72
73 # Install
74 make -j $NIX_BUILD_CORES install
75''