Provides an entry point that builds and returns a combined LH + RH keyboard firmware when provided a keymap via a POST body. Wraps compilation with ccache, and includes a pre-warmed cache of the build in /tmp/ccache. To maximize chance of a direct cache hit, changes the lambda driver to always build in /tmp/build. some back of the envelope measurements (2012 xeon e3-1230v2, nixos) clean build, no cache -> 21.308 clean build, cache -> 7.145 modified keymap, clean build, cache -> 12.127
43 lines
1.2 KiB
Nix
43 lines
1.2 KiB
Nix
{ stdenv, lib, makeWrapper, ccache
|
|
, unwrappedCC ? stdenv.cc.cc, extraConfig ? "" }:
|
|
|
|
# copied from ccache in nixpkgs, modified to glob over prefixes. Also doesn't
|
|
# pass lib. Why was it passing lib?
|
|
stdenv.mkDerivation {
|
|
name = "ccache-links";
|
|
passthru = {
|
|
isClang = unwrappedCC.isClang or false;
|
|
isGNU = unwrappedCC.isGNU or false;
|
|
};
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
buildCommand = ''
|
|
mkdir -p $out/bin
|
|
|
|
wrap() {
|
|
local cname="$(basename $1)"
|
|
if [ -x "${unwrappedCC}/bin/$cname" ]; then
|
|
echo "Wrapping $1"
|
|
makeWrapper ${ccache}/bin/ccache $out/bin/$cname \
|
|
--run ${lib.escapeShellArg extraConfig} \
|
|
--add-flags ${unwrappedCC}/bin/$cname
|
|
fi
|
|
}
|
|
|
|
wrapAll() {
|
|
for prog in "$@"; do
|
|
wrap "$prog"
|
|
done
|
|
}
|
|
|
|
wrapAll ${unwrappedCC}/bin/{*cc,*c++,*gcc,*g++,*clang,*clang++}
|
|
|
|
for executable in $(ls ${unwrappedCC}/bin); do
|
|
if [ ! -x "$out/bin/$executable" ]; then
|
|
ln -s ${unwrappedCC}/bin/$executable $out/bin/$executable
|
|
fi
|
|
done
|
|
for file in $(ls ${unwrappedCC} | grep -vw bin); do
|
|
ln -s ${unwrappedCC}/$file $out/$file
|
|
done
|
|
'';
|
|
}
|