Alisa/nix/infra/backend.nix

40 lines
807 B
Nix
Raw Normal View History

2024-07-10 18:14:50 +02:00
{
lib,
config,
self,
...
}:
let
user = "alisa";
in
{
systemd.services.alisa-backend = {
enable = true;
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
description = "Alisa Backend API Server";
environment = {
2024-07-10 18:22:06 +02:00
DATABASE_URL = ''postgres://${user}@localhost:${builtins.toString config.services.postgresql.settings.port}/${user}'';
2024-07-10 18:14:50 +02:00
TOKEN_SECRET = "secret";
};
serviceConfig = {
Restart = "always";
DynamicUser = true;
User = user;
ExecStart = lib.getExe self.legacyPackages.${config.nixpkgs.hostPlatform.system}.backend;
};
};
services.postgresql = {
enable = true;
ensureDatabases = [ user ];
ensureUsers = [
{
name = user;
ensureDBOwnership = true;
}
];
};
}