2024-05-07 22:02:59 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
2024-12-06 18:04:47 +00:00
|
|
|
namespace,
|
2024-05-07 22:02:59 +00:00
|
|
|
...
|
|
|
|
}:
|
2024-02-29 14:53:34 +00:00
|
|
|
|
|
|
|
let
|
2024-12-06 18:04:47 +00:00
|
|
|
cfg = config.${namespace}.services.duplicacy-web;
|
2024-02-29 14:53:34 +00:00
|
|
|
in
|
2024-08-02 21:55:48 +00:00
|
|
|
{
|
2024-05-07 22:02:59 +00:00
|
|
|
options = {
|
2024-12-06 18:04:47 +00:00
|
|
|
${namespace}.services.duplicacy-web = {
|
2024-08-02 21:55:48 +00:00
|
|
|
enable = lib.mkEnableOption "Enables duplicacy-web";
|
2024-08-29 15:59:28 +00:00
|
|
|
home = lib.mkOption {
|
2024-09-07 17:44:14 +00:00
|
|
|
default = "/var/lib/duplicacy-web";
|
2024-08-02 21:55:48 +00:00
|
|
|
type = lib.types.str;
|
2024-05-07 22:02:59 +00:00
|
|
|
description = "Environment where duplicacy-web stores its config files";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-07-02 20:19:15 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2024-12-09 18:30:39 +00:00
|
|
|
environment.systemPackages = [ pkgs.${namespace}.duplicacy-web ];
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-07-02 20:19:15 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [ 3875 ];
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-07-02 20:19:15 +00:00
|
|
|
# Install systemd service.
|
|
|
|
systemd.services.duplicacy-web = {
|
|
|
|
enable = true;
|
|
|
|
wants = [ "network-online.target" ];
|
2024-12-16 15:23:49 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-07-02 20:19:15 +00:00
|
|
|
after = [
|
|
|
|
"syslog.target"
|
|
|
|
"network-online.target"
|
|
|
|
];
|
|
|
|
description = "Start the Duplicacy backup service and web UI";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2024-12-09 18:30:39 +00:00
|
|
|
ExecStart = ''${pkgs.${namespace}.duplicacy-web}/duplicacy-web'';
|
2024-07-02 20:19:15 +00:00
|
|
|
Restart = "on-failure";
|
2024-12-01 16:24:54 +00:00
|
|
|
RestartSec = 10;
|
2024-07-02 20:19:15 +00:00
|
|
|
KillMode = "process";
|
2024-05-07 22:02:59 +00:00
|
|
|
};
|
2024-07-02 20:19:15 +00:00
|
|
|
environment = {
|
2024-08-29 15:59:28 +00:00
|
|
|
HOME = cfg.home;
|
2024-07-02 20:19:15 +00:00
|
|
|
};
|
2024-09-07 17:44:14 +00:00
|
|
|
unitConfig.RequiresMountsFor = cfg.home;
|
|
|
|
};
|
2024-07-02 20:19:15 +00:00
|
|
|
};
|
2024-02-29 14:53:34 +00:00
|
|
|
}
|