Files
dotfiles/systems/jeeves/services/gems.nix
T

69 lines
1.5 KiB
Nix

{
inputs,
pkgs,
...
}:
let
vars = import ../vars.nix;
stateDir = "${vars.services}/gems";
in
{
nixpkgs.overlays = [
(final: _prev: {
gems_python = final.python314.withPackages (
ps: with ps; [
fastapi
jinja2
pydantic
pydantic-settings
python-multipart
typer
uvicorn
]
);
})
];
users.groups.gems = { };
users.users.gems = {
isSystemUser = true;
group = "gems";
home = stateDir;
};
systemd.tmpfiles.rules = [
"d ${stateDir} 0750 gems gems - -"
];
systemd.services.gems = {
description = "Gems multiplayer game";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
environment = {
PYTHONPATH = "${inputs.self}";
GEMS_DATABASE_PATH = "${stateDir}/gems.sqlite3";
GEMS_KEY_PATH = "${stateDir}/instance.key";
GEMS_PUBLIC_ORIGIN = "https://gems.tmmworkshop.com";
GEMS_SECURE_COOKIES = "true";
};
serviceConfig = {
Type = "simple";
User = "gems";
Group = "gems";
ExecStart = "${pkgs.gems_python}/bin/python -m python.gems.main --host 0.0.0.0 --port 8002";
Restart = "on-failure";
RestartSec = "5s";
StandardOutput = "journal";
StandardError = "journal";
NoNewPrivileges = true;
PrivateTmp = true;
ProtectHome = true;
ProtectSystem = "strict";
ReadOnlyPaths = [ "${inputs.self}" ];
ReadWritePaths = [ stateDir ];
};
};
}