1 { config, pkgs, lib, ... }:
3 cfg = config.services.zrepl;
4 format = pkgs.formats.yaml { };
5 configFile = format.generate "zrepl.yml" cfg.settings;
8 meta.maintainers = with lib.maintainers; [ cole-h ];
12 enable = lib.mkEnableOption "zrepl";
14 package = lib.mkPackageOption pkgs "zrepl" { };
16 settings = lib.mkOption {
19 Configuration for zrepl. See <https://zrepl.github.io/configuration.html>
22 type = lib.types.submodule {
23 freeformType = format.type;
29 ### Implementation ###
31 config = lib.mkIf cfg.enable {
32 environment.systemPackages = [ cfg.package ];
34 # zrepl looks for its config in this location by default. This
35 # allows the use of e.g. `zrepl signal wakeup <job>` without having
36 # to specify the storepath of the config.
37 environment.etc."zrepl/zrepl.yml".source = configFile;
39 systemd.packages = [ cfg.package ];
41 # Note that pkgs.zrepl copies and adapts the upstream systemd unit, and
42 # the fields defined here only override certain fields from that unit.
43 systemd.services.zrepl = {
44 requires = [ "local-fs.target" ];
45 wantedBy = [ "zfs.target" ];
46 after = [ "zfs.target" ];
48 path = [ config.boot.zfs.package ];
49 restartTriggers = [ configFile ];
52 Restart = "on-failure";