at 18.09-beta 1.4 kB view raw
1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.services.duplicati; 7in 8{ 9 options = { 10 services.duplicati = { 11 enable = mkEnableOption "Duplicati"; 12 13 port = mkOption { 14 default = 8200; 15 type = types.int; 16 description = '' 17 Port serving the web interface 18 ''; 19 }; 20 21 interface = mkOption { 22 default = "lo"; 23 type = types.str; 24 description = '' 25 Listening interface for the web UI 26 Set it to "any" to listen on all available interfaces 27 ''; 28 }; 29 }; 30 }; 31 32 config = mkIf cfg.enable { 33 environment.systemPackages = [ pkgs.duplicati ]; 34 35 systemd.services.duplicati = { 36 description = "Duplicati backup"; 37 after = [ "network.target" ]; 38 wantedBy = [ "multi-user.target" ]; 39 serviceConfig = { 40 User = "duplicati"; 41 Group = "duplicati"; 42 ExecStart = "${pkgs.duplicati}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=/var/lib/duplicati"; 43 Restart = "on-failure"; 44 }; 45 }; 46 47 users.users.duplicati = { 48 uid = config.ids.uids.duplicati; 49 home = "/var/lib/duplicati"; 50 createHome = true; 51 group = "duplicati"; 52 }; 53 users.groups.duplicati.gid = config.ids.gids.duplicati; 54 55 }; 56} 57