diff --git a/nixos/modules/services/backup/duplicati.nix b/nixos/modules/services/backup/duplicati.nix index bb205d2ac0dd..b69510f0aecb 100644 --- a/nixos/modules/services/backup/duplicati.nix +++ b/nixos/modules/services/backup/duplicati.nix @@ -6,6 +6,12 @@ }: let cfg = config.services.duplicati; + + parametersFile = + if cfg.parametersFile != null then + cfg.parametersFile + else + pkgs.writeText "duplicati-parameters" cfg.parameters; in { options = { @@ -53,12 +59,48 @@ in Run as root with special care. ''; }; + + parameters = lib.mkOption { + default = ""; + type = lib.types.lines; + example = '' + --webservice-allowedhostnames=* + ''; + description = '' + This option can be used to store some or all of the options given to the + commandline client. + Each line in this option should be of the format --option=value. + The options in this file take precedence over the options provided + through command line arguments. + Duplicati docs: parameters-file + ''; + }; + + parametersFile = lib.mkOption { + default = null; + type = lib.types.nullOr lib.types.path; + description = '' + This file can be used to store some or all of the options given to the + commandline client. + Each line in the file option should be of the format --option=value. + The options in this file take precedence over the options provided + through command line arguments. + Duplicati docs: parameters-file + ''; + }; }; }; config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; + assertions = [ + { + assertion = !(cfg.parametersFile != null && cfg.parameters != ""); + message = "cannot set both services.duplicati.parameters and services.duplicati.parametersFile at the same time"; + } + ]; + systemd.services.duplicati = { description = "Duplicati backup"; after = [ "network.target" ]; @@ -67,7 +109,7 @@ in { User = cfg.user; Group = "duplicati"; - ExecStart = "${cfg.package}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=${cfg.dataDir}"; + ExecStart = "${cfg.package}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=${cfg.dataDir} --parameters-file=${parametersFile}"; Restart = "on-failure"; } (lib.mkIf (cfg.dataDir == "/var/lib/duplicati") {