From 3204926031d4e9c01e279386cb23781a975aa4ee Mon Sep 17 00:00:00 2001 From: notohh Date: Sun, 18 Jun 2023 17:35:07 -0400 Subject: [PATCH] arashi: init postgres + redis --- hosts/arashi/default.nix | 1 + hosts/arashi/hardware-configuration.nix | 7 +++-- hosts/arashi/services/default.nix | 2 +- hosts/arashi/services/postgresql.nix | 41 +++++++++++++++++++++++++ hosts/arashi/services/redis.nix | 0 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 hosts/arashi/services/postgresql.nix create mode 100644 hosts/arashi/services/redis.nix diff --git a/hosts/arashi/default.nix b/hosts/arashi/default.nix index dcb9634..5f08008 100644 --- a/hosts/arashi/default.nix +++ b/hosts/arashi/default.nix @@ -1,6 +1,7 @@ {...}: { imports = [ ./hardware-configuration.nix + ./services ../../modules ]; diff --git a/hosts/arashi/hardware-configuration.nix b/hosts/arashi/hardware-configuration.nix index 4746187..63c822d 100644 --- a/hosts/arashi/hardware-configuration.nix +++ b/hosts/arashi/hardware-configuration.nix @@ -1,7 +1,5 @@ { - config, lib, - pkgs, modulesPath, ... }: { @@ -19,6 +17,11 @@ fsType = "ext4"; }; + fileSystems."/nas" = { + device = "192.168.1.71:/volume1/arashi"; + fsType = "nfs"; + }; + swapDevices = [ {device = "/dev/disk/by-uuid/e9eb4b6a-e9a1-4616-8c82-349d2f38d140";} ]; diff --git a/hosts/arashi/services/default.nix b/hosts/arashi/services/default.nix index 08e6a9b..b9eafe2 100644 --- a/hosts/arashi/services/default.nix +++ b/hosts/arashi/services/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./traefik.nix + ./postgresql.nix ]; } diff --git a/hosts/arashi/services/postgresql.nix b/hosts/arashi/services/postgresql.nix new file mode 100644 index 0000000..f2576e7 --- /dev/null +++ b/hosts/arashi/services/postgresql.nix @@ -0,0 +1,41 @@ +{ + pkgs, + lib, + ... +}: { + networking.firewall.allowedTCPPorts = [5432]; + services.postgresql = { + enable = true; + enableTCPIP = true; + package = pkgs.postgresql_14; + port = 5432; + settings = { + listen_addresses = lib.mkForce "*"; + }; + authentication = '' + local all all trust + host replication all 127.0.0.1/32 trust + host all all all trust + ''; + ensureUsers = [ + { + name = "postgres"; + ensurePermissions = { + "ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES"; + }; + } + { + name = "hedgedoc"; + ensurePermissions."DATABASE hedgedoc" = "ALL PRIVILEGES"; + } + { + name = "forgejo"; + ensurePermissions."DATABASE forgejo" = "ALL PRIVILEGES"; + } + ]; + ensureDatabases = [ + "forgejo" + "hedgedoc" + ]; + }; +} diff --git a/hosts/arashi/services/redis.nix b/hosts/arashi/services/redis.nix new file mode 100644 index 0000000..e69de29