@@ -1,4 +1,4 @@
1−{ stdenv, fetchurl, fetchpatch, runCommand, gcc, zlib }:
1+{ stdenv, fetchurl, fetchpatch, runCommand, zlib }:
22
33let ccache = stdenv.mkDerivation rec {
44 name = "ccache-${version}";
@@ -15,43 +15,46 @@ let ccache = stdenv.mkDerivation rec {
1515 substituteInPlace Makefile.in --replace 'objs) $(extra_libs)' 'objs)'
1616 '';
1717
18− doCheck = true;
18+ doCheck = !stdenv.isDarwin;
1919
20− passthru = {
20+ passthru = let
21+ cc = stdenv.cc.cc;
22+ ccname = if stdenv.cc.cc.isClang or false then "clang" else "gcc";
23+ cxxname = if stdenv.cc.cc.isClang or false then "clang++" else "g++";
24+ in {
2125 # A derivation that provides gcc and g++ commands, but that
2226 # will end up calling ccache for the given cacheDir
2327 links = extraConfig: stdenv.mkDerivation rec {
2428 name = "ccache-links";
2529 passthru = {
26− inherit gcc;
27− isGNU = true;
30+ inherit (cc) isGNU isClang;
2831 };
29− inherit (gcc.cc) lib;
32+ inherit (cc) lib;
3033 buildCommand = ''
3134 mkdir -p $out/bin
32− if [ -x "${gcc.cc}/bin/gcc" ]; then
33− cat > $out/bin/gcc << EOF
35+ if [ -x "${cc}/bin/${ccname}" ]; then
36+ cat > $out/bin/${ccname} << EOF
3437 #!/bin/sh
3538 ${extraConfig}
36− exec ${ccache}/bin/ccache ${gcc.cc}/bin/gcc "\$@"
39+ exec ${ccache}/bin/ccache ${cc}/bin/${ccname} "\$@"
3740 EOF
38− chmod +x $out/bin/gcc
41+ chmod +x $out/bin/${ccname}
3942 fi
40− if [ -x "${gcc.cc}/bin/g++" ]; then
41− cat > $out/bin/g++ << EOF
43+ if [ -x "${cc}/bin/${cxxname}" ]; then
44+ cat > $out/bin/${cxxname} << EOF
4245 #!/bin/sh
4346 ${extraConfig}
44− exec ${ccache}/bin/ccache ${gcc.cc}/bin/g++ "\$@"
47+ exec ${ccache}/bin/ccache ${cc}/bin/${cxxname} "\$@"
4548 EOF
46− chmod +x $out/bin/g++
49+ chmod +x $out/bin/${cxxname}
4750 fi
48− for executable in $(ls ${gcc.cc}/bin); do
51+ for executable in $(ls ${cc}/bin); do
4952 if [ ! -x "$out/bin/$executable" ]; then
50− ln -s ${gcc.cc}/bin/$executable $out/bin/$executable
53+ ln -s ${cc}/bin/$executable $out/bin/$executable
5154 fi
5255 done
53− for file in $(ls ${gcc.cc} | grep -vw bin); do
54− ln -s ${gcc.cc}/$file $out/$file
56+ for file in $(ls ${cc} | grep -vw bin); do
57+ ln -s ${cc}/$file $out/$file
5558 done
5659 '';
5760 };
@@ -63,7 +66,7 @@ let ccache = stdenv.mkDerivation rec {
6366 downloadPage = https://ccache.samba.org/download.html;
6467 license = licenses.gpl3Plus;
6568 maintainers = with maintainers; [ nckx ];
66− platforms = with platforms; linux;
69+ platforms = platforms.unix;
6770 };
6871};
6972in ccache