forked from tomasharkema/x1p42100-nixos
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathccache.nix
More file actions
98 lines (88 loc) · 2.31 KB
/
ccache.nix
File metadata and controls
98 lines (88 loc) · 2.31 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
config,
lib,
pkgs,
...
}: let
remoteDir = "/mnt/ccache";
ccacheOptions = {
INODECACHE = "true";
COMPRESS = "true";
DIR = "${config.programs.ccache.cacheDir}";
UMASK = "002";
MAXSIZE = "20GB";
RESHARE = "true";
REMOTE_STORAGE = "file://${remoteDir}";
};
withCcachePrefix = lib.mapAttrs' (name: value: lib.nameValuePair ("CCACHE_" + name) value) ccacheOptions;
exportVariablesList =
lib.mapAttrsToList (
n: v: ''export ${n}="${v}"''
)
withCcachePrefix;
exportVariables = lib.concatStringsSep "\n" exportVariablesList;
in {
config = {
nixpkgs.overlays = [
(self: super: {
ccacheWrapper = super.ccacheWrapper.override {
extraConfig = builtins.trace "\n\n====\n\n${exportVariables}\n\n====\n\n" ''
${exportVariables}
if [ ! -d "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' does not exist"
echo "Please create it with:"
echo " sudo mkdir -m0777 '$CCACHE_DIR'"
echo " sudo chown root:nixbld '$CCACHE_DIR'"
echo "====="
exit 1
fi
if [ ! -w "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
echo "Please verify its access permissions"
echo "====="
exit 1
fi
'';
};
})
];
environment = {
systemPackages = [pkgs.ccache];
variables = withCcachePrefix;
etc."ccache.conf".text = ''
max_size = 20G
cache_dir = "${ccacheOptions.DIR}"
compression = true
reshare = true
umask = 002
inode_cache = true
remote_storage = "${ccacheOptions.REMOTE_STORAGE}"
'';
};
nix.settings.extra-sandbox-paths = [
config.programs.ccache.cacheDir
remoteDir
];
fileSystems = {
"${remoteDir}" = {
device = "192.168.1.100:/export/ccache";
fsType = "nfs";
options = [
"x-systemd.automount"
"noauto"
"x-systemd.idle-timeout=600"
"fsc"
];
};
};
programs.ccache = {
enable = true;
packageNames = [
"sssd"
"freeipa"
];
};
};
}