1{
2 lib,
3 stdenv,
4 fetchurl,
5 updateAutotoolsGnuConfigScriptsHook,
6 xz,
7 coreutils ? null,
8}:
9
10# Note: this package is used for bootstrapping fetchurl, and thus
11# cannot use fetchpatch! All mutable patches (generated by GitHub or
12# cgit) that are needed here should be included directly in Nixpkgs as
13# files.
14
15stdenv.mkDerivation rec {
16 pname = "diffutils";
17 version = "3.12";
18
19 src = fetchurl {
20 url = "mirror://gnu/diffutils/diffutils-${version}.tar.xz";
21 hash = "sha256-fIt/n8hgkUH96pzs6FJJ0whiQ5H/Yd7a9Sj8szdyff0=";
22 };
23
24 outputs = [
25 "out"
26 "info"
27 ];
28
29 nativeBuildInputs = [
30 updateAutotoolsGnuConfigScriptsHook
31 (lib.getBin xz)
32 ];
33 # If no explicit coreutils is given, use the one from stdenv.
34 buildInputs = [ coreutils ];
35
36 # Disable stack-related gnulib tests on x86_64-darwin because they have problems running under
37 # Rosetta 2: test-c-stack hangs, test-sigsegv-catch-stackoverflow and test-sigaction fail.
38 postPatch =
39 if
40 ((stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) || (stdenv.hostPlatform.isAarch32))
41 then
42 ''
43 sed -i -E 's:[[:space:]]test-c-stack2?\.sh::g' gnulib-tests/Makefile.in
44 sed -i -E 's:[[:space:]]test-sigsegv-catch-stackoverflow[12]\$\(EXEEXT\)::g' gnulib-tests/Makefile.in
45 sed -i -E 's:[[:space:]]test-sigaction\$\(EXEEXT\)::g' gnulib-tests/Makefile.in
46 ''
47 else
48 null;
49
50 configureFlags =
51 # "pr" need not be on the PATH as a run-time dep, so we need to tell
52 # configure where it is. Covers the cross and native case alike.
53 lib.optional (coreutils != null) "PR_PROGRAM=${coreutils}/bin/pr"
54 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
55 "gl_cv_func_getopt_gnu=yes"
56 "gl_cv_func_strcasecmp_works=yes"
57 ];
58
59 # Test failure on QEMU only (#300550)
60 doCheck = !stdenv.buildPlatform.isRiscV64;
61
62 meta = with lib; {
63 homepage = "https://www.gnu.org/software/diffutils/diffutils.html";
64 description = "Commands for showing the differences between files (diff, cmp, etc.)";
65 license = licenses.gpl3;
66 platforms = platforms.unix;
67 maintainers = lib.teams.helsinki-systems.members;
68 };
69}