46 lines
1.2 KiB
Nix
46 lines
1.2 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;
|
|
EnvironmentFile = "/var/secrets/workout-sync.env";
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
confinement.enable = true;
|
|
};
|
|
|
|
modules.services.webserver = {
|
|
enable = lib.mkDefault true;
|
|
vHosts.${fqdn}.locations."/".proxyPort = port;
|
|
};
|
|
};
|
|
}
|