summary refs log tree commit diff
path: root/host
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-02-17 09:16:57 +0100
committerRory& <root@rory.gay>2025-02-17 09:16:57 +0100
commit96e147cc8f39530fb2defb2319964e0c61d28f3c (patch)
tree4d9f6bd3befb3d15f52f39989d169d2236517b89 /host
parentSome server replacement work (diff)
downloadRory-Open-Architecture-96e147cc8f39530fb2defb2319964e0c61d28f3c.tar.xz
Synapse work
Diffstat (limited to 'host')
-rw-r--r--host/Rory-nginx-old/configuration.nix3
-rwxr-xr-xhost/Rory-nginx/configuration.nix9
-rwxr-xr-xhost/Rory-nginx/services/containers/draupnir-linux-mint/container.nix32
-rwxr-xr-xhost/Rory-nginx/services/containers/draupnir-linux-mint/root.nix16
-rwxr-xr-xhost/Rory-nginx/services/containers/draupnir-linux-mint/services/draupnir.nix26
-rwxr-xr-xhost/Rory-nginx/services/containers/matrixunittests-conduit/container.nix30
-rwxr-xr-xhost/Rory-nginx/services/containers/matrixunittests-conduit/services/conduit.nix20
-rwxr-xr-xhost/Rory-nginx/services/containers/matrixunittests-conduit/services/nginx.nix94
-rwxr-xr-xhost/Rory-nginx/services/containers/matrixunittests/container.nix31
-rwxr-xr-xhost/Rory-nginx/services/containers/matrixunittests/services/conduit.nix43
-rwxr-xr-xhost/Rory-nginx/services/containers/matrixunittests/services/nginx.nix94
-rwxr-xr-xhost/Rory-nginx/services/containers/pluralcontactbotpoc/container.nix29
-rwxr-xr-xhost/Rory-nginx/services/containers/pluralcontactbotpoc/root.nix10
-rwxr-xr-xhost/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix39
-rwxr-xr-xhost/Rory-nginx/services/containers/pluralcontactbotpoc/services/nginx.nix94
-rwxr-xr-xhost/Rory-nginx/services/containers/pluralcontactbotpoc/services/pantalaimon.nix15
-rwxr-xr-xhost/Rory-nginx/services/matrix/grapevine.nix1
-rw-r--r--host/Rory-nginx/services/matrix/synapse/caches.nix1
-rwxr-xr-xhost/Rory-nginx/services/matrix/synapse/synapse-main.nix16
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/auth.nix107
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix107
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/event-creator.nix107
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix107
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/federation-reader.nix115
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix108
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/lib.nix147
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/media-repo.nix119
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/module.nix134
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/pusher.nix107
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix77
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/background.nix77
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix77
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/account_data-stream-writer.nix110
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix109
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/presence-stream-writer.nix110
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/push_rule-stream-writer.nix110
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/receipt-stream-writer.nix110
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/shared-stream-writer.nix119
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/to_device-stream-writer.nix110
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/typing-stream-writer.nix110
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/sync.nix107
-rwxr-xr-xhost/Rory-nginx/services/ollama.nix19
-rw-r--r--host/Rory-nginx/services/redpanda/root.nix10
-rw-r--r--host/Rory-nginx/services/redpanda/systemd-services.nix109
44 files changed, 15 insertions, 3110 deletions
diff --git a/host/Rory-nginx-old/configuration.nix b/host/Rory-nginx-old/configuration.nix

