mirror of
https://github.com/srid/nixos-config.git
synced 2025-12-28 08:14:58 +08:00
Add postgrest
This commit is contained in:
parent
d0851959ca
commit
3a57cfa449
3 changed files with 51 additions and 1 deletions
45
features/postgrest.nix
Normal file
45
features/postgrest.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
postgrest = pkgs.haskellPackages.postgrest;
|
||||
in
|
||||
{
|
||||
# PostgreSQL itself
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
package = pkgs.postgresql_12;
|
||||
enableTCPIP = false;
|
||||
# https://nixos.wiki/wiki/PostgreSQL
|
||||
authentication = pkgs.lib.mkOverride 10
|
||||
''
|
||||
# Unix domain socket
|
||||
local all all trust
|
||||
# TCP/IP connections from loopback only
|
||||
host all all ::1/128 trust
|
||||
'';
|
||||
initialScript = pkgs.writeText "backend-initScript" ''
|
||||
CREATE ROLE nixcloud WITH LOGIN PASSWORD 'nixcloud' CREATEDB;
|
||||
CREATE DATABASE nixcloud;
|
||||
GRANT ALL PRIVILEGES ON DATABASE nixcloud TO nixcloud;
|
||||
'';
|
||||
};
|
||||
|
||||
# PostgREST as systemd service
|
||||
systemd.services.postgrest = {
|
||||
enable = true;
|
||||
description = "PostgREST daemon";
|
||||
after = [ "postgresql.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
let pgrstConf = pkgs.writeText "pgrst.conf" ''
|
||||
db-uri = "postgres://postgres@localhost/postgres"
|
||||
db-schema = "public"
|
||||
db-anon-role = "postgres"
|
||||
server-port = 7000
|
||||
'';
|
||||
in
|
||||
"${postgrest}/bin/postgrest ${pgrstConf}";
|
||||
Restart = "always";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -17,7 +17,8 @@
|
|||
modules = ([
|
||||
# System configuration
|
||||
configurationNix
|
||||
# ./features/virtualization.nix
|
||||
|
||||
# Features common to all of my machines
|
||||
./features/passwordstore.nix
|
||||
./features/syncthing.nix
|
||||
./features/email
|
||||
|
|
@ -44,6 +45,8 @@
|
|||
[
|
||||
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p53
|
||||
./features/desktopish
|
||||
# ./features/virtualization.nix
|
||||
./features/postgrest.nix
|
||||
];
|
||||
nixosConfigurations.x1c7 = mkHomeMachine
|
||||
./hosts/x1c7.nix
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@
|
|||
obsidian
|
||||
signal-desktop
|
||||
ripgrep
|
||||
fzf
|
||||
htop
|
||||
];
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue