1{
2 lib,
3 stdenv,
4 fetchurl,
5 updateAutotoolsGnuConfigScriptsHook,
6 coreutils,
7}:
8
9# Note: this package is used for bootstrapping fetchurl, and thus
10# cannot use fetchpatch! All mutable patches (generated by GitHub or
11# cgit) that are needed here should be included directly in Nixpkgs as
12# files.
13
14stdenv.mkDerivation rec {
15 pname = "findutils";
16 version = "4.10.0";
17
18 src = fetchurl {
19 url = "mirror://gnu/findutils/findutils-${version}.tar.xz";
20 sha256 = "sha256-E4fgtn/yR9Kr3pmPkN+/cMFJE5Glnd/suK5ph4nwpPU=";
21 };
22
23 postPatch = ''
24 substituteInPlace xargs/xargs.c --replace 'char default_cmd[] = "echo";' 'char default_cmd[] = "${coreutils}/bin/echo";'
25 '';
26
27 patches = [ ./no-install-statedir.patch ];
28
29 nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ];
30 buildInputs = [ coreutils ]; # bin/updatedb script needs to call sort
31
32 # Since glibc-2.25 the i686 tests hang reliably right after test-sleep.
33 doCheck =
34 !stdenv.hostPlatform.isDarwin
35 && !stdenv.hostPlatform.isFreeBSD
36 && !(stdenv.hostPlatform.libc == "glibc" && stdenv.hostPlatform.isi686)
37 && (stdenv.hostPlatform.libc != "musl")
38 && stdenv.hostPlatform == stdenv.buildPlatform;
39
40 outputs = [
41 "out"
42 "info"
43 "locate"
44 ];
45
46 configureFlags = [
47 # "sort" need not be on the PATH as a run-time dep, so we need to tell
48 # configure where it is. Covers the cross and native case alike.
49 "SORT=${coreutils}/bin/sort"
50 "--localstatedir=/var/cache"
51 ];
52
53 CFLAGS = lib.optionals stdenv.hostPlatform.isDarwin [
54 # TODO: Revisit upstream issue https://savannah.gnu.org/bugs/?59972
55 # https://github.com/Homebrew/homebrew-core/pull/69761#issuecomment-770268478
56 "-D__nonnull\\(params\\)="
57 ];
58
59 postInstall = ''
60 moveToOutput bin/locate $locate
61 moveToOutput bin/updatedb $locate
62 '';
63
64 # can't move man pages in postInstall because the multi-output hook will move them back to $out
65 postFixup = ''
66 moveToOutput share/man/man5 $locate
67 moveToOutput share/man/man1/locate.1.gz $locate
68 moveToOutput share/man/man1/updatedb.1.gz $locate
69 '';
70
71 enableParallelBuilding = true;
72
73 # bionic libc is super weird and has issues with fortify outside of its own libc, check this comment:
74 # https://github.com/NixOS/nixpkgs/pull/192630#discussion_r978985593
75 # or you can check libc/include/sys/cdefs.h in bionic source code
76 hardeningDisable = lib.optional (stdenv.hostPlatform.libc == "bionic") "fortify";
77
78 meta = {
79 homepage = "https://www.gnu.org/software/findutils/";
80 description = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
81
82 longDescription = ''
83 The GNU Find Utilities are the basic directory searching
84 utilities of the GNU operating system. These programs are
85 typically used in conjunction with other programs to provide
86 modular and powerful directory search and file locating
87 capabilities to other commands.
88
89 The tools supplied with this package are:
90
91 * find - search for files in a directory hierarchy;
92 * xargs - build and execute command lines from standard input.
93
94 The following are available in the locate output:
95
96 * locate - list files in databases that match a pattern;
97 * updatedb - update a file name database;
98 '';
99
100 platforms = lib.platforms.all;
101
102 license = lib.licenses.gpl3Plus;
103
104 mainProgram = "find";
105 };
106}