mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-10 04:49:19 -08:00
45 lines
956 B
Nix
45 lines
956 B
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
utils,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.services.syncplay;
|
|
args =
|
|
[
|
|
"--disable-ready"
|
|
"--port"
|
|
cfg.port
|
|
]
|
|
++ optionals (cfg.certDir != null) ["--tls" cfg.certDir];
|
|
in {
|
|
sops.secrets.syncplay-env = {
|
|
sopsFile = mkDefault ./secrets/syncplay.yaml;
|
|
owner = cfg.user;
|
|
};
|
|
|
|
users.users.${cfg.user} = {
|
|
inherit (cfg) group;
|
|
isSystemUser = true;
|
|
home = "/var/lib/syncplay";
|
|
};
|
|
users.groups.${cfg.group} = {};
|
|
|
|
networking.firewall.interfaces.local.allowedTCPPorts = [cfg.port];
|
|
|
|
services.syncplay = {
|
|
enable = true;
|
|
user = "syncplay";
|
|
};
|
|
systemd.services.syncplay = mkIf cfg.enable {
|
|
serviceConfig = {
|
|
StateDirectory = "syncplay";
|
|
EnvironmentFile = singleton config.sops.secrets.syncplay-env.path;
|
|
ExecStart = mkForce [
|
|
"${pkgs.syncplay-nogui}/bin/syncplay-server ${utils.escapeSystemdExecArgs args}"
|
|
];
|
|
};
|
|
};
|
|
}
|