2018-04-07 21:23:04 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.duplicati;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.duplicati = {
|
|
|
|
enable = mkEnableOption "Duplicati";
|
2018-05-24 23:35:53 +02:00
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = 8200;
|
|
|
|
type = types.int;
|
|
|
|
description = ''
|
|
|
|
Port serving the web interface
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
interface = mkOption {
|
2019-06-22 20:25:43 +02:00
|
|
|
default = "127.0.0.1";
|
2018-05-24 23:35:53 +02:00
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Listening interface for the web UI
|
|
|
|
Set it to "any" to listen on all available interfaces
|
|
|
|
'';
|
|
|
|
};
|
2018-04-07 21:23:04 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.duplicati ];
|
|
|
|
|
|
|
|
systemd.services.duplicati = {
|
|
|
|
description = "Duplicati backup";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
User = "duplicati";
|
|
|
|
Group = "duplicati";
|
2018-05-24 23:35:53 +02:00
|
|
|
ExecStart = "${pkgs.duplicati}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=/var/lib/duplicati";
|
2018-04-07 21:23:04 +02:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.duplicati = {
|
2018-04-07 21:23:04 +02:00
|
|
|
uid = config.ids.uids.duplicati;
|
|
|
|
home = "/var/lib/duplicati";
|
|
|
|
createHome = true;
|
|
|
|
group = "duplicati";
|
|
|
|
};
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.duplicati.gid = config.ids.gids.duplicati;
|
2018-04-07 21:23:04 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|