From 9399700cb5552c3c0a35e231b9a3a637c3f3578d Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Wed, 29 Mar 2023 00:55:52 +0200 Subject: Add postgres and synapse --- flake.nix | 22 ++++++++++ host/Rory-postgres/configuration.nix | 51 ------------------------ host/Spacebar-nginx/configuration.nix | 2 +- host/Spacebar-nginx/hosts/spacebar.chat/mail.nix | 14 +++++++ host/Spacebar-nginx/hosts/spacebar.chat/root.nix | 10 ----- host/Spacebar-postgres/configuration.nix | 51 ++++++++++++++++++++++++ 6 files changed, 88 insertions(+), 62 deletions(-) delete mode 100755 host/Rory-postgres/configuration.nix create mode 100755 host/Spacebar-nginx/hosts/spacebar.chat/mail.nix delete mode 100755 host/Spacebar-nginx/hosts/spacebar.chat/root.nix create mode 100755 host/Spacebar-postgres/configuration.nix diff --git a/flake.nix b/flake.nix index 7c51186..aa30222 100755 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,28 @@ specialArgs = { inherit home-manager; }; + }; + Spacebar-synapse = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./host/Spacebar-synapse/configuration.nix + ./hardware-configuration.nix + home-manager.nixosModules.home-manager + ]; + specialArgs = { + inherit home-manager; + }; + }; + Spacebar-postgres = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./host/Spacebar-postgres/configuration.nix + ./hardware-configuration.nix + home-manager.nixosModules.home-manager + ]; + specialArgs = { + inherit home-manager; + }; }; }; }; diff --git a/host/Rory-postgres/configuration.nix b/host/Rory-postgres/configuration.nix deleted file mode 100755 index 33e4f6b..0000000 --- a/host/Rory-postgres/configuration.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - imports = - [ - ../../modules/base.nix - ]; - - networking = { - hostName = "Spacebar-postgres"; - interfaces.ens18.ipv4.addresses = [ { - address = "192.168.1.3"; - prefixLength = 24; - } ]; - interfaces.ens19.ipv4.addresses = [ { - address = "10.10.11.3"; - prefixLength = 16; - } ]; - }; - - systemd.tmpfiles.rules = [ "d /data/pg 0750 postgres postgres" ]; - - services.postgresql = { - enable = true; - package = pkgs.postgresql_14; - enableTCPIP = true; - authentication = pkgs.lib.mkOverride 10 '' - # TYPE, DATABASE, USER, ADDRESS, METHOD - local all all trust - host all all 127.0.0.1/32 trust - host all all ::1/128 trust - host matrix-synapse-spacebar-chat matrix-synapse-spacebar-chat 192.168.1.5/32 trust - host all all 0.0.0.0/0 md5 - ''; - initialScript = pkgs.writeText "backend-initScript" '' - CREATE ROLE matrix-synapse-spacebar-chat WITH LOGIN PASSWORD '${pkgs.postgresql_14}' CREATEDB; - CREATE DATABASE matrix-synapse-spacebar-chat; - GRANT ALL PRIVILEGES ON DATABASE matrix-synapse-spacebar-chat TO matrix-synapse-spacebar-chat; - ''; - dataDir = "/data/pg"; - settings = { - "max_connections" = "100"; - "shared_buffers" = "128MB"; - "max_wal_size" = "1GB"; - "min_wal_size" = "80MB"; - }; - }; - - system.stateVersion = "22.11"; # DO NOT EDIT! -} - diff --git a/host/Spacebar-nginx/configuration.nix b/host/Spacebar-nginx/configuration.nix index 19b8dc0..21da3b4 100755 --- a/host/Spacebar-nginx/configuration.nix +++ b/host/Spacebar-nginx/configuration.nix @@ -3,7 +3,7 @@ { imports = [ - ../../modules/base-server.nix + ../../modules/base.nix ]; networking = { diff --git a/host/Spacebar-nginx/hosts/spacebar.chat/mail.nix b/host/Spacebar-nginx/hosts/spacebar.chat/mail.nix new file mode 100755 index 0000000..3ca873d --- /dev/null +++ b/host/Spacebar-nginx/hosts/spacebar.chat/mail.nix @@ -0,0 +1,14 @@ +{ + enableACME = true; + forceSSL = true; + locations = { + "/" = { + proxyPass = "http://192.168.1.3"; + proxyWebsockets = true; + extraConfig = + "proxy_ssl_server_name on;" + + "proxy_pass_header Authorization;" + ; + }; + }; +} diff --git a/host/Spacebar-nginx/hosts/spacebar.chat/root.nix b/host/Spacebar-nginx/hosts/spacebar.chat/root.nix deleted file mode 100755 index a859950..0000000 --- a/host/Spacebar-nginx/hosts/spacebar.chat/root.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - root = "/data/nginx/html_boorunav"; - enableACME = true; - addSSL = true; - locations = { - "/" = { - index = "index.html"; - }; - }; -} \ No newline at end of file diff --git a/host/Spacebar-postgres/configuration.nix b/host/Spacebar-postgres/configuration.nix new file mode 100755 index 0000000..b40fd3a --- /dev/null +++ b/host/Spacebar-postgres/configuration.nix @@ -0,0 +1,51 @@ +{ config, pkgs, lib, ... }: + +{ + imports = + [ + ../../modules/base.nix + ]; + + networking = { + hostName = "Spacebar-postgres"; + interfaces.ens18.ipv4.addresses = [ { + address = "192.168.1.4"; + prefixLength = 24; + } ]; + interfaces.ens19.ipv4.addresses = [ { + address = "10.10.11.4"; + prefixLength = 16; + } ]; + }; + + systemd.tmpfiles.rules = [ "d /data/pg 0750 postgres postgres" ]; + + services.postgresql = { + enable = true; + package = pkgs.postgresql_14; + enableTCPIP = true; + authentication = pkgs.lib.mkOverride 10 '' + # TYPE, DATABASE, USER, ADDRESS, METHOD + local all all trust + host all all 127.0.0.1/32 trust + host all all ::1/128 trust + host matrix-synapse-spacebar-chat matrix-synapse-spacebar-chat 192.168.1.5/32 trust + host all all 0.0.0.0/0 md5 + ''; + initialScript = pkgs.writeText "backend-initScript" '' + CREATE ROLE matrix-synapse-spacebar-chat WITH LOGIN PASSWORD '${pkgs.postgresql_14}' CREATEDB; + CREATE DATABASE matrix-synapse-spacebar-chat; + GRANT ALL PRIVILEGES ON DATABASE matrix-synapse-spacebar-chat TO matrix-synapse-spacebar-chat; + ''; + dataDir = "/data/pg"; + settings = { + "max_connections" = "100"; + "shared_buffers" = "128MB"; + "max_wal_size" = "1GB"; + "min_wal_size" = "80MB"; + }; + }; + + system.stateVersion = "22.11"; # DO NOT EDIT! +} + -- cgit 1.4.1