2016-03-24 09:52:13 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2017-12-20 23:40:36 +00:00
|
|
|
with types;
|
2016-03-24 09:52:13 +00:00
|
|
|
|
|
|
|
let
|
2017-12-20 23:40:36 +00:00
|
|
|
|
|
|
|
planDescription = ''
|
|
|
|
The znapzend backup plan to use for the source.
|
2019-05-13 07:15:17 +00:00
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
The plan specifies how often to backup and for how long to keep the
|
|
|
|
backups. It consists of a series of retention periodes to interval
|
|
|
|
associations:
|
2019-05-13 07:15:17 +00:00
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
<literal>
|
|
|
|
retA=>intA,retB=>intB,...
|
|
|
|
</literal>
|
2019-05-13 07:15:17 +00:00
|
|
|
|
|
|
|
Both intervals and retention periods are expressed in standard units
|
|
|
|
of time or multiples of them. You can use both the full name or a
|
|
|
|
shortcut according to the following listing:
|
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
<literal>
|
|
|
|
second|sec|s, minute|min, hour|h, day|d, week|w, month|mon|m, year|y
|
|
|
|
</literal>
|
2019-05-13 07:15:17 +00:00
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
See <citerefentry><refentrytitle>znapzendzetup</refentrytitle><manvolnum>1</manvolnum></citerefentry> for more info.
|
|
|
|
'';
|
|
|
|
planExample = "1h=>10min,1d=>1h,1w=>1d,1m=>1w,1y=>1m";
|
|
|
|
|
|
|
|
# A type for a string of the form number{b|k|M|G}
|
|
|
|
mbufferSizeType = str // {
|
|
|
|
check = x: str.check x && builtins.isList (builtins.match "^[0-9]+[bkMG]$" x);
|
|
|
|
description = "string of the form number{b|k|M|G}";
|
|
|
|
};
|
|
|
|
|
2019-10-27 11:06:18 +00:00
|
|
|
enabledFeatures = concatLists (mapAttrsToList (name: enabled: optional enabled name) cfg.features);
|
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
# Type for a string that must contain certain other strings (the list parameter).
|
|
|
|
# Note that these would need regex escaping.
|
|
|
|
stringContainingStrings = list: let
|
|
|
|
matching = s: map (str: builtins.match ".*${str}.*" s) list;
|
|
|
|
in str // {
|
|
|
|
check = x: str.check x && all isList (matching x);
|
|
|
|
description = "string containing all of the characters ${concatStringsSep ", " list}";
|
|
|
|
};
|
|
|
|
|
|
|
|
timestampType = stringContainingStrings [ "%Y" "%m" "%d" "%H" "%M" "%S" ];
|
|
|
|
|
|
|
|
destType = srcConfig: submodule ({ name, ... }: {
|
|
|
|
options = {
|
|
|
|
|
|
|
|
label = mkOption {
|
|
|
|
type = str;
|
|
|
|
description = "Label for this destination. Defaults to the attribute name.";
|
|
|
|
};
|
|
|
|
|
|
|
|
plan = mkOption {
|
|
|
|
type = str;
|
|
|
|
description = planDescription;
|
|
|
|
example = planExample;
|
|
|
|
};
|
|
|
|
|
|
|
|
dataset = mkOption {
|
|
|
|
type = str;
|
|
|
|
description = "Dataset name to send snapshots to.";
|
|
|
|
example = "tank/main";
|
|
|
|
};
|
|
|
|
|
|
|
|
host = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
description = ''
|
|
|
|
Host to use for the destination dataset. Can be prefixed with
|
|
|
|
<literal>user@</literal> to specify the ssh user.
|
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
example = "john@example.com";
|
|
|
|
};
|
|
|
|
|
|
|
|
presend = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
description = ''
|
|
|
|
Command to run before sending the snapshot to the destination.
|
|
|
|
Intended to run a remote script via <command>ssh</command> on the
|
|
|
|
destination, e.g. to bring up a backup disk or server or to put a
|
|
|
|
zpool online/offline. See also <option>postsend</option>.
|
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
example = "ssh root@bserv zpool import -Nf tank";
|
|
|
|
};
|
|
|
|
|
|
|
|
postsend = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
description = ''
|
|
|
|
Command to run after sending the snapshot to the destination.
|
|
|
|
Intended to run a remote script via <command>ssh</command> on the
|
|
|
|
destination, e.g. to bring up a backup disk or server or to put a
|
|
|
|
zpool online/offline. See also <option>presend</option>.
|
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
example = "ssh root@bserv zpool export tank";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
label = mkDefault name;
|
|
|
|
plan = mkDefault srcConfig.plan;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
srcType = submodule ({ name, config, ... }: {
|
|
|
|
options = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = bool;
|
|
|
|
description = "Whether to enable this source.";
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
recursive = mkOption {
|
|
|
|
type = bool;
|
|
|
|
description = "Whether to do recursive snapshots.";
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
mbuffer = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = bool;
|
|
|
|
description = "Whether to use <command>mbuffer</command>.";
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = nullOr ints.u16;
|
|
|
|
description = ''
|
|
|
|
Port to use for <command>mbuffer</command>.
|
2019-05-13 07:15:17 +00:00
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
If this is null, it will run <command>mbuffer</command> through
|
|
|
|
ssh.
|
2019-05-13 07:15:17 +00:00
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
If this is not null, it will run <command>mbuffer</command>
|
|
|
|
directly through TCP, which is not encrypted but faster. In that
|
|
|
|
case the given port needs to be open on the destination host.
|
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
size = mkOption {
|
|
|
|
type = mbufferSizeType;
|
|
|
|
description = ''
|
|
|
|
The size for <command>mbuffer</command>.
|
|
|
|
Supports the units b, k, M, G.
|
|
|
|
'';
|
|
|
|
default = "1G";
|
|
|
|
example = "128M";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
presnap = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
description = ''
|
|
|
|
Command to run before snapshots are taken on the source dataset,
|
|
|
|
e.g. for database locking/flushing. See also
|
|
|
|
<option>postsnap</option>.
|
|
|
|
'';
|
|
|
|
default = null;
|
2021-10-03 16:06:03 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
'''''${pkgs.mariadb}/bin/mysql -e "set autocommit=0;flush tables with read lock;\\! ''${pkgs.coreutils}/bin/sleep 600" & ''${pkgs.coreutils}/bin/echo $! > /tmp/mariadblock.pid ; sleep 10'''
|
2017-12-20 23:40:36 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
postsnap = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
description = ''
|
|
|
|
Command to run after snapshots are taken on the source dataset,
|
|
|
|
e.g. for database unlocking. See also <option>presnap</option>.
|
|
|
|
'';
|
|
|
|
default = null;
|
2021-10-03 16:06:03 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
"''${pkgs.coreutils}/bin/kill `''${pkgs.coreutils}/bin/cat /tmp/mariadblock.pid`;''${pkgs.coreutils}/bin/rm /tmp/mariadblock.pid"
|
2017-12-20 23:40:36 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
timestampFormat = mkOption {
|
|
|
|
type = timestampType;
|
|
|
|
description = ''
|
|
|
|
The timestamp format to use for constructing snapshot names.
|
|
|
|
The syntax is <literal>strftime</literal>-like. The string must
|
|
|
|
consist of the mandatory <literal>%Y %m %d %H %M %S</literal>.
|
|
|
|
Optionally <literal>- _ . :</literal> characters as well as any
|
|
|
|
alphanumeric character are allowed. If suffixed by a
|
|
|
|
<literal>Z</literal>, times will be in UTC.
|
|
|
|
'';
|
|
|
|
default = "%Y-%m-%d-%H%M%S";
|
|
|
|
example = "znapzend-%m.%d.%Y-%H%M%SZ";
|
|
|
|
};
|
|
|
|
|
|
|
|
sendDelay = mkOption {
|
|
|
|
type = int;
|
|
|
|
description = ''
|
|
|
|
Specify delay (in seconds) before sending snaps to the destination.
|
|
|
|
May be useful if you want to control sending time.
|
|
|
|
'';
|
|
|
|
default = 0;
|
|
|
|
example = 60;
|
|
|
|
};
|
|
|
|
|
|
|
|
plan = mkOption {
|
|
|
|
type = str;
|
|
|
|
description = planDescription;
|
|
|
|
example = planExample;
|
|
|
|
};
|
|
|
|
|
|
|
|
dataset = mkOption {
|
|
|
|
type = str;
|
|
|
|
description = "The dataset to use for this source.";
|
|
|
|
example = "tank/home";
|
|
|
|
};
|
|
|
|
|
|
|
|
destinations = mkOption {
|
2020-08-22 23:28:45 +00:00
|
|
|
type = attrsOf (destType config);
|
2017-12-20 23:40:36 +00:00
|
|
|
description = "Additional destinations.";
|
|
|
|
default = {};
|
2021-10-03 16:06:03 +00:00
|
|
|
example = literalExpression ''
|
2017-12-20 23:40:36 +00:00
|
|
|
{
|
|
|
|
local = {
|
|
|
|
dataset = "btank/backup";
|
|
|
|
presend = "zpool import -N btank";
|
|
|
|
postsend = "zpool export btank";
|
|
|
|
};
|
|
|
|
remote = {
|
|
|
|
host = "john@example.com";
|
|
|
|
dataset = "tank/john";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
dataset = mkDefault name;
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
### Generating the configuration from here
|
|
|
|
|
2016-03-24 09:52:13 +00:00
|
|
|
cfg = config.services.znapzend;
|
2017-12-20 23:40:36 +00:00
|
|
|
|
|
|
|
onOff = b: if b then "on" else "off";
|
2019-04-24 03:48:22 +00:00
|
|
|
nullOff = b: if b == null then "off" else toString b;
|
2017-12-20 23:40:36 +00:00
|
|
|
stripSlashes = replaceStrings [ "/" ] [ "." ];
|
|
|
|
|
|
|
|
attrsToFile = config: concatStringsSep "\n" (builtins.attrValues (
|
|
|
|
mapAttrs (n: v: "${n}=${v}") config));
|
|
|
|
|
|
|
|
mkDestAttrs = dst: with dst;
|
|
|
|
mapAttrs' (n: v: nameValuePair "dst_${label}${n}" v) ({
|
2019-04-24 03:48:22 +00:00
|
|
|
"" = optionalString (host != null) "${host}:" + dataset;
|
2017-12-20 23:40:36 +00:00
|
|
|
_plan = plan;
|
|
|
|
} // optionalAttrs (presend != null) {
|
|
|
|
_precmd = presend;
|
|
|
|
} // optionalAttrs (postsend != null) {
|
|
|
|
_pstcmd = postsend;
|
|
|
|
});
|
|
|
|
|
|
|
|
mkSrcAttrs = srcCfg: with srcCfg; {
|
|
|
|
enabled = onOff enable;
|
2020-05-08 16:37:51 +00:00
|
|
|
# mbuffer is not referenced by its full path to accomodate non-NixOS systems or differing mbuffer versions between source and target
|
|
|
|
mbuffer = with mbuffer; if enable then "mbuffer"
|
2017-12-20 23:40:36 +00:00
|
|
|
+ optionalString (port != null) ":${toString port}" else "off";
|
|
|
|
mbuffer_size = mbuffer.size;
|
|
|
|
post_znap_cmd = nullOff postsnap;
|
|
|
|
pre_znap_cmd = nullOff presnap;
|
|
|
|
recursive = onOff recursive;
|
|
|
|
src = dataset;
|
|
|
|
src_plan = plan;
|
|
|
|
tsformat = timestampFormat;
|
|
|
|
zend_delay = toString sendDelay;
|
2021-01-25 06:57:48 +00:00
|
|
|
} // foldr (a: b: a // b) {} (
|
2017-12-20 23:40:36 +00:00
|
|
|
map mkDestAttrs (builtins.attrValues destinations)
|
|
|
|
);
|
|
|
|
|
|
|
|
files = mapAttrs' (n: srcCfg: let
|
|
|
|
fileText = attrsToFile (mkSrcAttrs srcCfg);
|
|
|
|
in {
|
|
|
|
name = srcCfg.dataset;
|
|
|
|
value = pkgs.writeText (stripSlashes srcCfg.dataset) fileText;
|
|
|
|
}) cfg.zetup;
|
|
|
|
|
2016-03-24 09:52:13 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.znapzend = {
|
2017-12-20 23:40:36 +00:00
|
|
|
enable = mkEnableOption "ZnapZend ZFS backup daemon";
|
2017-05-21 10:57:16 +00:00
|
|
|
|
|
|
|
logLevel = mkOption {
|
|
|
|
default = "debug";
|
|
|
|
example = "warning";
|
2017-12-20 23:40:36 +00:00
|
|
|
type = enum ["debug" "info" "warning" "err" "alert"];
|
|
|
|
description = ''
|
|
|
|
The log level when logging to file. Any of debug, info, warning, err,
|
|
|
|
alert. Default in daemonized form is debug.
|
|
|
|
'';
|
2017-05-21 10:57:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
logTo = mkOption {
|
2017-12-20 23:40:36 +00:00
|
|
|
type = str;
|
2017-05-21 10:57:16 +00:00
|
|
|
default = "syslog::daemon";
|
|
|
|
example = "/var/log/znapzend.log";
|
2017-12-20 23:40:36 +00:00
|
|
|
description = ''
|
|
|
|
Where to log to (syslog::<facility> or <filepath>).
|
|
|
|
'';
|
2017-05-21 10:57:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
noDestroy = mkOption {
|
2017-12-20 23:40:36 +00:00
|
|
|
type = bool;
|
2017-05-21 10:57:16 +00:00
|
|
|
default = false;
|
2017-08-30 12:13:13 +00:00
|
|
|
description = "Does all changes to the filesystem except destroy.";
|
|
|
|
};
|
|
|
|
|
|
|
|
autoCreation = mkOption {
|
2017-12-20 23:40:36 +00:00
|
|
|
type = bool;
|
|
|
|
default = false;
|
2021-09-09 18:45:33 +00:00
|
|
|
description = "Automatically create the destination dataset if it does not exist.";
|
2017-12-20 23:40:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
zetup = mkOption {
|
2020-08-22 23:28:45 +00:00
|
|
|
type = attrsOf srcType;
|
2017-12-20 23:40:36 +00:00
|
|
|
description = "Znapzend configuration.";
|
|
|
|
default = {};
|
2021-10-03 16:06:03 +00:00
|
|
|
example = literalExpression ''
|
2017-12-20 23:40:36 +00:00
|
|
|
{
|
|
|
|
"tank/home" = {
|
|
|
|
# Make snapshots of tank/home every hour, keep those for 1 day,
|
|
|
|
# keep every days snapshot for 1 month, etc.
|
|
|
|
plan = "1d=>1h,1m=>1d,1y=>1m";
|
|
|
|
recursive = true;
|
|
|
|
# Send all those snapshots to john@example.com:rtank/john as well
|
|
|
|
destinations.remote = {
|
|
|
|
host = "john@example.com";
|
|
|
|
dataset = "rtank/john";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
pure = mkOption {
|
|
|
|
type = bool;
|
|
|
|
description = ''
|
|
|
|
Do not persist any stateful znapzend setups. If this option is
|
|
|
|
enabled, your previously set znapzend setups will be cleared and only
|
|
|
|
the ones defined with this module will be applied.
|
|
|
|
'';
|
2017-08-30 12:13:13 +00:00
|
|
|
default = false;
|
2017-05-21 10:57:16 +00:00
|
|
|
};
|
2019-10-27 11:06:18 +00:00
|
|
|
|
2020-05-11 12:35:11 +00:00
|
|
|
features.oracleMode = mkEnableOption ''
|
|
|
|
Destroy snapshots one by one instead of using one long argument list.
|
|
|
|
If source and destination are out of sync for a long time, you may have
|
|
|
|
so many snapshots to destroy that the argument gets is too long and the
|
|
|
|
command fails.
|
|
|
|
'';
|
2019-10-27 11:06:18 +00:00
|
|
|
features.recvu = mkEnableOption ''
|
|
|
|
recvu feature which uses <literal>-u</literal> on the receiving end to keep the destination
|
|
|
|
filesystem unmounted.
|
|
|
|
'';
|
|
|
|
features.compressed = mkEnableOption ''
|
|
|
|
compressed feature which adds the options <literal>-Lce</literal> to
|
|
|
|
the <command>zfs send</command> command. When this is enabled, make
|
|
|
|
sure that both the sending and receiving pool have the same relevant
|
|
|
|
features enabled. Using <literal>-c</literal> will skip unneccessary
|
|
|
|
decompress-compress stages, <literal>-L</literal> is for large block
|
|
|
|
support and -e is for embedded data support. see
|
|
|
|
<citerefentry><refentrytitle>znapzend</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
|
|
|
and <citerefentry><refentrytitle>zfs</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
|
|
|
for more info.
|
|
|
|
'';
|
2020-03-23 20:13:06 +00:00
|
|
|
features.sendRaw = mkEnableOption ''
|
|
|
|
sendRaw feature which adds the options <literal>-w</literal> to the
|
|
|
|
<command>zfs send</command> command. For encrypted source datasets this
|
|
|
|
instructs zfs not to decrypt before sending which results in a remote
|
|
|
|
backup that can't be read without the encryption key/passphrase, useful
|
|
|
|
when the remote isn't fully trusted or not physically secure. This
|
|
|
|
option must be used consistently, raw incrementals cannot be based on
|
|
|
|
non-raw snapshots and vice versa.
|
|
|
|
'';
|
|
|
|
features.skipIntermediates = mkEnableOption ''
|
|
|
|
Enable the skipIntermediates feature to send a single increment
|
|
|
|
between latest common snapshot and the newly made one. It may skip
|
|
|
|
several source snaps if the destination was offline for some time, and
|
|
|
|
it should skip snapshots not managed by znapzend. Normally for online
|
|
|
|
destinations, the new snapshot is sent as soon as it is created on the
|
|
|
|
source, so there are no automatic increments to skip.
|
|
|
|
'';
|
|
|
|
features.lowmemRecurse = mkEnableOption ''
|
|
|
|
use lowmemRecurse on systems where you have too many datasets, so a
|
|
|
|
recursive listing of attributes to find backup plans exhausts the
|
|
|
|
memory available to <command>znapzend</command>: instead, go the slower
|
|
|
|
way to first list all impacted dataset names, and then query their
|
|
|
|
configs one by one.
|
|
|
|
'';
|
|
|
|
features.zfsGetType = mkEnableOption ''
|
|
|
|
use zfsGetType if your <command>zfs get</command> supports a
|
|
|
|
<literal>-t</literal> argument for filtering by dataset type at all AND
|
|
|
|
lists properties for snapshots by default when recursing, so that there
|
|
|
|
is too much data to process while searching for backup plans.
|
|
|
|
If these two conditions apply to your system, the time needed for a
|
|
|
|
<literal>--recursive</literal> search for backup plans can literally
|
|
|
|
differ by hundreds of times (depending on the amount of snapshots in
|
|
|
|
that dataset tree... and a decent backup plan will ensure you have a lot
|
|
|
|
of those), so you would benefit from requesting this feature.
|
|
|
|
'';
|
2016-03-24 09:52:13 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.znapzend ];
|
|
|
|
|
|
|
|
systemd.services = {
|
2019-08-13 21:52:01 +00:00
|
|
|
znapzend = {
|
2016-03-24 09:52:13 +00:00
|
|
|
description = "ZnapZend - ZFS Backup System";
|
2017-05-15 13:09:50 +00:00
|
|
|
wantedBy = [ "zfs.target" ];
|
2016-03-24 09:52:13 +00:00
|
|
|
after = [ "zfs.target" ];
|
|
|
|
|
2017-04-19 11:56:51 +00:00
|
|
|
path = with pkgs; [ zfs mbuffer openssh ];
|
2016-03-24 09:52:13 +00:00
|
|
|
|
2017-12-20 23:40:36 +00:00
|
|
|
preStart = optionalString cfg.pure ''
|
|
|
|
echo Resetting znapzend zetups
|
|
|
|
${pkgs.znapzend}/bin/znapzendzetup list \
|
|
|
|
| grep -oP '(?<=\*\*\* backup plan: ).*(?= \*\*\*)' \
|
2018-02-17 14:50:48 +00:00
|
|
|
| xargs -I{} ${pkgs.znapzend}/bin/znapzendzetup delete "{}"
|
2017-12-20 23:40:36 +00:00
|
|
|
'' + concatStringsSep "\n" (mapAttrsToList (dataset: config: ''
|
|
|
|
echo Importing znapzend zetup ${config} for dataset ${dataset}
|
2019-02-14 17:27:48 +00:00
|
|
|
${pkgs.znapzend}/bin/znapzendzetup import --write ${dataset} ${config} &
|
|
|
|
'') files) + ''
|
|
|
|
wait
|
|
|
|
'';
|
2017-12-20 23:40:36 +00:00
|
|
|
|
2017-04-19 11:56:51 +00:00
|
|
|
serviceConfig = {
|
2019-10-27 11:29:31 +00:00
|
|
|
# znapzendzetup --import apparently tries to connect to the backup
|
|
|
|
# host 3 times with a timeout of 30 seconds, leading to a startup
|
|
|
|
# delay of >90s when the host is down, which is just above the default
|
|
|
|
# service timeout of 90 seconds. Increase the timeout so it doesn't
|
|
|
|
# make the service fail in that case.
|
|
|
|
TimeoutStartSec = 180;
|
|
|
|
# Needs to have write access to ZFS
|
|
|
|
User = "root";
|
2017-12-20 23:40:36 +00:00
|
|
|
ExecStart = let
|
|
|
|
args = concatStringsSep " " [
|
|
|
|
"--logto=${cfg.logTo}"
|
|
|
|
"--loglevel=${cfg.logLevel}"
|
|
|
|
(optionalString cfg.noDestroy "--nodestroy")
|
|
|
|
(optionalString cfg.autoCreation "--autoCreation")
|
2019-10-27 11:06:18 +00:00
|
|
|
(optionalString (enabledFeatures != [])
|
|
|
|
"--features=${concatStringsSep "," enabledFeatures}")
|
2017-12-20 23:40:36 +00:00
|
|
|
]; in "${pkgs.znapzend}/bin/znapzend ${args}";
|
2017-04-19 11:56:51 +00:00
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
2017-05-21 10:57:16 +00:00
|
|
|
Restart = "on-failure";
|
2017-04-19 11:56:51 +00:00
|
|
|
};
|
2016-03-24 09:52:13 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2017-12-20 23:40:36 +00:00
|
|
|
|
2020-05-11 12:35:11 +00:00
|
|
|
meta.maintainers = with maintainers; [ infinisil SlothOfAnarchy ];
|
2016-03-24 09:52:13 +00:00
|
|
|
}
|