2024-05-07 18:02:59 -04:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-02-29 09:53:34 -05:00
|
|
|
|
|
|
|
let
|
2024-06-24 11:38:28 -04:00
|
|
|
cfg = config.aux.system.services.duplicacy-web;
|
2024-05-07 18:02:59 -04:00
|
|
|
duplicacy-web = pkgs.callPackage ../../packages/duplicacy-web.nix { inherit pkgs lib; };
|
2024-02-29 09:53:34 -05:00
|
|
|
in
|
2024-08-02 17:55:48 -04:00
|
|
|
{
|
2024-05-07 18:02:59 -04:00
|
|
|
options = {
|
2024-06-24 11:38:28 -04:00
|
|
|
aux.system.services.duplicacy-web = {
|
2024-08-02 17:55:48 -04:00
|
|
|
enable = lib.mkEnableOption "Enables duplicacy-web";
|
|
|
|
autostart = lib.mkOption {
|
2024-05-07 18:02:59 -04:00
|
|
|
default = true;
|
2024-08-02 17:55:48 -04:00
|
|
|
type = lib.types.bool;
|
2024-05-07 18:02:59 -04:00
|
|
|
description = "Whether to auto-start duplicacy-web on boot";
|
|
|
|
};
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-08-02 17:55:48 -04:00
|
|
|
environment = lib.mkOption {
|
2024-05-07 18:02:59 -04:00
|
|
|
default = "";
|
2024-08-02 17:55:48 -04:00
|
|
|
type = lib.types.str;
|
2024-05-07 18:02:59 -04:00
|
|
|
description = "Environment where duplicacy-web stores its config files";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-07-02 16:19:15 -04:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
environment.systemPackages = [ duplicacy-web ];
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-07-02 16:19:15 -04:00
|
|
|
networking.firewall.allowedTCPPorts = [ 3875 ];
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-07-02 16:19:15 -04:00
|
|
|
# Install systemd service.
|
|
|
|
systemd.services.duplicacy-web = {
|
|
|
|
enable = true;
|
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
after = [
|
|
|
|
"syslog.target"
|
|
|
|
"network-online.target"
|
|
|
|
];
|
|
|
|
description = "Start the Duplicacy backup service and web UI";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = ''${duplicacy-web}/duplicacy-web'';
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSrc = 10;
|
|
|
|
KillMode = "process";
|
2024-05-07 18:02:59 -04:00
|
|
|
};
|
2024-07-02 16:19:15 -04:00
|
|
|
environment = {
|
|
|
|
HOME = cfg.environment;
|
|
|
|
};
|
|
|
|
} // lib.optionalAttrs (!cfg.autostart) { wantedBy = lib.mkForce [ ]; };
|
|
|
|
};
|
2024-02-29 09:53:34 -05:00
|
|
|
}
|