infra: init backend api
This commit is contained in:
parent
f0b650f4e3
commit
9a42e80657
1 changed files with 39 additions and 0 deletions
39
nix/infra/backend.nix
Normal file
39
nix/infra/backend.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
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 = {
|
||||
DATABASE_URL = "postgres://${user}@localhost:${config.services.postgresql.settings.port}/${user}";
|
||||
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;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue