diff options
| author | adi <adikro@disroot.org> | 2026-07-29 17:09:58 +0200 |
|---|---|---|
| committer | adi <adikro@disroot.org> | 2026-07-29 17:09:58 +0200 |
| commit | 39a2b09c27bb74c9e59d1772764f901e3c8fb9e4 (patch) | |
| tree | 0ba58e6fbf086a85d875df1c10f6d23bc3bbc7da /os/srv/postgres.nix | |
| parent | 8a820cacee1ff07ae7397d053b26e66f7086a4a4 (diff) | |
revamped flake.nix, removed homelab specific modulesstaging
Diffstat (limited to 'os/srv/postgres.nix')
| -rw-r--r-- | os/srv/postgres.nix | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/os/srv/postgres.nix b/os/srv/postgres.nix deleted file mode 100644 index f669f63..0000000 --- a/os/srv/postgres.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -let - cfg = config.os.srv.postgres; -in -{ - options.os.srv.postgres.enable = lib.mkEnableOption ""; - config = lib.mkIf cfg.enable { - assertions = [ - { - assertion = config.os.srv.sops.enable; - message = "Required for password secure password storing"; - } - { - assertion = config.os.core.network.enableFirewall; - message = "Requires firewall"; - } - ]; - - sops.secrets."postgres/authelia_password" = { - owner = "postgres"; - group = "postgres"; - restartUnits = [ "postgresql.service" ]; - }; - - services.postgresql = { - enable = true; - package = pkgs.postgresql_18; - - extraPlugins = [ config.services.postgresql.package.pkgs.pgvector ]; - - settings = { - listen_addresses = config.os.core.network.ips.database-vm; - - max_connections = 100; - shared_buffers = "256MB"; - work_mem = "4MB"; - }; - - ensureDatabases = [ "authelia" ]; - ensureUsers = [ - { - name = "authelia"; - ensureDBOwnership = true; - } - ]; - - initialScript = pkgs.writeText "init-postgres-passwords.sql" '' - CREATE USER authelia; - ALTER USER authelia WITH PASSWORD 'scram-sha-256'; - ''; - - authentication = pkgs.lib.mkForce '' - local all all trust - host all all 10.0.0.0/24 scram-sha-256 - ''; - }; - - systemd.services.postgresql.postStart = lib.mkAfter '' - PASS=$(cat ${config.sops.secrets."postgres/authelia_password".path}) - ${config.services.postgresql.package}/bin/psql -tAc "ALTER USER authelia WITH PASSWORD '$PASS';" - ''; - - networking.firewall.extraInputRules = '' - ip saddr 10.0.0.0/24 tcp dport 5432 accept - ''; - }; -} |
