]>
Commit | Line | Data |
---|---|---|
5dda316b IB |
1 | { config, lib, pkgs, ... }: |
2 | let | |
3 | cfg = config.services.zrepl; | |
4 | in | |
5 | { | |
6 | options = { | |
7 | services.zrepl = { | |
8 | enable = lib.mkEnableOption "Enable the zrepl daemon"; | |
9 | ||
10 | config = lib.mkOption { | |
11 | type = lib.types.lines; | |
12 | default = ""; | |
13 | description = "Configuration"; | |
14 | }; | |
15 | }; | |
16 | }; | |
17 | ||
18 | config = lib.mkIf cfg.enable { | |
4c4652aa IB |
19 | secrets.keys = { |
20 | "zrepl/zrepl.yml" = { | |
5dda316b IB |
21 | permissions = "0400"; |
22 | text = cfg.config; | |
23 | user = config.systemd.services.zrepl.serviceConfig.User or "root"; | |
24 | group = config.systemd.services.zrepl.serviceConfig.Group or "root"; | |
4c4652aa IB |
25 | }; |
26 | }; | |
5dda316b IB |
27 | services.filesWatcher.zrepl = { |
28 | restart = true; | |
29 | paths = [ config.secrets.fullPaths."zrepl/zrepl.yml" ]; | |
30 | }; | |
31 | systemd.services.zrepl = { | |
32 | description = "zrepl daemon"; | |
33 | wantedBy = [ "multi-user.target" ]; | |
34 | path = [ pkgs.zfs pkgs.openssh ]; | |
35 | serviceConfig = { | |
36 | ExecStart = | |
37 | let configFile = config.secrets.fullPaths."zrepl/zrepl.yml"; | |
38 | in "${pkgs.zrepl}/bin/zrepl daemon --config ${configFile}"; | |
39 | Type = "simple"; | |
40 | RuntimeDirectory= "zrepl"; | |
41 | RuntimeDirectoryMode= "0700"; | |
42 | }; | |
43 | }; | |
44 | }; | |
45 | } |