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.10";
18
19 src = fetchurl {
20 url = "mirror://gnu/diffutils/diffutils-${version}.tar.xz";
21 hash = "sha256-kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4=";
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 fails.
38 postPatch =
39 if (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) then
40 ''
41 sed -i -E 's:test-c-stack2?\.sh::g' gnulib-tests/Makefile.in
42 sed -i -E 's:test-sigsegv-catch-stackoverflow[12]::g' gnulib-tests/Makefile.in
43 ''
44 else
45 null;
46
47 configureFlags =
48 # "pr" need not be on the PATH as a run-time dep, so we need to tell
49 # configure where it is. Covers the cross and native case alike.
50 lib.optional (coreutils != null) "PR_PROGRAM=${coreutils}/bin/pr"
51 ++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) "gl_cv_func_getopt_gnu=yes";
52
53 # Test failure on QEMU only (#300550)
54 doCheck = !stdenv.buildPlatform.isRiscV64;
55
56 meta = with lib; {
57 homepage = "https://www.gnu.org/software/diffutils/diffutils.html";
58 description = "Commands for showing the differences between files (diff, cmp, etc.)";
59 license = licenses.gpl3;
60 platforms = platforms.unix;
61 maintainers = with maintainers; [ das_j ];
62 };
63}