index 9096c4a..870c37f 100644 --- a/host/Rory-nginx-old/configuration.nix +++ b/host/Rory-nginx-old/configuration.nix
@@ -25,14 +25,13 @@ ./services/ollama.nix ./services/deluge.nix ./services/prometheus.nix - ./services/redpanda/root.nix ./services/email/root.nix ]; users.groups.ocp = { }; networking = { - hostName = "Rory-nginx"; + hostName = "Rory-nginx-old"; interfaces.ens18.ipv4.addresses = [ { address = "192.168.1.2"; diff --git a/host/Rory-nginx/configuration.nix b/host/Rory-nginx/configuration.nix
index 912e6fe..433b5db 100755 --- a/host/Rory-nginx/configuration.nix +++ b/host/Rory-nginx/configuration.nix
@@ -22,9 +22,7 @@ ./services/nginx/nginx.nix #./services/jitsi.nix ./services/cgit.nix - ./services/ollama.nix ./services/prometheus.nix - ./services/redpanda/root.nix ./services/email/root.nix ]; @@ -91,12 +89,7 @@ # inherit pkgs lib; # conduit = conduit; #}; - - services.pgadmin = { - enable = false; - initialEmail = "root@localhost.localdomain"; - initialPasswordFile = "/etc/matrix-user-pass"; - }; + containers."draupnir-cme" = import ./services/containers/draupnir-cme/container.nix { inherit pkgs lib nixpkgs-Draupnir; }; diff --git a/host/Rory-nginx/services/containers/draupnir-linux-mint/container.nix b/host/Rory-nginx/services/containers/draupnir-linux-mint/container.nix deleted file mode 100755
index 41d25c5..0000000 --- a/host/Rory-nginx/services/containers/draupnir-linux-mint/container.nix +++ /dev/null
@@ -1,32 +0,0 @@ -{ nixpkgs-Draupnir, ... }: - -{ - privateNetwork = true; - autoStart = true; - specialArgs = { - inherit nixpkgs-Draupnir; - }; - config = - { lib, pkgs, ... }: - { - imports = [ - ../shared.nix - ./root.nix - ./services/draupnir.nix - "${nixpkgs-Draupnir}/nixos/modules/services/matrix/draupnir.nix" - ]; - nixpkgs.overlays = [ - (final: prev: { - draupnir = nixpkgs-Draupnir.legacyPackages.${pkgs.stdenv.hostPlatform.system}.draupnir; - }) - ]; - }; - hostAddress = "192.168.100.1"; - localAddress = "192.168.100.19"; - - bindMounts."draupnir-access-token" = { - hostPath = "/etc/draupnir-linux-mint-access-token"; - mountPoint = "/etc/draupnir-access-token"; - isReadOnly = true; - }; -} diff --git a/host/Rory-nginx/services/containers/draupnir-linux-mint/root.nix b/host/Rory-nginx/services/containers/draupnir-linux-mint/root.nix deleted file mode 100755
index 2adac62..0000000 --- a/host/Rory-nginx/services/containers/draupnir-linux-mint/root.nix +++ /dev/null
@@ -1,16 +0,0 @@ -{ pkgs, ... }: - -{ - networking.useHostResolvConf = true; - - networking.hosts = { - "192.168.100.18" = [ - "matrix.rory.gay" - "rory.gay" - ]; - }; - - networking.firewall = { - enable = true; - }; -} diff --git a/host/Rory-nginx/services/containers/draupnir-linux-mint/services/draupnir.nix b/host/Rory-nginx/services/containers/draupnir-linux-mint/services/draupnir.nix deleted file mode 100755
index 042651a..0000000 --- a/host/Rory-nginx/services/containers/draupnir-linux-mint/services/draupnir.nix +++ /dev/null
@@ -1,26 +0,0 @@ -{ ... }: - -{ - services.draupnir = { - enable = true; - accessTokenFile = "/etc/draupnir-access-token"; - homeserverUrl = "https://matrix.rory.gay"; - - settings = { - managementRoom = "#draupnir-linux-mint:rory.gay"; - recordIgnoredInvites = true; # We want to be aware of invites - autojoinOnlyIfManager = true; # ... but we don't want the bot to be invited to eg. Matrix HQ... - automaticallyRedactForReasons = [ "*" ]; # Always autoredact - fasterMembershipChecks = true; - - backgroundDelayMS = 10; # delay isn't needed, I don't mind the performance hit - pollReports = false; - - admin.enableMakeRoomAdminCommand = false; - commands.ban.defaultReasons = [ - "spam" - "code of conduct violation" - ]; - }; - }; -} diff --git a/host/Rory-nginx/services/containers/matrixunittests-conduit/container.nix b/host/Rory-nginx/services/containers/matrixunittests-conduit/container.nix deleted file mode 100755
index daefba1..0000000 --- a/host/Rory-nginx/services/containers/matrixunittests-conduit/container.nix +++ /dev/null
@@ -1,30 +0,0 @@ -{ conduit, ... }: - -{ - privateNetwork = true; - autoStart = true; - specialArgs = { - inherit conduit; - }; - config = - { - lib, - pkgs, - conduit, - ... - }: - { - imports = [ - ../shared.nix - ./services/nginx.nix - ./services/conduit.nix - ]; - networking.useHostResolvConf = true; - networking.firewall = { - enable = true; - allowedTCPPorts = [ 80 ]; - }; - }; - hostAddress = "192.168.100.1"; - localAddress = "192.168.100.15"; -} diff --git a/host/Rory-nginx/services/containers/matrixunittests-conduit/services/conduit.nix b/host/Rory-nginx/services/containers/matrixunittests-conduit/services/conduit.nix deleted file mode 100755
index 3df71be..0000000 --- a/host/Rory-nginx/services/containers/matrixunittests-conduit/services/conduit.nix +++ /dev/null
@@ -1,20 +0,0 @@ -{ pkgs, conduit, ... }: - -{ - services.matrix-conduit = { - package = conduit.packages.${pkgs.system}.default; - enable = true; - settings.global = { - address = "127.0.0.1"; - server_name = "conduit.matrixunittests.rory.gay"; - database_backend = "rocksdb"; - enable_lightning_bolt = true; - max_concurrent_requests = 1000; - allow_check_for_updates = false; - allow_registration = true; - yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true; - allow_guest_registration = true; - disable_federation = true; - }; - }; -} diff --git a/host/Rory-nginx/services/containers/matrixunittests-conduit/services/nginx.nix b/host/Rory-nginx/services/containers/matrixunittests-conduit/services/nginx.nix deleted file mode 100755
index 0d7874e..0000000 --- a/host/Rory-nginx/services/containers/matrixunittests-conduit/services/nginx.nix +++ /dev/null
@@ -1,94 +0,0 @@ -{ pkgs, ... }: - -{ - services = { - nginx = { - enable = true; - package = pkgs.nginxQuic; - recommendedProxySettings = true; - recommendedTlsSettings = true; - recommendedZstdSettings = true; - recommendedGzipSettings = true; - recommendedBrotliSettings = true; - recommendedOptimisation = true; - appendConfig = '' - worker_processes 16; - ''; - eventsConfig = '' - #use kqueue; - worker_connections 512; - ''; - appendHttpConfig = '' - #sendfile on; - disable_symlinks off; - ''; - additionalModules = with pkgs.nginxModules; [ moreheaders ]; - virtualHosts = { - "conduit.matrixunittests.rory.gay" = { - locations."/" = { - proxyPass = "http://127.0.0.1:6167"; - extraConfig = '' - if ($request_method = 'OPTIONS') { - more_set_headers 'Access-Control-Allow-Origin: *'; - more_set_headers 'Access-Control-Allow-Methods: *'; - # - # Custom headers and headers various browsers *should* be OK with but aren't - # - more_set_headers 'Access-Control-Allow-Headers: *'; - # - # Tell client that this pre-flight info is valid for 20 days - # - more_set_headers 'Access-Control-Max-Age: 1728000'; - more_set_headers 'Content-Type: text/plain; charset=utf-8'; - more_set_headers 'Content-Length: 0'; - return 204; - } - ''; - }; - locations."= /.well-known/matrix/server".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${builtins.toJSON { "m.server" = "conduit.matrixunittests.rory.gay:443"; }}'; - ''; - locations."= /.well-known/matrix/client".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${builtins.toJSON { "m.homeserver".base_url = "https://conduit.matrixunittests.rory.gay"; }}'; - ''; - locations."= /.well-known/matrix/support".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${ - builtins.toJSON { - admins = [ - { - matrix_id = "@emma:rory.gay"; - role = "admin"; - } - { - matrix_id = "@alicia:rory.gay"; - role = "admin"; - } - { - matrix_id = "@root:rory.gay"; - role = "admin"; - } - { - matrix_id = "@rory:rory.gay"; - role = "admin"; - } - ]; - } - }'; - ''; - }; - }; - }; - }; - systemd.services.nginx.serviceConfig = { - LimitNOFILE = 5000000; - }; - security.acme.acceptTerms = true; - security.acme.defaults.email = "root@rory.gay"; - -} diff --git a/host/Rory-nginx/services/containers/matrixunittests/container.nix b/host/Rory-nginx/services/containers/matrixunittests/container.nix deleted file mode 100755
index cbd90f8..0000000 --- a/host/Rory-nginx/services/containers/matrixunittests/container.nix +++ /dev/null
@@ -1,31 +0,0 @@ -{ grapevine, ... }: - -{ - privateNetwork = true; - autoStart = true; - config = - { - lib, - pkgs, - ... - }: - { - imports = [ - ../shared.nix - ./services/nginx.nix - ./services/conduit.nix - grapevine.nixosModules.default - - ]; - networking.useHostResolvConf = true; - networking.firewall = { - enable = true; - allowedTCPPorts = [ - 80 - 5432 - ]; - }; - }; - hostAddress = "192.168.100.1"; - localAddress = "192.168.100.13"; -} diff --git a/host/Rory-nginx/services/containers/matrixunittests/services/conduit.nix b/host/Rory-nginx/services/containers/matrixunittests/services/conduit.nix deleted file mode 100755
index cd5776f..0000000 --- a/host/Rory-nginx/services/containers/matrixunittests/services/conduit.nix +++ /dev/null
@@ -1,43 +0,0 @@ -{ ... }: - -{ - services.grapevine = { - # package = conduit.packages.${pkgs.system}.default; - enable = true; - settings = { - server_name = "matrixunittests.rory.gay"; - allow_registration = true; - - listen = [ - { - type = "tcp"; - address = "127.0.0.1"; - port = 6167; - } - ]; - federation.enable = false; - server_discovery.client.base_url = "https://matrixunittests.rory.gay"; # This is required for some reason - - database = { - backend = "rocksdb"; - }; - }; - }; - - systemd.services.matrix-conduit-reg-token = { - enable = true; - description = "Random registration token for Conduit."; - wantedBy = [ "grapevine.service" ]; # So the registration can be used by Conduit. - - script = '' - rm -rfv /var/lib/grapevine/* - systemctl daemon-reload - systemctl try-restart grapevine.service''; - serviceConfig = { - User = "root"; - Group = "root"; - IgnoreSIGPIPE = true; - Restart = "on-failure"; - }; - }; -} diff --git a/host/Rory-nginx/services/containers/matrixunittests/services/nginx.nix b/host/Rory-nginx/services/containers/matrixunittests/services/nginx.nix deleted file mode 100755
index 0236182..0000000 --- a/host/Rory-nginx/services/containers/matrixunittests/services/nginx.nix +++ /dev/null
@@ -1,94 +0,0 @@ -{ pkgs, ... }: - -{ - services = { - nginx = { - enable = true; - package = pkgs.nginxQuic; - recommendedProxySettings = true; - recommendedTlsSettings = true; - recommendedZstdSettings = true; - recommendedGzipSettings = true; - recommendedBrotliSettings = true; - recommendedOptimisation = true; - appendConfig = '' - worker_processes 16; - ''; - eventsConfig = '' - #use kqueue; - worker_connections 512; - ''; - appendHttpConfig = '' - #sendfile on; - disable_symlinks off; - ''; - additionalModules = with pkgs.nginxModules; [ moreheaders ]; - virtualHosts = { - "matrixunittests.rory.gay" = { - locations."/" = { - proxyPass = "http://127.0.0.1:6167"; - extraConfig = '' - if ($request_method = 'OPTIONS') { - more_set_headers 'Access-Control-Allow-Origin: *'; - more_set_headers 'Access-Control-Allow-Methods: *'; - # - # Custom headers and headers various browsers *should* be OK with but aren't - # - more_set_headers 'Access-Control-Allow-Headers: *'; - # - # Tell client that this pre-flight info is valid for 20 days - # - more_set_headers 'Access-Control-Max-Age: 1728000'; - more_set_headers 'Content-Type: text/plain; charset=utf-8'; - more_set_headers 'Content-Length: 0'; - return 204; - } - ''; - }; - locations."= /.well-known/matrix/server".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${builtins.toJSON { "m.server" = "matrixunittests.rory.gay:443"; }}'; - ''; - locations."= /.well-known/matrix/client".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${builtins.toJSON { "m.homeserver".base_url = "https://matrixunittests.rory.gay"; }}'; - ''; - locations."= /.well-known/matrix/support".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${ - builtins.toJSON { - admins = [ - { - matrix_id = "@emma:rory.gay"; - role = "admin"; - } - { - matrix_id = "@alicia:rory.gay"; - role = "admin"; - } - { - matrix_id = "@root:rory.gay"; - role = "admin"; - } - { - matrix_id = "@rory:rory.gay"; - role = "admin"; - } - ]; - } - }'; - ''; - }; - }; - }; - }; - systemd.services.nginx.serviceConfig = { - LimitNOFILE = 5000000; - }; - security.acme.acceptTerms = true; - security.acme.defaults.email = "root@rory.gay"; - -} diff --git a/host/Rory-nginx/services/containers/pluralcontactbotpoc/container.nix b/host/Rory-nginx/services/containers/pluralcontactbotpoc/container.nix deleted file mode 100755
index 6be7c83..0000000 --- a/host/Rory-nginx/services/containers/pluralcontactbotpoc/container.nix +++ /dev/null
@@ -1,29 +0,0 @@ -{ conduit, ... }: - -{ - privateNetwork = true; - autoStart = true; - specialArgs = { - inherit conduit; - }; - config = - { - lib, - pkgs, - conduit, - ... - }: - { - imports = [ - ./root.nix - ../shared.nix - ]; - networking.useHostResolvConf = true; - networking.firewall = { - enable = true; - allowedTCPPorts = [ 80 ]; - }; - }; - hostAddress = "192.168.100.1"; - localAddress = "192.168.100.11"; -} diff --git a/host/Rory-nginx/services/containers/pluralcontactbotpoc/root.nix b/host/Rory-nginx/services/containers/pluralcontactbotpoc/root.nix deleted file mode 100755
index 11d0be3..0000000 --- a/host/Rory-nginx/services/containers/pluralcontactbotpoc/root.nix +++ /dev/null
@@ -1,10 +0,0 @@ -{ ... }: - -{ - imports = [ - ./services/nginx.nix - ./services/conduit.nix - ./services/pantalaimon.nix - ]; - -} diff --git a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix b/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix deleted file mode 100755
index db9df9a..0000000 --- a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix +++ /dev/null
@@ -1,39 +0,0 @@ -{ pkgs, conduit, ... }: - -{ - services.matrix-conduit = { - package = conduit.packages.${pkgs.system}.default; - enable = true; - settings.global = { - address = "127.0.0.1"; - server_name = "pcpoc.rory.gay"; - database_backend = "rocksdb"; - enable_lightning_bolt = true; - max_concurrent_requests = 1000; - allow_check_for_updates = false; - allow_registration = false; - }; - }; - - systemd.services.matrix-conduit-reg-token = { - enable = true; - description = "Random registration token for Conduit."; - wantedBy = [ "conduit.service" ]; # So the registration can be used by Conduit. - - script = '' - reg_token=`cat /dev/urandom | tr -dc a-zA-Z0-9 | head -c 256` - mkdir -p /run/systemd/system/conduit.service.d - echo $reg_token > /run/conduit-registration-token - echo "[Service]" > /run/systemd/system/conduit.service.d/override.conf - echo Environment=\"CONDUIT_REGISTRATION_TOKEN=$reg_token\" >> /run/systemd/system/conduit.service.d/override.conf - systemctl daemon-reload - systemctl try-restart conduit.service''; - serviceConfig = { - User = "root"; - Group = "root"; - IgnoreSIGPIPE = true; - Restart = "on-failure"; - }; - }; - -} diff --git a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/nginx.nix b/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/nginx.nix deleted file mode 100755
index 9d8041a..0000000 --- a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/nginx.nix +++ /dev/null
@@ -1,94 +0,0 @@ -{ pkgs, ... }: - -{ - services = { - nginx = { - enable = true; - package = pkgs.nginxQuic; - recommendedProxySettings = true; - recommendedTlsSettings = true; - recommendedZstdSettings = true; - recommendedGzipSettings = true; - recommendedBrotliSettings = true; - recommendedOptimisation = true; - appendConfig = '' - worker_processes 16; - ''; - eventsConfig = '' - #use kqueue; - worker_connections 512; - ''; - appendHttpConfig = '' - #sendfile on; - disable_symlinks off; - ''; - additionalModules = with pkgs.nginxModules; [ moreheaders ]; - virtualHosts = { - "pcpoc.rory.gay" = { - locations."/" = { - proxyPass = "http://127.0.0.1:6167"; - extraConfig = '' - if ($request_method = 'OPTIONS') { - more_set_headers 'Access-Control-Allow-Origin: *'; - more_set_headers 'Access-Control-Allow-Methods: *'; - # - # Custom headers and headers various browsers *should* be OK with but aren't - # - more_set_headers 'Access-Control-Allow-Headers: *'; - # - # Tell client that this pre-flight info is valid for 20 days - # - more_set_headers 'Access-Control-Max-Age: 1728000'; - more_set_headers 'Content-Type: text/plain; charset=utf-8'; - more_set_headers 'Content-Length: 0'; - return 204; - } - ''; - }; - locations."= /.well-known/matrix/server".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${builtins.toJSON { "m.server" = "pcpoc.rory.gay:443"; }}'; - ''; - locations."= /.well-known/matrix/client".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${builtins.toJSON { "m.homeserver".base_url = "https://pcpoc.rory.gay"; }}'; - ''; - locations."= /.well-known/matrix/support".extraConfig = '' - more_set_headers 'Content-Type application/json'; - more_set_headers 'Access-Control-Allow-Origin *'; - return 200 '${ - builtins.toJSON { - admins = [ - { - matrix_id = "@emma:rory.gay"; - role = "admin"; - } - { - matrix_id = "@alicia:rory.gay"; - role = "admin"; - } - { - matrix_id = "@root:rory.gay"; - role = "admin"; - } - { - matrix_id = "@rory:rory.gay"; - role = "admin"; - } - ]; - } - }'; - ''; - }; - }; - }; - }; - systemd.services.nginx.serviceConfig = { - LimitNOFILE = 5000000; - }; - security.acme.acceptTerms = true; - security.acme.defaults.email = "root@rory.gay"; - -} diff --git a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/pantalaimon.nix b/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/pantalaimon.nix deleted file mode 100755
index 335176f..0000000 --- a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/pantalaimon.nix +++ /dev/null
@@ -1,15 +0,0 @@ -{ ... }: - -{ - services.pantalaimon-headless = { - instances."localhost" = { - homeserver = "http://localhost:6167"; - ssl = false; - extraSettings = { - "DropOldKeys" = true; - "UseKeyring" = false; - }; - }; - }; - -} diff --git a/host/Rory-nginx/services/matrix/grapevine.nix b/host/Rory-nginx/services/matrix/grapevine.nix
index c73b48c..7368c2a 100755 --- a/host/Rory-nginx/services/matrix/grapevine.nix +++ b/host/Rory-nginx/services/matrix/grapevine.nix
@@ -7,6 +7,7 @@ conduit_compat = true; server_name = "conduit.rory.gay"; #trusted_servers = [ "rory.gay" ]; + federation.self_test = false; listen = [ { diff --git a/host/Rory-nginx/services/matrix/synapse/caches.nix b/host/Rory-nginx/services/matrix/synapse/caches.nix
index 9fa735e..f00c78c 100644 --- a/host/Rory-nginx/services/matrix/synapse/caches.nix +++ b/host/Rory-nginx/services/matrix/synapse/caches.nix
@@ -6,6 +6,7 @@ ]; gc_thresholds = [ 10000 + 5000 2500 ]; diff --git a/host/Rory-nginx/services/matrix/synapse/synapse-main.nix b/host/Rory-nginx/services/matrix/synapse/synapse-main.nix
index c823846..02456df 100755 --- a/host/Rory-nginx/services/matrix/synapse/synapse-main.nix +++ b/host/Rory-nginx/services/matrix/synapse/synapse-main.nix
@@ -75,7 +75,7 @@ max_long_retry_delay = "30s"; # rapid retry, small increments - destination_min_retry_interval = "5m"; # default=10m + destination_min_retry_interval = "1m"; # default=10m destination_max_retry_interval = "12h"; # default=7d destination_retry_multiplier = 1.2; # default=2 }; @@ -195,17 +195,23 @@ after = [ "network.target" ]; script = '' - + set -e -x -o pipefail + echo "Starting key generation" if [ ! -f "registration_shared_secret.txt" ] then - cat /dev/urandom | tr -dc a-zA-Z0-9 | fold -w 256 | head -n 1 > registration_shared_secret.txt + echo "Generating new key" + strace cat /dev/urandom | tr -dc a-zA-Z0-9 | fold -w 256 | head -n 1 > registration_shared_secret.txt + echo "Key generation complete" else - echo Not generating key, key exists; - fi''; + echo "Not generating key, key exists" + fi + echo "Script complete" + ''; serviceConfig = { User = "matrix-synapse"; Group = "matrix-synapse"; WorkingDirectory = "/var/lib/matrix-synapse"; + RemainAfterExit = true; }; }; diff --git a/host/Rory-nginx/services/matrix/synapse/workers/auth.nix b/host/Rory-nginx/services/matrix/synapse/workers/auth.nix deleted file mode 100644
index 3a4a697..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/auth.nix +++ /dev/null
@@ -1,107 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ./lib.nix; - dbGroup = "solo"; - workers = lib.range 0 (cfg.authWorkers - 1); - workerName = "auth"; - workerRoutes = workerLib.workerRoutes.auth; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.authWorkers > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix b/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix deleted file mode 100644
index 758d6de..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix +++ /dev/null
@@ -1,107 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ./lib.nix; - dbGroup = "medium"; - workers = lib.range 0 (cfg.clientReaders - 1); - workerName = "client_reader"; - workerRoutes = workerLib.workerRoutes.clientReader; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.clientReaders > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/event-creator.nix b/host/Rory-nginx/services/matrix/synapse/workers/event-creator.nix deleted file mode 100644
index c9c084d..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/event-creator.nix +++ /dev/null
@@ -1,107 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ./lib.nix; - dbGroup = "medium"; - workers = lib.range 0 (cfg.eventCreators - 1); - workerName = "event_creator"; - workerRoutes = workerLib.workerRoutes.eventCreator; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.eventCreators > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix b/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix deleted file mode 100644
index 6997764..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix +++ /dev/null
@@ -1,107 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ./lib.nix; - dbGroup = "medium"; - workers = lib.range 0 (cfg.federationReaders - 1); - workerName = "federation_inbound"; - workerRoutes = workerLib.workerRoutes.federationInbound; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.federationInboundWorkers > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/federation-reader.nix b/host/Rory-nginx/services/matrix/synapse/workers/federation-reader.nix deleted file mode 100644
index f231822..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/federation-reader.nix +++ /dev/null
@@ -1,115 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ./lib.nix; - dbGroup = "medium"; - workers = lib.range 0 (cfg.federationReaders - 1); - workerName = "federation_reader"; - workerRoutes = workerLib.workerRoutes.federationReader; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.federationReaders > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - - #virtualHosts."${cfg.nginxVirtualHostName}".locations."~ ^/_matrix/federation/(v1|v2)/invite/" = { - # proxyPass = "http://${workerName}-federation"; - # extraConfig = '' - # proxy_http_version 1.1; - # proxy_set_header Connection ""; - # ''; - #}; - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix b/host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix deleted file mode 100644
index 1cedcbb..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix +++ /dev/null
@@ -1,108 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.services.matrix-synapse; - dbGroup = "medium"; - workers = lib.range 0 (cfg.federationSenders - 1); - workerName = "federation_sender"; - workerRoutes = {}; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.federationSenders > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - send_federation = false; - federation_sender_instances = lib.map (index: "${workerName}-${toString index}") workers; - outbound_federation_restricted_to = lib.map (index: "${workerName}-${toString index}") workers; - worker_replication_secret = "${workerName}_secret"; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/lib.nix b/host/Rory-nginx/services/matrix/synapse/workers/lib.nix deleted file mode 100644
index c99e2ef..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/lib.nix +++ /dev/null
@@ -1,147 +0,0 @@ -{ - workerRoutes = { - sync.client = [ - "~ ^/_matrix/client/(v2_alpha|r0|v3)/sync$" - "~ ^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$" - "~ ^/_matrix/client/(api/v1|r0|v3)/initialSync$" - "~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$" - "~ ^/_matrix/client/unstable/org.matrix.simplified_msc3575/sync$" - ]; - - clientReader.client = [ - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/publicRooms$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/joined_members$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/context/.*$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state(/|$)" - "~ ^/_matrix/client/v1/rooms/.*/hierarchy$" - "~ ^/_matrix/client/(v1|unstable)/rooms/.*/relations/" - "~ ^/_matrix/client/v1/rooms/.*/threads$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/messages$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable/.*)/rooms/.*/aliases" - "~ ^/_matrix/client/v1/rooms/.*/timestamp_to_event$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/search" - "~ ^/_matrix/client/(r0|v3|unstable)/user/.*/filter(/|$)" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$" - "~ ^/_matrix/client/(r0|v3|unstable)/notifications$" - # e2ee - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/query$" - - # unstable - "~ ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$" - - # auth - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/3pid$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/whoami$" - "~ ^/_matrix/client/versions$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$" - "~ ^/_matrix/client/(r0|v3|unstable)/register$" - "~ ^/_matrix/client/(r0|v3|unstable)/register/available$" - "~ ^/_matrix/client/(r0|v3|unstable)/auth/.*/fallback/web$" - "~ ^/_matrix/client/(r0|v3|unstable)/password_policy$" - "~ ^/_matrix/client/(r0|v3|unstable)/capabilities$" - ]; - - eventCreator.client = [ - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/redact" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/send" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/(join|invite|leave|ban|unban|kick)$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/join/" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/knock/" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/profile/" - ]; - - federationInbound.federation = [ - "~ ^/_matrix/federation/(v1|v2)/send/" - ]; - - federationReader.federation = [ - "~ ^/_matrix/federation/(v1|v2)/event/" - "~ ^/_matrix/federation/(v1|v2)/state/" - "~ ^/_matrix/federation/(v1|v2)/state_ids/" - "~ ^/_matrix/federation/(v1|v2)/backfill/" - "~ ^/_matrix/federation/(v1|v2)/get_missing_events/" - "~ ^/_matrix/federation/(v1|v2)/publicRooms" - "~ ^/_matrix/federation/(v1|v2)/query/" - "~ ^/_matrix/federation/(v1|v2)/make_join/" - "~ ^/_matrix/federation/(v1|v2)/make_leave/" - "~ ^/_matrix/federation/(v1|v2)/send_join/" - "~ ^/_matrix/federation/(v1|v2)/send_leave/" - "~ ^/_matrix/federation/v1/make_knock/" - "~ ^/_matrix/federation/v1/send_knock/" - "~ ^/_matrix/federation/(v1|v2)/invite/" # Needs special handling, define manually - "~ ^/_matrix/federation/(v1|v2)/query_auth/" - "~ ^/_matrix/federation/(v1|v2)/event_auth/" - "~ ^/_matrix/federation/v1/timestamp_to_event/" - "~ ^/_matrix/federation/(v1|v2)/exchange_third_party_invite/" - "~ ^/_matrix/federation/(v1|v2)/user/devices/" - "~ ^/_matrix/federation/(v1|v2)/get_groups_publicised$" - "~ ^/_matrix/key/v2/query" - # extra - "~ ^/_matrix/key/v2/server$" - ]; - - mediaRepo.media = [ - "~ ^/_matrix/client/v1/media/" - "~ ^/_matrix/federation/v1/media/" - "~ ^/_synapse/admin/v1/purge_media_cache$" - "~ ^/_synapse/admin/v1/room/.*/media.*$" - "~ ^/_synapse/admin/v1/user/.*/media.*$" - "~ ^/_synapse/admin/v1/users/.*/media$" - "~ ^/_synapse/admin/v1/media/.*$" - "~ ^/_synapse/admin/v1/quarantine_media/.*$" - "~ ^/_matrix/media/" - ]; - - auth.client = [ - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/3pid$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/whoami$" - "~ ^/_matrix/client/versions$" - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$" - "~ ^/_matrix/client/(r0|v3|unstable)/register$" - "~ ^/_matrix/client/(r0|v3|unstable)/register/available$" - "~ ^/_matrix/client/(r0|v3|unstable)/auth/.*/fallback/web$" - "~ ^/_matrix/client/(r0|v3|unstable)/password_policy$" - "~ ^/_matrix/client/(r0|v3|unstable)/capabilities$" - ]; - - typing.client = [ - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/typing" - ]; - - toDevice.client = [ - "~ ^/_matrix/client/(r0|v3|unstable)/sendToDevice/" - ]; - - receipts.client = [ - "~ ^/_matrix/client/(r0|v3|unstable)/rooms/.*/receipt" - "~ ^/_matrix/client/(r0|v3|unstable)/rooms/.*/read_markers" - ]; - - pushRules.client = [ - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/pushrules/" - ]; - - presence.client = [ - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/presence/" - ]; - - accountData.client = [ - "~ ^/_matrix/client/(r0|v3|unstable)/account_data" - "~ ^/_matrix/client/(r0|v3|unstable)/rooms/.*/account_data" - "~ ^/_matrix/client/(r0|v3|unstable)/rooms/.*/tags" - ]; - - userDirectory.client = [ - "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$" - - #profile - "~ ^/_matrix/client/v3/profile/.*$" - "~ ^/_matrix/client/v3/profile/.*/(displayname|avatar_url)$" - ]; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/media-repo.nix b/host/Rory-nginx/services/matrix/synapse/workers/media-repo.nix deleted file mode 100644
index 46fd353..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/media-repo.nix +++ /dev/null
@@ -1,119 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ./lib.nix; - dbGroup = "solo"; - workers = lib.range 0 (cfg.mediaRepoWorkers - 1); - workerName = "media_repo"; - workerRoutes = workerLib.workerRoutes.mediaRepo; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.mediaRepoWorkers > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - media_instance_running_background_jobs = "${workerName}-0"; - enable_media_repo = false; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - enable_media_repo = true; - rc_federation = { - window_size = 1; - sleep_limit = 1000; - sleep_delay = 1; - reject_limit = 1000; - concurrent = 100; - }; - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - client_max_body_size 512M; - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/module.nix b/host/Rory-nginx/services/matrix/synapse/workers/module.nix deleted file mode 100644
index 3b6456b..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/module.nix +++ /dev/null
@@ -1,134 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.services.matrix-synapse; - mkIntOption = - description: - lib.mkOption { - type = lib.types.int; - default = 0; - description = description; - }; -in -{ - imports = [ - ./single/appservice.nix - ./single/background.nix - ./single/user-dir.nix - - ./auth.nix - ./client-reader.nix - ./event-creator.nix - ./federation-inbound.nix - ./federation-reader.nix - ./federation-sender.nix - ./media-repo.nix - ./pusher.nix - ./sync.nix - - ./stream-writers/account_data-stream-writer.nix - ./stream-writers/event-stream-writer.nix - ./stream-writers/presence-stream-writer.nix - ./stream-writers/push_rule-stream-writer.nix - ./stream-writers/receipt-stream-writer.nix - ./stream-writers/to_device-stream-writer.nix - ./stream-writers/typing-stream-writer.nix - - # ./stream-writers/shared-stream-writer.nix - ]; - options.services.matrix-synapse = { - enableWorkers = lib.mkEnableOption "Enable dedicated workers"; - enableStreamWriters = lib.mkEnableOption "Enable stream writers"; - enableAppserviceWorker = lib.mkEnableOption "Enable dedicated appservice worker"; - enableBackgroundWorker = lib.mkEnableOption "Enable dedicated background task worker"; - enableUserDirWorker = lib.mkEnableOption "Enable dedicated user directory worker"; - - authWorkers = mkIntOption "Number of auth workers"; - clientReaders = mkIntOption "Number of client readers"; - eventCreators = mkIntOption "Number of auth workers"; - federationInboundWorkers = mkIntOption "Number of federation inbound workers"; - federationReaders = mkIntOption "Number of federation readers"; - federationSenders = mkIntOption "Number of federation senders"; - mediaRepoWorkers = mkIntOption "Number of media repo workers"; - pushers = mkIntOption "Number of pushers"; - syncWorkers = mkIntOption "Number of sync workers"; - - #stream writers - eventStreamWriters = mkIntOption "Number of event stream writers"; - typingStreamWriters = mkIntOption "Number of typing stream writers"; - toDeviceStreamWriters = mkIntOption "Number of to_device stream writers"; - accountDataStreamWriters = mkIntOption "Number of account data stream writers"; - receiptStreamWriters = mkIntOption "Number of read receipt stream writers"; - presenceStreamWriters = mkIntOption "Number of presence stream writers"; - pushRuleStreamWriters = mkIntOption "Number of push rule stream writers"; - - sharedStreamWriters = mkIntOption "Number of shared stream writers"; - - nginxVirtualHostName = lib.mkOption { - type = lib.types.str; - default = null; - description = "The virtual host name for the nginx server"; - }; - - allowedRemoteInviteOrigins = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = [ ]; - description = "List of allowed remote invite origins"; - }; - }; - - config = { - assertions = [ - { - assertion = cfg.enableWorkers -> cfg.nginxVirtualHostName != null; - message = "nginxVirtualHostName must be set when enableWorkers is true"; - } - - # Stream types and count limitations: https://github.com/element-hq/synapse/blob/develop/synapse/config/workers.py#L344 - { - assertion = cfg.typingStreamWriters <= 1; - message = "Only one typing stream writer is supported"; - } - { - assertion = cfg.toDeviceStreamWriters <= 1; - message = "Only one to_device stream writer is supported"; - } - { - assertion = cfg.accountDataStreamWriters <= 1; - message = "Only one account data stream writer is supported"; - } - # This may be outdated in the documentation...? - #{ - # assertion = cfg.receiptStreamWriters <= 1; - # message = "Only one receipt stream writer is supported"; - #} - { - assertion = cfg.presenceStreamWriters <= 1; - message = "Only one presence stream writer is supported"; - } - { - assertion = cfg.pushRuleStreamWriters <= 1; - message = "Only one push rule stream writer is supported"; - } - - { - assertion = cfg.sharedStreamWriters <= 1; - message = "Only one shared stream writer is supported"; - } - ]; - - # Matrix utility maps - services.nginx.appendHttpConfig = '' - # Map authorization header to origin name - map $http_authorization $mx_origin_name { - default ""; - "~*X-Matrix origin=(?<origin>[^,]+)" $origin; - } - - # Map origin name to whether it can invite - map $mx_origin_name $mx_can_invite { - default 0; - ${lib.concatMapStringsSep "\n" (origin: " \"${origin}\" 1;") cfg.allowedRemoteInviteOrigins} - } - ''; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/pusher.nix b/host/Rory-nginx/services/matrix/synapse/workers/pusher.nix deleted file mode 100644
index 5267838..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/pusher.nix +++ /dev/null
@@ -1,107 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.services.matrix-synapse; - dbGroup = "small"; - workers = lib.range 0 (cfg.pushers - 1); - workerName = "pusher"; - workerRoutes = {}; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.pushers > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "pusher-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - pusher_instances = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix deleted file mode 100644
index 03a080b..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix +++ /dev/null
@@ -1,77 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "small"; - workerName = "appservice"; - tasks = [ "appservice" ]; - workerRoutes = {}; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (lib.length tasks > 0) { - monitoring.synapse.workerNames = [ workerName ]; - services.matrix-synapse = { - settings = { - instance_map = { - ${workerName} = { - path = "/run/matrix-synapse/${workerName}.sock"; - }; - }; - - run_background_tasks_on = lib.mkIf (lib.elem "background" tasks) workerName; - notify_appservices_from_worker = lib.mkIf (lib.elem "appservice" tasks) workerName; - update_user_directory_from_worker = lib.mkIf (lib.elem "user_directory" tasks) workerName; - }; - - workers = { - ${workerName} = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - - database = (import ../../db.nix { inherit workerName dbGroup; }); - }; - }; - }; - - services.nginx = { - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock"; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix deleted file mode 100644
index 741b88c..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix +++ /dev/null
@@ -1,77 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "small"; - workerName = "background"; - tasks = [ "background" ]; - workerRoutes = { }; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (lib.length tasks > 0) { - monitoring.synapse.workerNames = [ workerName ]; - services.matrix-synapse = { - settings = { - instance_map = { - ${workerName} = { - path = "/run/matrix-synapse/${workerName}.sock"; - }; - }; - - run_background_tasks_on = lib.mkIf (lib.elem "background" tasks) workerName; - notify_appservices_from_worker = lib.mkIf (lib.elem "appservice" tasks) workerName; - update_user_directory_from_worker = lib.mkIf (lib.elem "user_directory" tasks) workerName; - }; - - workers = { - ${workerName} = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - - database = (import ../../db.nix { inherit workerName dbGroup; }); - }; - }; - }; - - services.nginx = { - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock"; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix deleted file mode 100644
index 97ddf26..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix +++ /dev/null
@@ -1,77 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "small"; - workerName = "user_dir"; - tasks = [ "user_directory" ]; - workerRoutes = workerLib.workerRoutes.userDirectory; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (lib.length tasks > 0) { - monitoring.synapse.workerNames = [ workerName ]; - services.matrix-synapse = { - settings = { - instance_map = { - ${workerName} = { - path = "/run/matrix-synapse/${workerName}.sock"; - }; - }; - - run_background_tasks_on = lib.mkIf (lib.elem "background" tasks) workerName; - notify_appservices_from_worker = lib.mkIf (lib.elem "appservice" tasks) workerName; - update_user_directory_from_worker = lib.mkIf (lib.elem "user_directory" tasks) workerName; - }; - - workers = { - ${workerName} = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - - database = (import ../../db.nix { inherit workerName dbGroup; }); - }; - }; - }; - - services.nginx = { - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock"; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/account_data-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/account_data-stream-writer.nix deleted file mode 100644
index b1cc986..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/account_data-stream-writer.nix +++ /dev/null
@@ -1,110 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "medium"; - streamWriterType = "account_data"; - workers = lib.range 0 (cfg.accountDataStreamWriters - 1); - workerName = "account_data_stream_writer"; - workerRoutes = workerLib.workerRoutes.accountData; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.accountDataStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.${streamWriterType} = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix deleted file mode 100644
index 1459d6b..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix +++ /dev/null
@@ -1,109 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - dbGroup = "medium"; - streamWriterType = "events"; - workers = lib.range 0 (cfg.eventStreamWriters - 1); - workerName = "event_stream_writer"; - workerRoutes = {}; - enabledResources = []; -in -{ - config = lib.mkIf (cfg.eventStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.${streamWriterType} = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/presence-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/presence-stream-writer.nix deleted file mode 100644
index a417ce5..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/presence-stream-writer.nix +++ /dev/null
@@ -1,110 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "medium"; - streamWriterType = "presence"; - workers = lib.range 0 (cfg.presenceStreamWriters - 1); - workerName = "presence_stream_writer"; - workerRoutes = workerLib.workerRoutes.presence; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.presenceStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.${streamWriterType} = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/push_rule-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/push_rule-stream-writer.nix deleted file mode 100644
index f5210b2..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/push_rule-stream-writer.nix +++ /dev/null
@@ -1,110 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "medium"; - streamWriterType = "push_rules"; - workers = lib.range 0 (cfg.pushRuleStreamWriters - 1); - workerName = "push_rule_stream_writer"; - workerRoutes = workerLib.workerRoutes.pushRules; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.pushRuleStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.${streamWriterType} = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/receipt-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/receipt-stream-writer.nix deleted file mode 100644
index 3ef84dc..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/receipt-stream-writer.nix +++ /dev/null
@@ -1,110 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "medium"; - streamWriterType = "receipts"; - workers = lib.range 0 (cfg.receiptStreamWriters - 1); - workerName = "receipts_stream_writer"; - workerRoutes = workerLib.workerRoutes.receipts; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.receiptStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.${streamWriterType} = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/shared-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/shared-stream-writer.nix deleted file mode 100644
index 72ba834..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/shared-stream-writer.nix +++ /dev/null
@@ -1,119 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - dbGroup = "medium"; - streamWriterType = "shared"; # unused, from template - workers = lib.range 0 (cfg.presenceStreamWriters - 1); - workerName = "shared_stream_writer"; - workerRoutes = { - client = [ ]; - federation = [ ]; - media = [ ]; - }; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.sharedStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.account_data = lib.map (index: "${workerName}-${toString index}") workers; - stream_writers.events = lib.map (index: "${workerName}-${toString index}") workers; - stream_writers.presence = lib.map (index: "${workerName}-${toString index}") workers; - stream_writers.push_rules = lib.map (index: "${workerName}-${toString index}") workers; - stream_writers.receipts = lib.map (index: "${workerName}-${toString index}") workers; - stream_writers.to_device = lib.map (index: "${workerName}-${toString index}") workers; - stream_writers.typing = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/to_device-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/to_device-stream-writer.nix deleted file mode 100644
index bc32e0a..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/to_device-stream-writer.nix +++ /dev/null
@@ -1,110 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "medium"; - streamWriterType = "to_device"; - workers = lib.range 0 (cfg.toDeviceStreamWriters - 1); - workerName = "to_device_stream_writer"; - workerRoutes = workerLib.workerRoutes.toDevice; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.toDeviceStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.${streamWriterType} = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/typing-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/typing-stream-writer.nix deleted file mode 100644
index a57d0d8..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/typing-stream-writer.nix +++ /dev/null
@@ -1,110 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ../lib.nix; - dbGroup = "medium"; - streamWriterType = "typing"; - workers = lib.range 0 (cfg.typingStreamWriters - 1); - workerName = "typing_stream_writer"; - workerRoutes = workerLib.workerRoutes.typing; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.typingStreamWriters > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - - stream_writers.${streamWriterType} = lib.map (index: "${workerName}-${toString index}") workers; - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/sync.nix b/host/Rory-nginx/services/matrix/synapse/workers/sync.nix deleted file mode 100644
index 6a64a7e..0000000 --- a/host/Rory-nginx/services/matrix/synapse/workers/sync.nix +++ /dev/null
@@ -1,107 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.services.matrix-synapse; - workerLib = import ./lib.nix; - dbGroup = "medium"; - workers = lib.range 0 (cfg.syncWorkers - 1); - workerName = "sync"; - workerRoutes = workerLib.workerRoutes.sync; - enabledResources = lib.attrNames workerRoutes; -in -{ - config = lib.mkIf (cfg.syncWorkers > 0) { - monitoring.synapse.workerNames = lib.map (index: "${workerName}-${toString index}") workers; - services.matrix-synapse = { - settings = { - instance_map = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - }; - }) workers - ); - }; - - workers = lib.listToAttrs ( - lib.map (index: { - name = "${workerName}-${toString index}"; - value = { - worker_app = "synapse.app.generic_worker"; - worker_listeners = - [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - ] - ++ lib.map (type: { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - mode = "666"; - resources = [ - { - names = [ type ]; - compress = false; - } - ]; - }) enabledResources; - database = ( - import ../db.nix { - inherit dbGroup; - workerName = "${workerName}-${toString index}"; - } - ); - }; - }) workers - ); - }; - - services.nginx = { - upstreams = lib.listToAttrs ( - lib.map (type: { - name = "${workerName}-${type}"; - value = { - extraConfig = '' - keepalive 32; - least_conn; - ''; - servers = lib.listToAttrs ( - lib.map (index: { - name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; - value = { - max_fails = 0; - }; - }) workers - ); - }; - }) enabledResources - ); - - virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( - lib.flatten ( - lib.forEach enabledResources ( - type: - lib.map (route: { - name = route; - value = { - proxyPass = "http://${workerName}-${type}"; - extraConfig = '' - proxy_http_version 1.1; - proxy_set_header Connection ""; - ''; - }; - }) workerRoutes.${type} - ) - ) - ); - }; - }; -} diff --git a/host/Rory-nginx/services/ollama.nix b/host/Rory-nginx/services/ollama.nix deleted file mode 100755
index 16f4e1c..0000000 --- a/host/Rory-nginx/services/ollama.nix +++ /dev/null
@@ -1,19 +0,0 @@ -{ ... }: - -{ - # systemd.tmpfiles.rules = [ "d /data/ollama 0750 ostgres postgres" ]; - - services.ollama = { - enable = true; - home = "/data/ollama/home"; - models = "/data/ollama/home/models"; - environmentVariables = { - OLLAMA_LLM_LIBRARY = "cpu_avx2"; - }; - #listenAddress = "0.0.0.0:11434"; - host = "0.0.0.0"; - port = 11434; - user = "ollama"; - group = "ollama"; - }; -} diff --git a/host/Rory-nginx/services/redpanda/root.nix b/host/Rory-nginx/services/redpanda/root.nix deleted file mode 100644
index ef169a6..0000000 --- a/host/Rory-nginx/services/redpanda/root.nix +++ /dev/null
@@ -1,10 +0,0 @@ -{ ... }: -{ - imports = [ - ./systemd-services.nix - ]; - - services.redpanda-connect = { - enable = true; - }; -} diff --git a/host/Rory-nginx/services/redpanda/systemd-services.nix b/host/Rory-nginx/services/redpanda/systemd-services.nix deleted file mode 100644
index c75a5be..0000000 --- a/host/Rory-nginx/services/redpanda/systemd-services.nix +++ /dev/null
@@ -1,109 +0,0 @@ -{ pkgs, lib, ... }: -{ - services.redpanda-connect.pipelines.systemd-services = { - enable = true; - allowSudo = true; - config = { - http = { - enabled = true; - address = "127.0.0.1:5100"; - }; - input = { - label = ""; - subprocess = { - name = "${pkgs.systemd}/bin/systemctl"; - args = [ - "-ojson" - "--recursive" - ]; - restart_on_exit = true; - max_buffer = 1024 * 512; - }; - }; - pipeline = { - processors = [ - { unarchive.format = "json_array"; } - { - mapping = '' - root = this - if this.load == "loaded" { - root.loaded_value = 1.0 - } else { - root.loaded_value = 0.0 - } - if this.active == "active" { - root.active_value = 1.0 - } else if this.active == "activating" { - root.active_value = 0.5 - } else { - root.active_value = 0.0 - } - if this.sub == "active" { - root.sub_value = 1.0 - } else if this.sub == "auto-restart" { - root.sub_value = 0.5 - } else { - root.sub_value = 0.0 - } - ''; - } - { - metric = { - name = "systemd_service_status"; - type = "gauge"; - value = "\${!json(\"loaded_value\")}"; - labels = { - field = "load"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - { - metric = { - name = "systemd_service_status"; - type = "gauge"; - value = "\${!json(\"active_value\")}"; - labels = { - field = "active"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - { - metric = { - name = "systemd_service_status"; - type = "gauge"; - value = "\${!json(\"sub_value\")}"; - labels = { - field = "sub"; - service = "\${!json(\"unit\")}"; - description = "\${!json(\"description\")}"; - }; - }; - } - { - sleep.duration = "5s"; - } - ]; - }; - metrics.prometheus = { }; - output.drop = { }; - }; - }; - - services.prometheus.scrapeConfigs = [ - { - job_name = "redpanda-connect"; - scrape_interval = "5s"; - static_configs = [ - { - targets = [ "localhost:5100" ]; - labels.instance = "redpanda-connect"; - } - ]; - metrics_path = "/metrics"; - } - ]; -}