-
Notifications
You must be signed in to change notification settings - Fork 389
Expand file tree
/
Copy pathccache.nix
More file actions
54 lines (52 loc) · 1.36 KB
/
ccache.nix
File metadata and controls
54 lines (52 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ pkgs
, cc
, ccacheDir ? "/nix/var/cache/ccache"
, showNotice ? true
}:
let
noticeHook =
if showNotice then
pkgs.writeTextFile {
name = "ccache-notice-hook";
destination = "/nix-support/setup-hook";
text = ''
echo "====="
echo "ccache is enabled!"
echo "Disable with: --arg withCcache false"
echh ""
echo "It's recommended to run tests with ccache disabled to avoid cache incoherencies."
echo "====="
'';
}
else
null;
wrapper = pkgs.ccacheWrapper.override {
inherit cc;
extraConfig = ''
export CCACHE_DIR="${ccacheDir}"
if [ ! -d "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' does not exist"
echo " sudo mkdir -m0770 '$CCACHE_DIR'
echo "sudo chown root:nixbld '$CCACHE_DIR'"
echo ""
echo 'Alternatively, disable ccache with `--arg withCcache false`'
echo "====="
exit 1
fi
if [ ! -w "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' exists but isn't writable by $(whoami)"
echo "Please verify its access permissions"
echo "====="
exit 1
fi
export CCACHE_COMPRESS=1
export CCACHE_UMASK=007
export CCACHE_SLOPPINESS=random_seed
'';
};
in
{
inherit wrapper noticeHook;
}