2024-05-07 22:02:59 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-02-29 14:53:34 +00:00
|
|
|
|
|
|
|
let
|
2024-05-07 22:02:59 +00:00
|
|
|
cfg = config.host.services.duplicacy-web;
|
|
|
|
duplicacy-web = pkgs.callPackage ../../packages/duplicacy-web.nix { inherit pkgs lib; };
|
2024-02-29 14:53:34 +00:00
|
|
|
in
|
|
|
|
with lib;
|
|
|
|
rec {
|
2024-05-07 22:02:59 +00:00
|
|
|
options = {
|
|
|
|
host.services.duplicacy-web = {
|
|
|
|
enable = mkEnableOption (mdDoc "Enables duplicacy-web");
|
|
|
|
autostart = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = "Whether to auto-start duplicacy-web on boot";
|
|
|
|
};
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-05-07 22:02:59 +00:00
|
|
|
environment = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
description = "Environment where duplicacy-web stores its config files";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-05-07 22:02:59 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
environment.systemPackages = [ duplicacy-web ];
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-05-07 22:02:59 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [ 3875 ];
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-05-07 22:02:59 +00: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";
|
|
|
|
};
|
|
|
|
environment = {
|
|
|
|
HOME = cfg.environment;
|
|
|
|
};
|
|
|
|
} // optionalAttrs cfg.autostart { wantedBy = [ "multi-user.target" ]; }; # Start at boot if autostart is enabled.
|
|
|
|
};
|
2024-02-29 14:53:34 +00:00
|
|
|
}
|