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