git.iko.soy/typeable/nixpkgs
on master help sign in
cachefilesd service: init
commit0842bc94e5c46e351b748638cf36a5b382921d5f authorNikolay Amiantov <ab@fmap.me> dateSun 16 Oct 2016, 19:56 (10 years ago) parent40547dd
2 files changed+60
nixos/modules/module-list.nix+1 nixos/modules/services/network-filesystems/cachefilesd.nix+59
nixos/modules/module-list.nix+1
@@ -312,6 +312,7 @@
312312 ./services/monitoring/uptime.nix
313313 ./services/monitoring/zabbix-agent.nix
314314 ./services/monitoring/zabbix-server.nix
315+ ./services/network-filesystems/cachefilesd.nix
315316 ./services/network-filesystems/drbd.nix
316317 ./services/network-filesystems/netatalk.nix
317318 ./services/network-filesystems/nfsd.nix
nixos/modules/services/network-filesystems/cachefilesd.nixnew file+59
@@ -0,0 +1,59 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+
7+ cfg = config.services.cachefilesd;
8+
9+ cfgFile = pkgs.writeText "cachefilesd.conf" ''
10+ dir ${cfg.cacheDir}
11+ ${cfg.extraConfig}
12+ '';
13+
14+in
15+
16+{
17+ options = {
18+ services.cachefilesd = {
19+
20+ enable = mkOption {
21+ type = types.bool;
22+ default = false;
23+ description = "Whether to enable cachefilesd network filesystems caching daemon.";
24+ };
25+
26+ cacheDir = mkOption {
27+ type = types.str;
28+ default = "/var/cache/fscache";
29+ description = "Directory to contain filesystem cache.";
30+ };
31+
32+ extraConfig = mkOption {
33+ type = types.lines;
34+ default = "";
35+ example = "brun 10%";
36+ description = "Additional configuration file entries. See cachefilesd.conf(5) for more information.";
37+ };
38+
39+ };
40+ };
41+
42+ ###### implementation
43+
44+ config = mkIf cfg.enable {
45+
46+ systemd.services.cachefilesd = {
47+ description = "Local network file caching management daemon";
48+ wantedBy = [ "multi-user.target" ];
49+ path = [ pkgs.kmod pkgs.cachefilesd ];
50+ script = ''
51+ modprobe -qab cachefiles
52+ mkdir -p ${cfg.cacheDir}
53+ chmod 700 ${cfg.cacheDir}
54+ exec cachefilesd -n -f ${cfgFile}
55+ '';
56+ };
57+
58+ };
59+}