at 17.09-beta 1.7 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.znapzend; 7in 8{ 9 options = { 10 services.znapzend = { 11 enable = mkEnableOption "ZnapZend daemon"; 12 13 logLevel = mkOption { 14 default = "debug"; 15 example = "warning"; 16 type = lib.types.enum ["debug" "info" "warning" "err" "alert"]; 17 description = "The log level when logging to file. Any of debug, info, warning, err, alert. Default in daemonized form is debug."; 18 }; 19 20 logTo = mkOption { 21 type = types.str; 22 default = "syslog::daemon"; 23 example = "/var/log/znapzend.log"; 24 description = "Where to log to (syslog::<facility> or <filepath>)."; 25 }; 26 27 noDestroy = mkOption { 28 type = types.bool; 29 default = false; 30 description = "Does all changes to the filesystem except destroy."; 31 }; 32 33 autoCreation = mkOption { 34 type = types.bool; 35 default = false; 36 description = "Automatically create the dataset on dest if it does not exists."; 37 }; 38 }; 39 }; 40 41 config = mkIf cfg.enable { 42 environment.systemPackages = [ pkgs.znapzend ]; 43 44 systemd.services = { 45 "znapzend" = { 46 description = "ZnapZend - ZFS Backup System"; 47 wantedBy = [ "zfs.target" ]; 48 after = [ "zfs.target" ]; 49 50 path = with pkgs; [ zfs mbuffer openssh ]; 51 52 serviceConfig = { 53 ExecStart = "${pkgs.znapzend}/bin/znapzend --logto=${cfg.logTo} --loglevel=${cfg.logLevel} ${optionalString cfg.noDestroy "--nodestroy"} ${optionalString cfg.autoCreation "--autoCreation"}"; 54 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 55 Restart = "on-failure"; 56 }; 57 }; 58 }; 59 }; 60}