6396c04d9f
Let's hope this doesn't break all over the place. Works here.
58 lines
1.6 KiB
Nix
58 lines
1.6 KiB
Nix
{ stdenv, fetchurl, runCommand, gcc, perl, zlib }:
|
|
|
|
let
|
|
# TODO: find out if there's harm in just using 'rec' instead.
|
|
name = "ccache-${version}";
|
|
version = "3.2.2";
|
|
sha256 = "1jm0qb3h5sypllaiyj81zp6m009vm50hzjnx994ril94kxlrj3ag";
|
|
doCheck = true;
|
|
|
|
ccache =
|
|
stdenv.mkDerivation {
|
|
inherit name doCheck;
|
|
src = fetchurl {
|
|
inherit sha256;
|
|
url = "mirror://samba/ccache/${name}.tar.xz";
|
|
};
|
|
|
|
# The test dependency on perl should be gone in the next release:
|
|
buildInputs = [ zlib ]
|
|
++ stdenv.lib.optionals doCheck [ perl ];
|
|
|
|
passthru = {
|
|
# A derivation that provides gcc and g++ commands, but that
|
|
# will end up calling ccache for the given cacheDir
|
|
links = extraConfig : (runCommand "ccache-links" { passthru.gcc = gcc; }
|
|
''
|
|
mkdir -p $out/bin
|
|
if [ -x "${gcc.cc}/bin/gcc" ]; then
|
|
cat > $out/bin/gcc << EOF
|
|
#!/bin/sh
|
|
${extraConfig}
|
|
exec ${ccache}/bin/ccache ${gcc.cc}/bin/gcc "\$@"
|
|
EOF
|
|
chmod +x $out/bin/gcc
|
|
fi
|
|
if [ -x "${gcc.cc}/bin/g++" ]; then
|
|
cat > $out/bin/g++ << EOF
|
|
#!/bin/sh
|
|
${extraConfig}
|
|
exec ${ccache}/bin/ccache ${gcc.cc}/bin/g++ "\$@"
|
|
EOF
|
|
chmod +x $out/bin/g++
|
|
fi
|
|
'');
|
|
};
|
|
|
|
meta = with stdenv.lib; {
|
|
inherit version;
|
|
description = "Compiler cache for fast recompilation of C/C++ code";
|
|
homepage = http://ccache.samba.org/;
|
|
downloadPage = https://ccache.samba.org/download.html;
|
|
license = with licenses; gpl3Plus;
|
|
maintainers = with maintainers; [ nckx ];
|
|
};
|
|
};
|
|
in
|
|
ccache
|