@@ -1,23 +1,64 @@
1−{ stdenv, fetchFromGitHub, asciidoc-full, gperf, perl, autoreconfHook, zlib, makeWrapper }:
1+{ lib
2+, stdenv
3+, fetchFromGitHub
4+, fetchpatch
5+, substituteAll
6+, binutils
7+, asciidoc
8+, cmake
9+, perl
10+, zstd
11+, xcodebuild
12+, makeWrapper
13+}:
214
315let ccache = stdenv.mkDerivation rec {
416 pname = "ccache";
5− version = "3.7.12";
17+ version = "4.0";
618
719 src = fetchFromGitHub {
8− owner = "ccache";
9− repo = "ccache";
20+ owner = pname;
21+ repo = pname;
1022 rev = "v${version}";
11− sha256 = "1xnv4g4n1jk1i98sa53k8w6q7hbwbw62svs30lssppysbrv8x3gz";
23+ sha256 = "1frcplrv61m2iwc6jwycpbcz1101xl6s4sh8p87prdj98l60lyrx";
1224 };
1325
14− nativeBuildInputs = [ asciidoc-full autoreconfHook gperf perl ];
26+ # TODO: Remove patches from upstream in next release
27+ patches = [
28+ # Fix badly named man page filename
29+ (fetchpatch {
30+ url = "https://github.com/ccache/ccache/commit/223e706fb24ce86eb0ad86079a97e6f345b9ef40.patch";
31+ sha256 = "1h7amp3ka45a79zwlxh8qnzx6n371gnfpfgijcqljps7skhl5gjg";
32+ })
33+ # Build and install man page by default
34+ (fetchpatch {
35+ url = "https://github.com/ccache/ccache/commit/294ff2face26448afa68e3ef7b68bf4898d6dc77.patch";
36+ sha256 = "0rx69qn41bgksc4m3p59nk5d6rz72rwnfska9mh5j62pzfm8axja";
37+ })
38+ # Fixes use of undeclared identifier 'CLONE_NOOWNERCOPY' on darwin
39+ (fetchpatch {
40+ url = "https://github.com/ccache/ccache/commit/411c010c3a5ee690cd42b23ffcf026ae009e2897.patch";
41+ sha256 = "062s424d0d0psp6wjhmfnfn1s5dsrz403hdid5drm6l2san0jhq0";
42+ })
43+ ] ++ lib.optional stdenv.isDarwin (substituteAll {
44+ src = ./force-objdump-on-darwin.patch;
45+ objdump = "${binutils.bintools}/bin/objdump";
46+ });
1547
16− buildInputs = [ zlib ];
48+ nativeBuildInputs = [ asciidoc cmake perl ];
49+
50+ buildInputs = [ zstd ];
1751
1852 outputs = [ "out" "man" ];
1953
20− doCheck = !stdenv.isDarwin;
54+ doCheck = true;
55+ checkInputs = lib.optional stdenv.isDarwin xcodebuild;
56+ checkPhase = ''
57+ export HOME=$(mktemp -d)
58+ ctest --output-on-failure ${lib.optionalString stdenv.isDarwin ''
59+ -E '^(test.nocpp2|test.modules)$'
60+ ''}
61+ '';
2162
2263 passthru = {
2364 # A derivation that provides gcc and g++ commands, but that
@@ -63,9 +104,10 @@ let ccache = stdenv.mkDerivation rec {
63104
64105 meta = with stdenv.lib; {
65106 description = "Compiler cache for fast recompilation of C/C++ code";
66− homepage = "https://ccache.dev/";
107+ homepage = "https://ccache.dev";
67108 downloadPage = "https://ccache.dev/download.html";
68109 license = licenses.gpl3Plus;
110+ maintainers = with maintainers; [ metadark r-burns ];
69111 platforms = platforms.unix;
70112 };
71113};