63 lines
1.7 KiB
Nix
63 lines
1.7 KiB
Nix
{ pkgs, inputs, config, lib, ... }:
|
|
let
|
|
cfg = config.modules.services.workout-sync;
|
|
fqdn = "${cfg.subdomain}.${config.networking.domain}";
|
|
port = cfg.port;
|
|
workout-sync = inputs.workout-sync.packages.${pkgs.system}.default;
|
|
in
|
|
{
|
|
options.modules.services.workout-sync = {
|
|
enable = lib.mkEnableOption "Enable Workout Sync";
|
|
subdomain = lib.mkOption {
|
|
type = lib.types.str;
|
|
};
|
|
port = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 3344;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
modules.services.workout-tracker.enable = lib.mkDefault true;
|
|
|
|
systemd.services.workout-sync = {
|
|
enable = true;
|
|
description = "Workout sync service";
|
|
environment = {
|
|
PORT = toString port;
|
|
WORKOUT_TRACKER_URL = "http://localhost:${toString config.services.workout-tracker.port}";
|
|
};
|
|
serviceConfig = {
|
|
ExecStart = "${workout-sync}/bin/workout-sync";
|
|
Restart = "always";
|
|
DynamicUser = true;
|
|
BindReadOnlyPaths = [
|
|
/run/systemd/resolve/stub-resolv.conf
|
|
/etc/ssl
|
|
/etc/static/ssl
|
|
/etc/resolv.conf
|
|
/etc/static/resolv.conf
|
|
/etc/nsswitch.conf
|
|
/etc/static/nsswitch.conf
|
|
/etc/hosts
|
|
];
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
confinement.enable = true;
|
|
};
|
|
|
|
modules.services.webserver = {
|
|
enable = lib.mkDefault true;
|
|
vHosts.${fqdn}.locations."/" = {
|
|
proxyPort = port;
|
|
extraConfig = ''
|
|
client_max_body_size 50m;
|
|
proxy_send_timeout 300;
|
|
proxy_read_timeout 300;
|
|
send_timeout 300;
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|