From f2f069251c7e5fb4955b487d246b27363f09d1ec Mon Sep 17 00:00:00 2001 From: Alexandre LUCAZEAU Date: Fri, 8 Jul 2022 08:33:52 +0000 Subject: [PATCH] ADD : databases : create load and configure postgresql --- hosts/next/configuration.nix | 1 + hosts/next/databases.nix | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 hosts/next/databases.nix diff --git a/hosts/next/configuration.nix b/hosts/next/configuration.nix index 52803ea..b757611 100644 --- a/hosts/next/configuration.nix +++ b/hosts/next/configuration.nix @@ -3,6 +3,7 @@ ./hardware-configuration.nix ./nextcloud.nix ./backup.nix + ./databases.nix ../modules/users.nix ../modules/common.nix ../modules/prometheus-node.nix diff --git a/hosts/next/databases.nix b/hosts/next/databases.nix new file mode 100644 index 0000000..b91feaa --- /dev/null +++ b/hosts/next/databases.nix @@ -0,0 +1,19 @@ +{config, pkgs, ...}: +{ + +networking.firewall.allowedTCPPorts = [ 5432 ]; +# Enable PostgreSQL + services.postgresql = { + enable = true; + authentication = "host all all 192.168.0.0/16 trust"; + + # Ensure the database, user, and permissions always exist + ensureDatabases = [ "pizzajoffredb" ]; + ensureUsers = [ + { name = "pizzajoffre"; + ensurePermissions."DATABASE pizzajoffredb" = "ALL PRIVILEGES"; + } + ]; + }; + +}