Added: Postgrest

This commit is contained in:
2026-02-19 18:43:36 +01:00
parent 0e1f5d2f99
commit d8cd7b6b69
2 changed files with 46 additions and 2 deletions

View File

@@ -61,9 +61,52 @@
};
# Enable the PostgreSQL service to start on boot
systemd.services.postgresql.wantedBy = [ "multi-user.target" ];
systemd.services = {
postgresql.wantedBy = [ "multi-user.target" ];
networking.firewall.allowedTCPPorts = [ 5432 ];
postgrest = {
description = "PostgREST - PostgreSQL REST API";
after = [
"postgresql.service"
"network.target"
];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.postgrest}/bin/postgrest /etc/postgrest/postgrest.conf";
User = "postgrest";
Restart = "on-failure";
RestartSec = 5;
};
};
};
users = {
users.postgrest = {
isSystemUser = true;
group = "postgrest";
};
groups.postgrest = { };
};
# PostgREST configuration file
environment = {
etc."postgrest/postgrest.conf".text = ''
db-uri = "postgres://postgres:postgres@localhost:5432/postgres"
db-schema = "public"
db-anon-role = "web_anon"
server-host = "0.0.0.0"
server-port = 3000
jwt-secret = "no7WwM0xJa/Yzn5o4IZHG4oBNSShl4JRPZOcmhvnqFw="
'';
systemPackages = with pkgs; [ postgrest ];
};
networking.firewall.allowedTCPPorts = [
5432
3000
];
# Create mount point for external USB storage (optional, for better performance)
# Uncomment if using the USB 3 storage we configured earlier