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"; + } + ]; + }; + +}