From d6cc9c81640b0950606071313a33c995a27649e5 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sat, 26 Oct 2024 02:03:31 +0200 Subject: [PATCH 01/11] matrix-authentication-service: init host underground to test mas, related to #242 --- flake.lock | 17 + flake.nix | 5 + hosts/default.nix | 24 + hosts/nachtigall/configuration.nix | 45 ++ hosts/underground/configuration.nix | 107 ++++ hosts/underground/default.nix | 16 + hosts/underground/hardware-configuration.nix | 34 ++ hosts/underground/networking.nix | 24 + modules/coturn/default.nix | 6 +- modules/matrix-irc/default.nix | 5 - modules/matrix/default.nix | 540 +++++++++--------- modules/nginx-matrix/default.nix | 55 +- .../nginx-matrix/element-client-config.nix | 6 +- overlays/default.nix | 1 + ... nachtigall-coturn-static-auth-secret.age} | 0 ...all-matrix-synapse-secret-config.yaml.age} | Bin ...nachtigall-matrix-synapse-signing-key.age} | Bin ...ll-matrix-synapse-sliding-sync-secret.age} | 0 secrets/secrets.nix | 14 +- ...thentication-service-secret-config.yml.age | Bin 0 -> 6263 bytes ...ound-matrix-synapse-secret-config.yaml.age | Bin 0 -> 4219 bytes terraform/dns.tf | 32 +- 22 files changed, 630 insertions(+), 301 deletions(-) create mode 100644 hosts/underground/configuration.nix create mode 100644 hosts/underground/default.nix create mode 100644 hosts/underground/hardware-configuration.nix create mode 100644 hosts/underground/networking.nix rename secrets/{coturn-static-auth-secret.age => nachtigall-coturn-static-auth-secret.age} (100%) rename secrets/{matrix-synapse-secret-config.yaml.age => nachtigall-matrix-synapse-secret-config.yaml.age} (100%) rename secrets/{matrix-synapse-signing-key.age => nachtigall-matrix-synapse-signing-key.age} (100%) rename secrets/{matrix-synapse-sliding-sync-secret.age => nachtigall-matrix-synapse-sliding-sync-secret.age} (100%) create mode 100644 secrets/underground-matrix-authentication-service-secret-config.yml.age create mode 100644 secrets/underground-matrix-synapse-secret-config.yaml.age diff --git a/flake.lock b/flake.lock index ae964ea..8c96268 100644 --- a/flake.lock +++ b/flake.lock @@ -234,6 +234,22 @@ "type": "github" } }, + "fork": { + "locked": { + "lastModified": 1729963002, + "narHash": "sha256-2zrYfd/qdfExU5zVwvH80uJnKc/dMeK6zp3O1UtW2Mo=", + "owner": "teutat3s", + "repo": "nixpkgs", + "rev": "005faaacbeede0296dec5c844f508027ab8a3ff6", + "type": "github" + }, + "original": { + "owner": "teutat3s", + "ref": "init-matrix-authentication-service-module", + "repo": "nixpkgs", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -354,6 +370,7 @@ "element-stickers": "element-stickers", "element-themes": "element-themes", "flake-parts": "flake-parts", + "fork": "fork", "home-manager": "home-manager", "keycloak-theme-pub-solar": "keycloak-theme-pub-solar", "maunium-stickerpicker": "maunium-stickerpicker", diff --git a/flake.nix b/flake.nix index a417b49..923092c 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ # Track channels with commits tested and built by hydra nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + fork.url = "github:teutat3s/nixpkgs/init-matrix-authentication-service-module"; nix-darwin.url = "github:lnl7/nix-darwin/master"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; @@ -152,6 +153,10 @@ hostname = "tankstelle.wg.pub.solar"; sshUser = username; }; + underground = { + hostname = "80.244.242.3"; + sshUser = username; + }; trinkgenossin = { hostname = "trinkgenossin.wg.pub.solar"; sshUser = username; diff --git a/hosts/default.nix b/hosts/default.nix index 6f159d0..e7a8f2e 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -178,6 +178,30 @@ self.nixosModules.nginx ]; }; + + underground = self.inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + flake = { + inherit self inputs config; + }; + }; + modules = [ + self.inputs.agenix.nixosModules.default + self.nixosModules.home-manager + ./underground + self.nixosModules.overlays + self.nixosModules.unlock-luks-on-boot + self.nixosModules.core + + self.nixosModules.backups + self.nixosModules.keycloak + self.nixosModules.postgresql + self.nixosModules.matrix + self.nixosModules.matrix-irc + self.nixosModules.nginx + self.nixosModules.nginx-matrix + ]; + }; }; }; } diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index c226ed0..eb7e657 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -48,6 +48,7 @@ owner = "root"; }; + # keycloak age.secrets.keycloak-database-password = { file = "${flake.self}/secrets/keycloak-database-password.age"; mode = "600"; @@ -59,6 +60,50 @@ database-password-file = config.age.secrets.keycloak-database-password.path; }; + # matrix-synapse + age.secrets."nachtigall-matrix-synapse-signing-key" = { + file = "${flake.self}/secrets/nachtigall-matrix-synapse-signing-key.age"; + mode = "400"; + owner = "matrix-synapse"; + }; + + age.secrets."nachtigall-matrix-synapse-secret-config.yaml" = { + file = "${flake.self}/secrets/nachtigall-matrix-synapse-secret-config.yaml.age"; + mode = "400"; + owner = "matrix-synapse"; + }; + + age.secrets."nachtigall-matrix-synapse-sliding-sync-secret" = { + file = "${flake.self}/secrets/nachtigall-matrix-synapse-sliding-sync-secret.age"; + mode = "400"; + owner = "matrix-synapse"; + }; + + + pub-solar-os.matrix-synapse = { + enable = true; + signing_key_path = config.age.secrets."nachtigall-matrix-synapse-signing-key".path; + extra-config-files = [ + config.age.secrets."nachtigall-matrix-synapse-secret-config.yaml".path + + # The registration file is automatically generated after starting the + # appservice for the first time. + # cp /var/lib/mautrix-telegram/telegram-registration.yaml \ + # /var/lib/matrix-synapse/ + # chown matrix-synapse:matrix-synapse \ + # /var/lib/matrix-synapse/telegram-registration.yaml + "/var/lib/matrix-synapse/telegram-registration.yaml" + ]; + app-service-config-files = [ + "/var/lib/matrix-synapse/telegram-registration.yaml" + "/var/lib/matrix-appservice-irc/registration.yml" + # "/matrix-appservice-slack-registration.yaml" + # "/hookshot-registration.yml" + # "/matrix-mautrix-signal-registration.yaml" + # "/matrix-mautrix-telegram-registration.yaml" + ]; + }; + systemd.services.postgresql = { after = [ "var-lib-postgresql.mount" ]; requisite = [ "var-lib-postgresql.mount" ]; diff --git a/hosts/underground/configuration.nix b/hosts/underground/configuration.nix new file mode 100644 index 0000000..b53f5dd --- /dev/null +++ b/hosts/underground/configuration.nix @@ -0,0 +1,107 @@ +{ + flake, + config, + pkgs, + ... +}: +{ + # Use GRUB2 as the boot loader. + boot.loader.grub = { + enable = true; + devices = [ "/dev/vda" ]; + }; + + pub-solar-os.networking.domain = "test.pub.solar"; + + systemd.tmpfiles.rules = [ "f /tmp/dbf 1777 root root 10d password" ]; + + # keycloak + pub-solar-os.auth = { + enable = true; + database-password-file = "/tmp/dbf"; + }; + services.keycloak.database.createLocally = true; + + # matrix-synapse + # test.pub.solar /.well-known is required for federation + services.nginx.virtualHosts."${config.pub-solar-os.networking.domain}" = { + default = true; + enableACME = true; + forceSSL = true; + }; + + age.secrets."underground-matrix-synapse-secret-config.yaml" = { + file = "${flake.self}/secrets/underground-matrix-synapse-secret-config.yaml.age"; + mode = "400"; + owner = "matrix-synapse"; + }; + + age.secrets."underground-matrix-authentication-service-secret-config.yml" = { + file = "${flake.self}/secrets/underground-matrix-authentication-service-secret-config.yml.age"; + mode = "400"; + owner = "matrix-authentication-service"; + }; + + pub-solar-os.matrix-synapse = { + enable = true; + extra-config-files = [ + config.age.secrets."underground-matrix-synapse-secret-config.yaml".path + + # The registration file is automatically generated after starting the + # appservice for the first time. + # cp /var/lib/mautrix-telegram/telegram-registration.yaml \ + # /var/lib/matrix-synapse/ + # chown matrix-synapse:matrix-synapse \ + # /var/lib/matrix-synapse/telegram-registration.yaml + #"/var/lib/matrix-synapse/telegram-registration.yaml" + ]; + app-service-config-files = [ + "/var/lib/matrix-appservice-irc/registration.yml" + #"/var/lib/matrix-synapse/telegram-registration.yaml" + ]; + }; + + services.matrix-authentication-service = { + enable = true; + createDatabase = true; + extraConfigFiles = [ + config.age.secrets."underground-matrix-authentication-service-secret-config.yml".path + ]; + settings = { + http.public_base = "https://mas.${config.pub-solar-os.networking.domain}"; + http.issuer = "https://mas.${config.pub-solar-os.networking.domain}"; + http.listeners = [ + { + name = "web"; + resources = [ + { name = "discovery"; } + { name = "human"; } + { name = "oauth"; } + { name = "compat"; } + { name = "graphql"; } + { name = "assets"; path = "${config.services.matrix-authentication-service.package}/share/matrix-authentication-service/assets"; } + ]; + binds = [ + { host = "0.0.0.0"; port = 8090; } + ]; + proxy_protocol = false; + } + { + name = "internal"; + resources = [ + { name = "health"; } + ]; + binds = [ + { host = "0.0.0.0"; port = 8081; } + ]; + proxy_protocol = false; + } + ]; + passwords.enabled = false; + }; + }; + + services.openssh.openFirewall = true; + + system.stateVersion = "24.05"; +} diff --git a/hosts/underground/default.nix b/hosts/underground/default.nix new file mode 100644 index 0000000..5a612a4 --- /dev/null +++ b/hosts/underground/default.nix @@ -0,0 +1,16 @@ +{ flake, ... }: + +{ + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ./configuration.nix + + ./networking.nix + "${flake.inputs.fork}/nixos/modules/services//matrix/matrix-authentication-service.nix" + ]; + + disabledModules = [ + "services/matrix/matrix-authentication-service.nix " + ]; +} diff --git a/hosts/underground/hardware-configuration.nix b/hosts/underground/hardware-configuration.nix new file mode 100644 index 0000000..e4738a1 --- /dev/null +++ b/hosts/underground/hardware-configuration.nix @@ -0,0 +1,34 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + boot.initrd.luks.devices."cryptroot" = { + device = "/dev/disk/by-label/cryptroot"; + }; + + fileSystems."/" = + { device = "/dev/disk/by-label/root"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-label/boot"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-label/swap"; } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/hosts/underground/networking.nix b/hosts/underground/networking.nix new file mode 100644 index 0000000..3085c7b --- /dev/null +++ b/hosts/underground/networking.nix @@ -0,0 +1,24 @@ +{ + config, + pkgs, + flake, + ... +}: +{ + + networking.hostName = "underground"; + + networking = { + defaultGateway = { + address = "80.244.242.1"; + interface = "enp1s0"; + }; + nameservers = ["95.129.51.51" "80.244.244.244"]; + interfaces.enp1s0 = { + useDHCP = false; + ipv4.addresses = [ + { address = "80.244.242.3"; prefixLength = 29; } + ]; + }; + }; +} diff --git a/modules/coturn/default.nix b/modules/coturn/default.nix index d8635aa..a7d3e86 100644 --- a/modules/coturn/default.nix +++ b/modules/coturn/default.nix @@ -5,8 +5,8 @@ ... }: { - age.secrets."coturn-static-auth-secret" = { - file = "${flake.self}/secrets/coturn-static-auth-secret.age"; + age.secrets."nachtigall-coturn-static-auth-secret" = { + file = "${flake.self}/secrets/nachtigall-coturn-static-auth-secret.age"; mode = "400"; owner = "turnserver"; }; @@ -18,7 +18,7 @@ min-port = 49000; max-port = 50000; use-auth-secret = true; - static-auth-secret-file = "/run/agenix/coturn-static-auth-secret"; + static-auth-secret-file = "/run/agenix/nachtigall-coturn-static-auth-secret"; realm = "turn.${config.pub-solar-os.networking.domain}"; cert = "${config.security.acme.certs.${realm}.directory}/full.pem"; pkey = "${config.security.acme.certs.${realm}.directory}/key.pem"; diff --git a/modules/matrix-irc/default.nix b/modules/matrix-irc/default.nix index f64d25c..02217d2 100644 --- a/modules/matrix-irc/default.nix +++ b/modules/matrix-irc/default.nix @@ -16,11 +16,6 @@ let synapseClientPort = "${toString listenerWithClient.port}"; in { - systemd.services.matrix-appservice-irc.serviceConfig.SystemCallFilter = lib.mkForce [ - "@system-service @pkey" - "~@privileged @resources" - "@chown" - ]; services.matrix-appservice-irc = { enable = true; localpart = "irc_bot"; diff --git a/modules/matrix/default.nix b/modules/matrix/default.nix index 3165911..d8518d3 100644 --- a/modules/matrix/default.nix +++ b/modules/matrix/default.nix @@ -1,6 +1,7 @@ { flake, config, + lib, pkgs, ... }: @@ -9,304 +10,291 @@ let serverDomain = "${config.pub-solar-os.networking.domain}"; in { - age.secrets."matrix-synapse-signing-key" = { - file = "${flake.self}/secrets/matrix-synapse-signing-key.age"; - mode = "400"; - owner = "matrix-synapse"; + options.pub-solar-os.matrix-synapse = { + enable = lib.mkEnableOption "Enable matrix-synapse to run on the node"; + + app-service-config-files = lib.mkOption { + description = "List of app service config files"; + type = lib.types.listOf lib.types.str; + default = []; + }; + + extra-config-files = lib.mkOption { + description = "List of extra synapse config files"; + type = lib.types.listOf lib.types.str; + default = []; + }; + + signing_key_path = lib.mkOption { + description = "Path to file containing the signing key"; + type = lib.types.str; + default = "${config.services.matrix-synapse.dataDir}/homeserver.signing.key"; + }; }; - age.secrets."matrix-synapse-secret-config.yaml" = { - file = "${flake.self}/secrets/matrix-synapse-secret-config.yaml.age"; - mode = "400"; - owner = "matrix-synapse"; - }; - - age.secrets."matrix-synapse-sliding-sync-secret" = { - file = "${flake.self}/secrets/matrix-synapse-sliding-sync-secret.age"; - mode = "400"; - owner = "matrix-synapse"; - }; - - services.matrix-synapse = { - enable = true; - settings = { - server_name = serverDomain; - public_baseurl = "https://${publicDomain}/"; - database = { - name = "psycopg2"; - args = { - host = "/run/postgresql"; - cp_max = 10; - cp_min = 5; - database = "matrix"; + config = lib.mkIf config.pub-solar-os.matrix-synapse.enable { + services.matrix-synapse = { + enable = true; + settings = { + server_name = serverDomain; + public_baseurl = "https://${publicDomain}/"; + database = { + name = "psycopg2"; + args = { + host = "/run/postgresql"; + cp_max = 10; + cp_min = 5; + database = "matrix"; + }; + allow_unsafe_locale = false; + txn_limit = 0; }; - allow_unsafe_locale = false; - txn_limit = 0; - }; - listeners = [ - { - bind_addresses = [ "127.0.0.1" ]; - port = 8008; - resources = [ - { - compress = true; - names = [ "client" ]; - } - { - compress = false; - names = [ "federation" ]; - } - ]; - tls = false; - type = "http"; - x_forwarded = true; - } - { - bind_addresses = [ "127.0.0.1" ]; - port = 8012; - resources = [ { names = [ "metrics" ]; } ]; - tls = false; - type = "metrics"; - } - ]; + listeners = [ + { + bind_addresses = [ "127.0.0.1" ]; + port = 8008; + resources = [ + { + compress = true; + names = [ "client" ]; + } + { + compress = false; + names = [ "federation" ]; + } + ]; + tls = false; + type = "http"; + x_forwarded = true; + } + { + bind_addresses = [ "127.0.0.1" ]; + port = 8012; + resources = [ { names = [ "metrics" ]; } ]; + tls = false; + type = "metrics"; + } + ]; - account_threepid_delegates.msisdn = ""; - alias_creation_rules = [ - { - action = "allow"; - alias = "*"; - room_id = "*"; - user_id = "*"; - } - ]; - allow_guest_access = false; - allow_public_rooms_over_federation = true; - allow_public_rooms_without_auth = false; - auto_join_rooms = [ - "#community:${serverDomain}" - "#general:${serverDomain}" - ]; + account_threepid_delegates.msisdn = ""; + alias_creation_rules = [ + { + action = "allow"; + alias = "*"; + room_id = "*"; + user_id = "*"; + } + ]; + allow_guest_access = false; + allow_public_rooms_over_federation = true; + allow_public_rooms_without_auth = false; + auto_join_rooms = [ + "#community:${serverDomain}" + "#general:${serverDomain}" + ]; - autocreate_auto_join_rooms = true; - caches.global_factor = 0.5; + autocreate_auto_join_rooms = true; + caches.global_factor = 0.5; - default_room_version = "10"; - disable_msisdn_registration = true; - enable_media_repo = true; - enable_metrics = true; - mau_stats_only = true; - enable_registration = false; - enable_registration_captcha = false; - enable_registration_without_verification = false; - enable_room_list_search = true; - encryption_enabled_by_default_for_room_type = "off"; - event_cache_size = "100K"; - federation_rr_transactions_per_room_per_second = 50; - federation_client_minimum_tls_version = "1.2"; - forget_rooms_on_leave = true; - include_profile_data_on_invite = true; - instance_map = { }; - limit_profile_requests_to_users_who_share_rooms = false; + default_room_version = "10"; + disable_msisdn_registration = true; + enable_media_repo = true; + enable_metrics = true; + mau_stats_only = true; + enable_registration = false; + enable_registration_captcha = false; + enable_registration_without_verification = false; + enable_room_list_search = true; + encryption_enabled_by_default_for_room_type = "off"; + event_cache_size = "100K"; + federation_rr_transactions_per_room_per_second = 50; + federation_client_minimum_tls_version = "1.2"; + forget_rooms_on_leave = true; + include_profile_data_on_invite = true; + instance_map = { }; + limit_profile_requests_to_users_who_share_rooms = false; - max_spider_size = "10M"; - max_upload_size = "50M"; - media_storage_providers = [ ]; + max_spider_size = "10M"; + max_upload_size = "50M"; + media_storage_providers = [ ]; - password_config = { - enabled = false; - localdb_enabled = false; - pepper = ""; - }; + password_config = { + enabled = false; + localdb_enabled = false; + pepper = ""; + }; - presence.enabled = true; - push.include_content = false; + presence.enabled = true; + push.include_content = false; - rc_admin_redaction = { - burst_count = 50; - per_second = 1; - }; - rc_federation = { - concurrent = 3; - reject_limit = 50; - sleep_delay = 500; - sleep_limit = 10; - window_size = 1000; - }; - rc_invites = { - per_issuer = { + rc_admin_redaction = { + burst_count = 50; + per_second = 1; + }; + rc_federation = { + concurrent = 3; + reject_limit = 50; + sleep_delay = 500; + sleep_limit = 10; + window_size = 1000; + }; + rc_invites = { + per_issuer = { + burst_count = 10; + per_second = 0.3; + }; + per_room = { + burst_count = 10; + per_second = 0.3; + }; + per_user = { + burst_count = 5; + per_second = 3.0e-3; + }; + }; + rc_joins = { + local = { + burst_count = 10; + per_second = 0.1; + }; + remote = { + burst_count = 10; + per_second = 1.0e-2; + }; + }; + rc_login = { + account = { + burst_count = 3; + per_second = 0.17; + }; + address = { + burst_count = 3; + per_second = 0.17; + }; + failed_attempts = { + burst_count = 3; + per_second = 0.17; + }; + }; + rc_message = { burst_count = 10; - per_second = 0.3; + per_second = 0.2; }; - per_room = { - burst_count = 10; - per_second = 0.3; - }; - per_user = { - burst_count = 5; - per_second = 3.0e-3; - }; - }; - rc_joins = { - local = { - burst_count = 10; - per_second = 0.1; - }; - remote = { - burst_count = 10; - per_second = 1.0e-2; - }; - }; - rc_login = { - account = { + rc_registration = { burst_count = 3; per_second = 0.17; }; - address = { - burst_count = 3; - per_second = 0.17; - }; - failed_attempts = { - burst_count = 3; - per_second = 0.17; + redaction_retention_period = "7d"; + forgotten_room_retention_period = "7d"; + redis.enabled = false; + registration_requires_token = false; + registrations_require_3pid = [ "email" ]; + report_stats = false; + require_auth_for_profile_requests = false; + room_list_publication_rules = [ + { + action = "allow"; + alias = "*"; + room_id = "*"; + user_id = "*"; + } + ]; + + signing_key_path = config.pub-solar-os.matrix-synapse.signing_key_path; + + stream_writers = { }; + trusted_key_servers = [ { server_name = "matrix.org"; } ]; + suppress_key_server_warning = true; + + turn_allow_guests = false; + turn_uris = [ + "turn:${config.services.coturn.realm}:3478?transport=udp" + "turn:${config.services.coturn.realm}:3478?transport=tcp" + ]; + turn_user_lifetime = "1h"; + + url_preview_accept_language = [ + "en-US" + "en" + ]; + url_preview_enabled = true; + url_preview_ip_range_blacklist = [ + "127.0.0.0/8" + "10.0.0.0/8" + "172.16.0.0/12" + "192.168.0.0/16" + "100.64.0.0/10" + "192.0.0.0/24" + "169.254.0.0/16" + "192.88.99.0/24" + "198.18.0.0/15" + "192.0.2.0/24" + "198.51.100.0/24" + "203.0.113.0/24" + "224.0.0.0/4" + "::1/128" + "fe80::/10" + "fc00::/7" + "2001:db8::/32" + "ff00::/8" + "fec0::/10" + ]; + + user_directory = { + prefer_local_users = false; + search_all_users = false; }; + user_ips_max_age = "28d"; + + app_service_config_files = config.pub-solar-os.matrix-synapse.app-service-config-files; }; - rc_message = { - burst_count = 10; - per_second = 0.2; - }; - rc_registration = { - burst_count = 3; - per_second = 0.17; - }; - redaction_retention_period = "7d"; - forgotten_room_retention_period = "7d"; - redis.enabled = false; - registration_requires_token = false; - registrations_require_3pid = [ "email" ]; - report_stats = false; - require_auth_for_profile_requests = false; - room_list_publication_rules = [ - { - action = "allow"; - alias = "*"; - room_id = "*"; - user_id = "*"; - } + + withJemalloc = true; + + extraConfigFiles = config.pub-solar-os.matrix-synapse.extra-config-files; + + extras = [ + "oidc" + "redis" ]; - signing_key_path = "/run/agenix/matrix-synapse-signing-key"; - - stream_writers = { }; - trusted_key_servers = [ { server_name = "matrix.org"; } ]; - suppress_key_server_warning = true; - - turn_allow_guests = false; - turn_uris = [ - "turn:${config.services.coturn.realm}:3478?transport=udp" - "turn:${config.services.coturn.realm}:3478?transport=tcp" - ]; - turn_user_lifetime = "1h"; - - url_preview_accept_language = [ - "en-US" - "en" - ]; - url_preview_enabled = true; - url_preview_ip_range_blacklist = [ - "127.0.0.0/8" - "10.0.0.0/8" - "172.16.0.0/12" - "192.168.0.0/16" - "100.64.0.0/10" - "192.0.0.0/24" - "169.254.0.0/16" - "192.88.99.0/24" - "198.18.0.0/15" - "192.0.2.0/24" - "198.51.100.0/24" - "203.0.113.0/24" - "224.0.0.0/4" - "::1/128" - "fe80::/10" - "fc00::/7" - "2001:db8::/32" - "ff00::/8" - "fec0::/10" - ]; - - user_directory = { - prefer_local_users = false; - search_all_users = false; - }; - user_ips_max_age = "28d"; - - app_service_config_files = [ - "/var/lib/matrix-synapse/telegram-registration.yaml" - "/var/lib/matrix-appservice-irc/registration.yml" - # "/matrix-appservice-slack-registration.yaml" - # "/hookshot-registration.yml" - # "/matrix-mautrix-signal-registration.yaml" - # "/matrix-mautrix-telegram-registration.yaml" - ]; + plugins = [ config.services.matrix-synapse.package.plugins.matrix-synapse-shared-secret-auth ]; }; - withJemalloc = true; + #services.matrix-sliding-sync = { + # enable = true; + # settings = { + # SYNCV3_SERVER = "https://${publicDomain}"; + # SYNCV3_BINDADDR = "127.0.0.1:8011"; + # # The bind addr for Prometheus metrics, which will be accessible at + # # /metrics at this address + # SYNCV3_PROM = "127.0.0.1:9100"; + # }; + # environmentFile = config.age.secrets."matrix-synapse-sliding-sync-secret".path; + #}; - extraConfigFiles = [ - "/run/agenix/matrix-synapse-secret-config.yaml" - - # The registration file is automatically generated after starting the - # appservice for the first time. - # cp /var/lib/mautrix-telegram/telegram-registration.yaml \ - # /var/lib/matrix-synapse/ - # chown matrix-synapse:matrix-synapse \ - # /var/lib/matrix-synapse/telegram-registration.yaml - "/var/lib/matrix-synapse/telegram-registration.yaml" - ]; - - extras = [ - "oidc" - "redis" - ]; - - plugins = [ config.services.matrix-synapse.package.plugins.matrix-synapse-shared-secret-auth ]; - }; - - services.matrix-sliding-sync = { - enable = true; - settings = { - SYNCV3_SERVER = "https://${publicDomain}"; - SYNCV3_BINDADDR = "127.0.0.1:8011"; - # The bind addr for Prometheus metrics, which will be accessible at - # /metrics at this address - SYNCV3_PROM = "127.0.0.1:9100"; + pub-solar-os.backups.restic.matrix-synapse = { + paths = [ + "/var/lib/matrix-synapse" + "/var/lib/matrix-appservice-irc" + "/var/lib/mautrix-telegram" + "/tmp/matrix-synapse-backup.sql" + ]; + timerConfig = { + OnCalendar = "*-*-* 05:00:00 Etc/UTC"; + }; + initialize = true; + backupPrepareCommand = '' + ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d matrix > /tmp/matrix-synapse-backup.sql + ''; + backupCleanupCommand = '' + rm /tmp/matrix-synapse-backup.sql + ''; + pruneOpts = [ + "--keep-daily 7" + "--keep-weekly 4" + "--keep-monthly 3" + ]; }; - environmentFile = config.age.secrets."matrix-synapse-sliding-sync-secret".path; - }; - - services.restic.backups.matrix-synapse-storagebox = { - paths = [ - "/var/lib/matrix-synapse" - "/var/lib/matrix-appservice-irc" - "/var/lib/mautrix-telegram" - "/tmp/matrix-synapse-backup.sql" - ]; - timerConfig = { - OnCalendar = "*-*-* 05:00:00 Etc/UTC"; - }; - initialize = true; - passwordFile = config.age.secrets."restic-repo-storagebox-nachtigall".path; - repository = "sftp:u377325@u377325.your-storagebox.de:/backups"; - backupPrepareCommand = '' - ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d matrix > /tmp/matrix-synapse-backup.sql - ''; - backupCleanupCommand = '' - rm /tmp/matrix-synapse-backup.sql - ''; - pruneOpts = [ - "--keep-daily 7" - "--keep-weekly 4" - "--keep-monthly 3" - ]; }; } diff --git a/modules/nginx-matrix/default.nix b/modules/nginx-matrix/default.nix index 0e236dc..603de36 100644 --- a/modules/nginx-matrix/default.nix +++ b/modules/nginx-matrix/default.nix @@ -10,11 +10,14 @@ let add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header X-XSS-Protection "1; mode=block"; ''; - clientConfig = import ./element-client-config.nix { inherit lib pkgs; }; + clientConfig = import ./element-client-config.nix { inherit config lib pkgs; }; wellKnownClient = domain: { "m.homeserver".base_url = "https://matrix.${domain}"; "m.identity_server".base_url = "https://matrix.${domain}"; - "org.matrix.msc3575.proxy".url = "https://matrix.${domain}"; + "org.matrix.msc2965.authentication" = { + issuer = "https://mas.${domain}/"; + account = "https://mas.${domain}/account"; + }; "im.vector.riot.e2ee".default = true; "io.element.e2ee" = { default = true; @@ -85,6 +88,27 @@ in root = pkgs.element-stickerpicker; }; + "mas.${config.pub-solar-os.networking.domain}" = { + root = "/dev/null"; + + forceSSL = lib.mkDefault true; + enableACME = lib.mkDefault true; + + locations = { + "/" = { + proxyPass = "http://127.0.0.1:8090"; + + extraConfig = '' + ${commonHeaders} + proxy_http_version 1.1; + + # Forward the client IP address + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + ''; + }; + }; + }; + "matrix.${config.pub-solar-os.networking.domain}" = { root = "/dev/null"; @@ -99,28 +123,41 @@ in locations = { # For telegram "/c3c3f34b-29fb-5feb-86e5-98c75ec8214b" = { + priority = 100; proxyPass = "http://127.0.0.1:8009"; extraConfig = commonHeaders; }; - # sliding-sync - "~ ^/(client/|_matrix/client/unstable/org.matrix.msc3575/sync)" = { - proxyPass = "http://127.0.0.1:8011"; - extraConfig = commonHeaders; + # Forward to the auth service + "~ ^/_matrix/client/(.*)/(login|logout|refresh)" = { + priority = 100; + proxyPass = "http://127.0.0.1:8090"; + + extraConfig = '' + ${commonHeaders} + proxy_http_version 1.1; + + # Forward the client IP address + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + ''; }; - "~* ^(/_matrix|/_synapse/client|/_synapse/oidc)" = { + # Forward to Synapse + # as per https://element-hq.github.io/synapse/latest/reverse_proxy.html#nginx + "~ ^(/_matrix|/_synapse/client)" = { + priority = 200; proxyPass = "http://127.0.0.1:8008"; extraConfig = '' ${commonHeaders} + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; client_body_buffer_size 25M; client_max_body_size 50M; proxy_max_temp_file_size 0; + proxy_http_version 1.1; ''; }; }; diff --git a/modules/nginx-matrix/element-client-config.nix b/modules/nginx-matrix/element-client-config.nix index b3eaf9b..617d3bc 100644 --- a/modules/nginx-matrix/element-client-config.nix +++ b/modules/nginx-matrix/element-client-config.nix @@ -1,9 +1,9 @@ -{ pkgs, lib, ... }: +{ config, pkgs, lib, ... }: { default_server_config = { "m.homeserver" = { - base_url = "https://matrix.pub.solar"; - server_name = "pub.solar"; + base_url = "https://matrix.${config.pub-solar-os.networking.domain}"; + server_name = "${config.pub-solar-os.networking.domain}"; }; "m.identity_server" = { base_url = ""; diff --git a/overlays/default.nix b/overlays/default.nix index 50ede5d..33f0e1d 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -17,6 +17,7 @@ inherit (inputs) element-stickers maunium-stickerpicker; }; mastodon = unstable.mastodon; + matrix-authentication-service = unstable.matrix-authentication-service; } ) ]; diff --git a/secrets/coturn-static-auth-secret.age b/secrets/nachtigall-coturn-static-auth-secret.age similarity index 100% rename from secrets/coturn-static-auth-secret.age rename to secrets/nachtigall-coturn-static-auth-secret.age diff --git a/secrets/matrix-synapse-secret-config.yaml.age b/secrets/nachtigall-matrix-synapse-secret-config.yaml.age similarity index 100% rename from secrets/matrix-synapse-secret-config.yaml.age rename to secrets/nachtigall-matrix-synapse-secret-config.yaml.age diff --git a/secrets/matrix-synapse-signing-key.age b/secrets/nachtigall-matrix-synapse-signing-key.age similarity index 100% rename from secrets/matrix-synapse-signing-key.age rename to secrets/nachtigall-matrix-synapse-signing-key.age diff --git a/secrets/matrix-synapse-sliding-sync-secret.age b/secrets/nachtigall-matrix-synapse-sliding-sync-secret.age similarity index 100% rename from secrets/matrix-synapse-sliding-sync-secret.age rename to secrets/nachtigall-matrix-synapse-sliding-sync-secret.age diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 999cec9..402fc79 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -7,6 +7,7 @@ let trinkgenossin-host = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDZXRDpom/LtyoCxvRuoONARKxIT6wNUwEyUjzHRE7DG root@trinkgenossin"; delite-host = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAKo7zlfQhcJ5/okFTOoOstZtmEL1iNlHxQ4q2baEcWT root@delite"; blue-shell-host = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP9g9X0a/MaVtbh44IeLxcq+McuYec0GYAdLsseBpk5f root@blue-shell"; + underground-host = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGF3PtA89yhVkmN7aJI6gqXK8DW9L7kI71IgiK4TAEwI root@underground"; adminKeys = builtins.foldl' ( keys: login: keys ++ (builtins.attrValues login.secretEncryptionKeys) @@ -24,6 +25,8 @@ let blueshellKeys = [ blue-shell-host ]; + undergroundKeys = [ underground-host ]; + garageKeys = [ trinkgenossin-host delite-host @@ -62,9 +65,12 @@ in "forgejo-ssh-private-key.age".publicKeys = nachtigallKeys ++ adminKeys; "matrix-mautrix-telegram-env-file.age".publicKeys = nachtigallKeys ++ adminKeys; - "matrix-synapse-signing-key.age".publicKeys = nachtigallKeys ++ adminKeys; - "matrix-synapse-secret-config.yaml.age".publicKeys = nachtigallKeys ++ adminKeys; - "matrix-synapse-sliding-sync-secret.age".publicKeys = nachtigallKeys ++ adminKeys; + "nachtigall-matrix-synapse-signing-key.age".publicKeys = nachtigallKeys ++ adminKeys; + "nachtigall-matrix-synapse-secret-config.yaml.age".publicKeys = nachtigallKeys ++ adminKeys; + "nachtigall-matrix-synapse-sliding-sync-secret.age".publicKeys = nachtigallKeys ++ adminKeys; + + "underground-matrix-synapse-secret-config.yaml.age".publicKeys = undergroundKeys ++ adminKeys; + "underground-matrix-authentication-service-secret-config.yml.age".publicKeys = undergroundKeys ++ adminKeys; "nextcloud-secrets.age".publicKeys = nachtigallKeys ++ adminKeys; "nextcloud-admin-pass.age".publicKeys = nachtigallKeys ++ adminKeys; @@ -84,7 +90,7 @@ in "mediawiki-oidc-client-secret.age".publicKeys = nachtigallKeys ++ adminKeys; "mediawiki-secret-key.age".publicKeys = nachtigallKeys ++ adminKeys; - "coturn-static-auth-secret.age".publicKeys = nachtigallKeys ++ adminKeys; + "nachtigall-coturn-static-auth-secret.age".publicKeys = nachtigallKeys ++ adminKeys; "grafana-admin-password.age".publicKeys = trinkgenossinKeys ++ adminKeys; "grafana-keycloak-client-secret.age".publicKeys = trinkgenossinKeys ++ adminKeys; diff --git a/secrets/underground-matrix-authentication-service-secret-config.yml.age b/secrets/underground-matrix-authentication-service-secret-config.yml.age new file mode 100644 index 0000000000000000000000000000000000000000..eaab469c83d3200a67f0b3f539330957499b9aed GIT binary patch literal 6263 zcmZXVcT^9G|Nk>?^0u=_%BWkS_g-YY_ul&*^4@#zw`*rhSxHLSqlAb`G8#%s;b!Yr zmr|reLiF|fo%1>8JN|#2^Ej{9>+yQNWE#~1m04l;S)DqIImTkw0Nr4~f+b-NhjxKV z34z1G=rAhU4uNUHOfrnp3&H6mW|cw*WcqawF4Zn3x>>~ERdO`Tjxu9l0wTo%K>_3z zwMj=(+es7xRPR8@nPf1+1C(GzXf+N&Q}fLZ29<5X@flXk|E9Sl3Ov&jrsF|5R5X=< zF-r_&zM3MltH}r$0_0O_;1oPk$R>+me5a3YG&%qTh6te$(!~OkPs1U4RBSw-g$D^m zbf1oH!HHmQv|r89K?Ot!>OVBQ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z_(61T3$+x9sS05Z{z%aQ#=HEeBkWPOTXN+;`iLLfn&+iJA2Pb z=1J&I&z~E6g{Zx4*NXd~A0A(}Qt~3xxGizN4c)Aty-h8dy}JWB_WRC>@Mp_^-BvJa zj(srywI3|XzAYCiKJxdUSJv!@4*F}qHXNOJ^TY2`A9v04EiQOqrcV9v&cXqu3yTJ= z-f8@De)55=w0iQ)InDzQhA){nazw?$fwXqeXV<3mneyqhlOwJ)>G}-*38P$%6aRSY zx5y^K6oqBY{u3sNt+GHYT3SQs-+Ka~Z_~)?c2SLfQM(pO^-^DyHf%$WszkKk1(GoK;3SHm1s`4q)um0UXcEE`tM;b#?9XG4`@XOX; zjUb9|ym)uRu~kJ+iy}W4Ega_QeAYho;>z{Rth%OwkB$$YyX4!0U6!zi2Ie0e@162k zvY$L_@#EbwPYb3$YSsVg#z`Z8se#)y)Iw{9ohz>s3#iqXZ~Oc7I?-%=Q+2mZ8F)sY zqk}7M{~S;?l+C@=YO{G=;8sZ3`t-v37C+xmj#~fe{c~HMOqM?>obXJ2*IhOHy?vK2 z_2+Hh`Jt9w^Pn#?tYp*vSH>CMjJ*P+p Q51QL~#-^6TukLRDKWNaec>n+a literal 0 HcmV?d00001 diff --git a/terraform/dns.tf b/terraform/dns.tf index d4a8d43..5372c39 100644 --- a/terraform/dns.tf +++ b/terraform/dns.tf @@ -332,10 +332,40 @@ resource "namecheap_domain_records" "pub-solar" { type = "AAAA" address = "2a01:4f8:172:1c25::1" } + record { + hostname = "underground" + type = "A" + address = "80.244.242.3" + } + record { + hostname = "test" + type = "CNAME" + address = "underground.pub.solar." + } + record { + hostname = "mas.test" + type = "CNAME" + address = "underground.pub.solar." + } record { hostname = "matrix.test" type = "CNAME" - address = "nachtigall.pub.solar." + address = "underground.pub.solar." + } + record { + hostname = "chat.test" + type = "CNAME" + address = "underground.pub.solar." + } + record { + hostname = "stickers.chat.test" + type = "CNAME" + address = "underground.pub.solar." + } + record { + hostname = "auth.test" + type = "CNAME" + address = "underground.pub.solar." } # SRV records can only be changed via NameCheap Web UI # add comment -- 2.44.2 From 7775ad332eb40cf34718c3d3e1adfe60cd8c45bf Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 27 Oct 2024 17:27:17 +0100 Subject: [PATCH 02/11] matrix: do not change paths for nachtigall secrets --- hosts/nachtigall/configuration.nix | 4 ++++ modules/coturn/default.nix | 3 ++- modules/matrix/default.nix | 26 +++++++++++++++----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index eb7e657..f49be98 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -63,18 +63,21 @@ # matrix-synapse age.secrets."nachtigall-matrix-synapse-signing-key" = { file = "${flake.self}/secrets/nachtigall-matrix-synapse-signing-key.age"; + path = "/run/agenix/matrix-synapse-signing-key"; mode = "400"; owner = "matrix-synapse"; }; age.secrets."nachtigall-matrix-synapse-secret-config.yaml" = { file = "${flake.self}/secrets/nachtigall-matrix-synapse-secret-config.yaml.age"; + path = "/run/agenix/matrix-synapse-secret-config.yaml"; mode = "400"; owner = "matrix-synapse"; }; age.secrets."nachtigall-matrix-synapse-sliding-sync-secret" = { file = "${flake.self}/secrets/nachtigall-matrix-synapse-sliding-sync-secret.age"; + path = "/run/agenix/matrix-synapse-sliding-sync-secret"; mode = "400"; owner = "matrix-synapse"; }; @@ -82,6 +85,7 @@ pub-solar-os.matrix-synapse = { enable = true; + sliding-sync.enable = true; signing_key_path = config.age.secrets."nachtigall-matrix-synapse-signing-key".path; extra-config-files = [ config.age.secrets."nachtigall-matrix-synapse-secret-config.yaml".path diff --git a/modules/coturn/default.nix b/modules/coturn/default.nix index a7d3e86..bf36448 100644 --- a/modules/coturn/default.nix +++ b/modules/coturn/default.nix @@ -7,6 +7,7 @@ { age.secrets."nachtigall-coturn-static-auth-secret" = { file = "${flake.self}/secrets/nachtigall-coturn-static-auth-secret.age"; + path = "/run/agenix/coturn-static-auth-secret"; mode = "400"; owner = "turnserver"; }; @@ -18,7 +19,7 @@ min-port = 49000; max-port = 50000; use-auth-secret = true; - static-auth-secret-file = "/run/agenix/nachtigall-coturn-static-auth-secret"; + static-auth-secret-file = config.age.secrets."nachtigall-coturn-static-auth-secret".path; realm = "turn.${config.pub-solar-os.networking.domain}"; cert = "${config.security.acme.certs.${realm}.directory}/full.pem"; pkey = "${config.security.acme.certs.${realm}.directory}/key.pem"; diff --git a/modules/matrix/default.nix b/modules/matrix/default.nix index d8518d3..c0bee63 100644 --- a/modules/matrix/default.nix +++ b/modules/matrix/default.nix @@ -30,6 +30,10 @@ in type = lib.types.str; default = "${config.services.matrix-synapse.dataDir}/homeserver.signing.key"; }; + sliding-sync.enable = lib.mkEnableOption { + description = "Whether to enable a sliding-sync proxy, no longer needed with synapse version 1.114+"; + default = false; + }; }; config = lib.mkIf config.pub-solar-os.matrix-synapse.enable { @@ -261,17 +265,17 @@ in plugins = [ config.services.matrix-synapse.package.plugins.matrix-synapse-shared-secret-auth ]; }; - #services.matrix-sliding-sync = { - # enable = true; - # settings = { - # SYNCV3_SERVER = "https://${publicDomain}"; - # SYNCV3_BINDADDR = "127.0.0.1:8011"; - # # The bind addr for Prometheus metrics, which will be accessible at - # # /metrics at this address - # SYNCV3_PROM = "127.0.0.1:9100"; - # }; - # environmentFile = config.age.secrets."matrix-synapse-sliding-sync-secret".path; - #}; + services.matrix-sliding-sync = { + enable = config.pub-solar-os.matrix-synapse.sliding-sync.enable; + settings = { + SYNCV3_SERVER = "https://${publicDomain}"; + SYNCV3_BINDADDR = "127.0.0.1:8011"; + # The bind addr for Prometheus metrics, which will be accessible at + # /metrics at this address + SYNCV3_PROM = "127.0.0.1:9100"; + }; + environmentFile = config.age.secrets."nachtigall-matrix-synapse-sliding-sync-secret".path; + }; pub-solar-os.backups.restic.matrix-synapse = { paths = [ -- 2.44.2 From 9d7d25136909fe053e36964c2fed8a5173f030c5 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 27 Oct 2024 17:28:20 +0100 Subject: [PATCH 03/11] style: fix formatting --- hosts/nachtigall/configuration.nix | 1 - hosts/underground/configuration.nix | 15 +++++-- hosts/underground/hardware-configuration.nix | 45 ++++++++++++------- hosts/underground/networking.nix | 10 ++++- modules/matrix/default.nix | 4 +- .../nginx-matrix/element-client-config.nix | 7 ++- secrets/secrets.nix | 3 +- 7 files changed, 59 insertions(+), 26 deletions(-) diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index f49be98..69b191c 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -82,7 +82,6 @@ owner = "matrix-synapse"; }; - pub-solar-os.matrix-synapse = { enable = true; sliding-sync.enable = true; diff --git a/hosts/underground/configuration.nix b/hosts/underground/configuration.nix index b53f5dd..131cb16 100644 --- a/hosts/underground/configuration.nix +++ b/hosts/underground/configuration.nix @@ -79,10 +79,16 @@ { name = "oauth"; } { name = "compat"; } { name = "graphql"; } - { name = "assets"; path = "${config.services.matrix-authentication-service.package}/share/matrix-authentication-service/assets"; } + { + name = "assets"; + path = "${config.services.matrix-authentication-service.package}/share/matrix-authentication-service/assets"; + } ]; binds = [ - { host = "0.0.0.0"; port = 8090; } + { + host = "0.0.0.0"; + port = 8090; + } ]; proxy_protocol = false; } @@ -92,7 +98,10 @@ { name = "health"; } ]; binds = [ - { host = "0.0.0.0"; port = 8081; } + { + host = "0.0.0.0"; + port = 8081; + } ]; proxy_protocol = false; } diff --git a/hosts/underground/hardware-configuration.nix b/hosts/underground/hardware-configuration.nix index e4738a1..28ab939 100644 --- a/hosts/underground/hardware-configuration.nix +++ b/hosts/underground/hardware-configuration.nix @@ -1,14 +1,27 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ (modulesPath + "/profiles/qemu-guest.nix") - ]; + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.availableKernelModules = [ + "ahci" + "xhci_pci" + "virtio_pci" + "virtio_scsi" + "sd_mod" + "sr_mod" + ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; @@ -16,19 +29,19 @@ device = "/dev/disk/by-label/cryptroot"; }; - fileSystems."/" = - { device = "/dev/disk/by-label/root"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-label/root"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-label/boot"; - fsType = "ext4"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-label/boot"; + fsType = "ext4"; + }; - swapDevices = - [ { device = "/dev/disk/by-label/swap"; } - ]; + swapDevices = [ + { device = "/dev/disk/by-label/swap"; } + ]; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; } diff --git a/hosts/underground/networking.nix b/hosts/underground/networking.nix index 3085c7b..0f08a7e 100644 --- a/hosts/underground/networking.nix +++ b/hosts/underground/networking.nix @@ -13,11 +13,17 @@ address = "80.244.242.1"; interface = "enp1s0"; }; - nameservers = ["95.129.51.51" "80.244.244.244"]; + nameservers = [ + "95.129.51.51" + "80.244.244.244" + ]; interfaces.enp1s0 = { useDHCP = false; ipv4.addresses = [ - { address = "80.244.242.3"; prefixLength = 29; } + { + address = "80.244.242.3"; + prefixLength = 29; + } ]; }; }; diff --git a/modules/matrix/default.nix b/modules/matrix/default.nix index c0bee63..1d95597 100644 --- a/modules/matrix/default.nix +++ b/modules/matrix/default.nix @@ -16,13 +16,13 @@ in app-service-config-files = lib.mkOption { description = "List of app service config files"; type = lib.types.listOf lib.types.str; - default = []; + default = [ ]; }; extra-config-files = lib.mkOption { description = "List of extra synapse config files"; type = lib.types.listOf lib.types.str; - default = []; + default = [ ]; }; signing_key_path = lib.mkOption { diff --git a/modules/nginx-matrix/element-client-config.nix b/modules/nginx-matrix/element-client-config.nix index 617d3bc..80fed55 100644 --- a/modules/nginx-matrix/element-client-config.nix +++ b/modules/nginx-matrix/element-client-config.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { default_server_config = { "m.homeserver" = { diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 402fc79..7165ba6 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -70,7 +70,8 @@ in "nachtigall-matrix-synapse-sliding-sync-secret.age".publicKeys = nachtigallKeys ++ adminKeys; "underground-matrix-synapse-secret-config.yaml.age".publicKeys = undergroundKeys ++ adminKeys; - "underground-matrix-authentication-service-secret-config.yml.age".publicKeys = undergroundKeys ++ adminKeys; + "underground-matrix-authentication-service-secret-config.yml.age".publicKeys = + undergroundKeys ++ adminKeys; "nextcloud-secrets.age".publicKeys = nachtigallKeys ++ adminKeys; "nextcloud-admin-pass.age".publicKeys = nachtigallKeys ++ adminKeys; -- 2.44.2 From 8244e605b669a71707dba13186ded74f02887f2a Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 27 Oct 2024 16:51:07 +0100 Subject: [PATCH 04/11] fix: passkey support in pub.solar keycloak theme --- flake.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 8c96268..a9ee187 100644 --- a/flake.lock +++ b/flake.lock @@ -280,11 +280,11 @@ ] }, "locked": { - "lastModified": 1707424749, - "narHash": "sha256-eTvts5E3zmD4/DoAI9KedQjRwica0cg36wwIVp1NWbM=", + "lastModified": 1730041422, + "narHash": "sha256-aEz5/yUJN/PSEXwPBuKMs2FbAmz68fDIQ9B0tVRVmTo=", "ref": "main", - "rev": "1202a23c205b3c07a5feb5caf6813f21b3c69307", - "revCount": 30, + "rev": "09f7b1ed16c99f5fb5c5f9a2a73ccc9ff0645b35", + "revCount": 32, "type": "git", "url": "https://git.pub.solar/pub-solar/keycloak-theme" }, -- 2.44.2 From c9c2d06a98b49e3d97dc3c7712c24933be9cf2a9 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Mon, 28 Oct 2024 21:38:43 +0100 Subject: [PATCH 05/11] dns: add CNAME record for mas.pub.solar --- terraform/dns.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/terraform/dns.tf b/terraform/dns.tf index 5372c39..236cd0d 100644 --- a/terraform/dns.tf +++ b/terraform/dns.tf @@ -109,6 +109,11 @@ resource "namecheap_domain_records" "pub-solar" { type = "CNAME" address = "nachtigall.pub.solar." } + record { + hostname = "mas" + type = "CNAME" + address = "nachtigall.pub.solar." + } record { hostname = "ci" type = "A" -- 2.44.2 From 472f9aa68b51cb0071b26c828636290ca5c807cc Mon Sep 17 00:00:00 2001 From: teutat3s Date: Mon, 28 Oct 2024 21:39:00 +0100 Subject: [PATCH 06/11] dns: list.pub.solar should be A / AAAA records --- terraform/dns.tf | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/terraform/dns.tf b/terraform/dns.tf index 236cd0d..cb3b81c 100644 --- a/terraform/dns.tf +++ b/terraform/dns.tf @@ -189,11 +189,6 @@ resource "namecheap_domain_records" "pub-solar" { type = "CNAME" address = "nachtigall.pub.solar." } - record { - hostname = "list" - type = "CNAME" - address = "nachtigall.pub.solar." - } record { hostname = "obs-portal" type = "CNAME" @@ -327,6 +322,16 @@ resource "namecheap_domain_records" "pub-solar" { address = "list.pub.solar." mx_pref = "0" } + record { + hostname = "list" + type = "A" + address = "138.201.80.102" + } + record { + hostname = "list" + type = "AAAA" + address = "2a01:4f8:172:1c25::1" + } record { hostname = "nachtigall" type = "A" -- 2.44.2 From 4434a901369c78126b105828c804eba15d81075d Mon Sep 17 00:00:00 2001 From: b12f Date: Wed, 30 Oct 2024 17:14:47 +0100 Subject: [PATCH 07/11] modules/matrix: rename secrets to not include hostnames --- hosts/nachtigall/configuration.nix | 16 ++++++++-------- hosts/underground/configuration.nix | 12 ++++++------ ...ge => matrix-synapse-secret-config.yaml.age} | Bin ...g-key.age => matrix-synapse-signing-key.age} | Bin ...e => matrix-synapse-sliding-sync-secret.age} | 0 secrets/secrets.nix | 10 +++++----- ...uthentication-service-secret-config.yml.age} | Bin ...aging-matrix-synapse-secret-config.yaml.age} | Bin 8 files changed, 19 insertions(+), 19 deletions(-) rename secrets/{nachtigall-matrix-synapse-secret-config.yaml.age => matrix-synapse-secret-config.yaml.age} (100%) rename secrets/{nachtigall-matrix-synapse-signing-key.age => matrix-synapse-signing-key.age} (100%) rename secrets/{nachtigall-matrix-synapse-sliding-sync-secret.age => matrix-synapse-sliding-sync-secret.age} (100%) rename secrets/{underground-matrix-authentication-service-secret-config.yml.age => staging-matrix-authentication-service-secret-config.yml.age} (100%) rename secrets/{underground-matrix-synapse-secret-config.yaml.age => staging-matrix-synapse-secret-config.yaml.age} (100%) diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index 69b191c..dac4fc6 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -61,22 +61,22 @@ }; # matrix-synapse - age.secrets."nachtigall-matrix-synapse-signing-key" = { - file = "${flake.self}/secrets/nachtigall-matrix-synapse-signing-key.age"; + age.secrets."matrix-synapse-signing-key" = { + file = "${flake.self}/secrets/matrix-synapse-signing-key.age"; path = "/run/agenix/matrix-synapse-signing-key"; mode = "400"; owner = "matrix-synapse"; }; - age.secrets."nachtigall-matrix-synapse-secret-config.yaml" = { - file = "${flake.self}/secrets/nachtigall-matrix-synapse-secret-config.yaml.age"; + age.secrets."matrix-synapse-secret-config.yaml" = { + file = "${flake.self}/secrets/matrix-synapse-secret-config.yaml.age"; path = "/run/agenix/matrix-synapse-secret-config.yaml"; mode = "400"; owner = "matrix-synapse"; }; - age.secrets."nachtigall-matrix-synapse-sliding-sync-secret" = { - file = "${flake.self}/secrets/nachtigall-matrix-synapse-sliding-sync-secret.age"; + age.secrets."matrix-synapse-sliding-sync-secret" = { + file = "${flake.self}/secrets/matrix-synapse-sliding-sync-secret.age"; path = "/run/agenix/matrix-synapse-sliding-sync-secret"; mode = "400"; owner = "matrix-synapse"; @@ -85,9 +85,9 @@ pub-solar-os.matrix-synapse = { enable = true; sliding-sync.enable = true; - signing_key_path = config.age.secrets."nachtigall-matrix-synapse-signing-key".path; + signing_key_path = config.age.secrets."matrix-synapse-signing-key".path; extra-config-files = [ - config.age.secrets."nachtigall-matrix-synapse-secret-config.yaml".path + config.age.secrets."matrix-synapse-secret-config.yaml".path # The registration file is automatically generated after starting the # appservice for the first time. diff --git a/hosts/underground/configuration.nix b/hosts/underground/configuration.nix index 131cb16..74b1d79 100644 --- a/hosts/underground/configuration.nix +++ b/hosts/underground/configuration.nix @@ -30,14 +30,14 @@ forceSSL = true; }; - age.secrets."underground-matrix-synapse-secret-config.yaml" = { - file = "${flake.self}/secrets/underground-matrix-synapse-secret-config.yaml.age"; + age.secrets."staging-matrix-synapse-secret-config.yaml" = { + file = "${flake.self}/secrets/staging-matrix-synapse-secret-config.yaml.age"; mode = "400"; owner = "matrix-synapse"; }; - age.secrets."underground-matrix-authentication-service-secret-config.yml" = { - file = "${flake.self}/secrets/underground-matrix-authentication-service-secret-config.yml.age"; + age.secrets."staging-matrix-authentication-service-secret-config.yml" = { + file = "${flake.self}/secrets/staging-matrix-authentication-service-secret-config.yml.age"; mode = "400"; owner = "matrix-authentication-service"; }; @@ -45,7 +45,7 @@ pub-solar-os.matrix-synapse = { enable = true; extra-config-files = [ - config.age.secrets."underground-matrix-synapse-secret-config.yaml".path + config.age.secrets."staging-matrix-synapse-secret-config.yaml".path # The registration file is automatically generated after starting the # appservice for the first time. @@ -65,7 +65,7 @@ enable = true; createDatabase = true; extraConfigFiles = [ - config.age.secrets."underground-matrix-authentication-service-secret-config.yml".path + config.age.secrets."staging-matrix-authentication-service-secret-config.yml".path ]; settings = { http.public_base = "https://mas.${config.pub-solar-os.networking.domain}"; diff --git a/secrets/nachtigall-matrix-synapse-secret-config.yaml.age b/secrets/matrix-synapse-secret-config.yaml.age similarity index 100% rename from secrets/nachtigall-matrix-synapse-secret-config.yaml.age rename to secrets/matrix-synapse-secret-config.yaml.age diff --git a/secrets/nachtigall-matrix-synapse-signing-key.age b/secrets/matrix-synapse-signing-key.age similarity index 100% rename from secrets/nachtigall-matrix-synapse-signing-key.age rename to secrets/matrix-synapse-signing-key.age diff --git a/secrets/nachtigall-matrix-synapse-sliding-sync-secret.age b/secrets/matrix-synapse-sliding-sync-secret.age similarity index 100% rename from secrets/nachtigall-matrix-synapse-sliding-sync-secret.age rename to secrets/matrix-synapse-sliding-sync-secret.age diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 7165ba6..6eaede2 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -65,12 +65,12 @@ in "forgejo-ssh-private-key.age".publicKeys = nachtigallKeys ++ adminKeys; "matrix-mautrix-telegram-env-file.age".publicKeys = nachtigallKeys ++ adminKeys; - "nachtigall-matrix-synapse-signing-key.age".publicKeys = nachtigallKeys ++ adminKeys; - "nachtigall-matrix-synapse-secret-config.yaml.age".publicKeys = nachtigallKeys ++ adminKeys; - "nachtigall-matrix-synapse-sliding-sync-secret.age".publicKeys = nachtigallKeys ++ adminKeys; + "matrix-synapse-signing-key.age".publicKeys = nachtigallKeys ++ adminKeys; + "matrix-synapse-secret-config.yaml.age".publicKeys = nachtigallKeys ++ adminKeys; + "matrix-synapse-sliding-sync-secret.age".publicKeys = nachtigallKeys ++ adminKeys; - "underground-matrix-synapse-secret-config.yaml.age".publicKeys = undergroundKeys ++ adminKeys; - "underground-matrix-authentication-service-secret-config.yml.age".publicKeys = + "staging-matrix-synapse-secret-config.yaml.age".publicKeys = undergroundKeys ++ adminKeys; + "staging-matrix-authentication-service-secret-config.yml.age".publicKeys = undergroundKeys ++ adminKeys; "nextcloud-secrets.age".publicKeys = nachtigallKeys ++ adminKeys; diff --git a/secrets/underground-matrix-authentication-service-secret-config.yml.age b/secrets/staging-matrix-authentication-service-secret-config.yml.age similarity index 100% rename from secrets/underground-matrix-authentication-service-secret-config.yml.age rename to secrets/staging-matrix-authentication-service-secret-config.yml.age diff --git a/secrets/underground-matrix-synapse-secret-config.yaml.age b/secrets/staging-matrix-synapse-secret-config.yaml.age similarity index 100% rename from secrets/underground-matrix-synapse-secret-config.yaml.age rename to secrets/staging-matrix-synapse-secret-config.yaml.age -- 2.44.2 From 9d9bcf9a15eecb342201be1eeed0224e3c35efa3 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Wed, 30 Oct 2024 17:57:33 +0100 Subject: [PATCH 08/11] mas: move to module, add secrets for prod --- hosts/nachtigall/configuration.nix | 53 +++++---- hosts/nachtigall/default.nix | 2 + hosts/underground/configuration.nix | 80 +++----------- modules/matrix/default.nix | 103 ++++++++++++++---- ...thentication-service-secret-config.yml.age | Bin 0 -> 6276 bytes secrets/secrets.nix | 1 + 6 files changed, 135 insertions(+), 104 deletions(-) create mode 100644 secrets/matrix-authentication-service-secret-config.yml.age diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index dac4fc6..8bfba8d 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -82,28 +82,39 @@ owner = "matrix-synapse"; }; - pub-solar-os.matrix-synapse = { - enable = true; - sliding-sync.enable = true; - signing_key_path = config.age.secrets."matrix-synapse-signing-key".path; - extra-config-files = [ - config.age.secrets."matrix-synapse-secret-config.yaml".path + age.secrets."matrix-authentication-service-secret-config.yml" = { + file = "${flake.self}/secrets/matrix-authentication-service-secret-config.yml.age"; + mode = "400"; + owner = "matrix-authentication-service"; + }; - # The registration file is automatically generated after starting the - # appservice for the first time. - # cp /var/lib/mautrix-telegram/telegram-registration.yaml \ - # /var/lib/matrix-synapse/ - # chown matrix-synapse:matrix-synapse \ - # /var/lib/matrix-synapse/telegram-registration.yaml - "/var/lib/matrix-synapse/telegram-registration.yaml" - ]; - app-service-config-files = [ - "/var/lib/matrix-synapse/telegram-registration.yaml" - "/var/lib/matrix-appservice-irc/registration.yml" - # "/matrix-appservice-slack-registration.yaml" - # "/hookshot-registration.yml" - # "/matrix-mautrix-signal-registration.yaml" - # "/matrix-mautrix-telegram-registration.yaml" + pub-solar-os.matrix = { + enable = true; + synapse = { + sliding-sync.enable = true; + signing_key_path = config.age.secrets."matrix-synapse-signing-key".path; + extra-config-files = [ + config.age.secrets."matrix-synapse-secret-config.yaml".path + + # The registration file is automatically generated after starting the + # appservice for the first time. + # cp /var/lib/mautrix-telegram/telegram-registration.yaml \ + # /var/lib/matrix-synapse/ + # chown matrix-synapse:matrix-synapse \ + # /var/lib/matrix-synapse/telegram-registration.yaml + "/var/lib/matrix-synapse/telegram-registration.yaml" + ]; + app-service-config-files = [ + "/var/lib/matrix-synapse/telegram-registration.yaml" + "/var/lib/matrix-appservice-irc/registration.yml" + # "/matrix-appservice-slack-registration.yaml" + # "/hookshot-registration.yml" + # "/matrix-mautrix-signal-registration.yaml" + # "/matrix-mautrix-telegram-registration.yaml" + ]; + }; + matrix-authentication-service.extra-config-files = [ + config.age.secrets."matrix-authentication-service-secret-config.yml".path ]; }; diff --git a/hosts/nachtigall/default.nix b/hosts/nachtigall/default.nix index 9a69c4f..100759a 100644 --- a/hosts/nachtigall/default.nix +++ b/hosts/nachtigall/default.nix @@ -9,10 +9,12 @@ ./networking.nix ./wireguard.nix ./backups.nix + "${flake.inputs.fork}/nixos/modules/services//matrix/matrix-authentication-service.nix" "${flake.inputs.unstable}/nixos/modules/services/web-apps/mastodon.nix" ]; disabledModules = [ + "services/matrix/matrix-authentication-service.nix " "services/web-apps/mastodon.nix" ]; } diff --git a/hosts/underground/configuration.nix b/hosts/underground/configuration.nix index 74b1d79..ff1c809 100644 --- a/hosts/underground/configuration.nix +++ b/hosts/underground/configuration.nix @@ -42,72 +42,28 @@ owner = "matrix-authentication-service"; }; - pub-solar-os.matrix-synapse = { + pub-solar-os.matrix = { enable = true; - extra-config-files = [ - config.age.secrets."staging-matrix-synapse-secret-config.yaml".path + synapse = { + extra-config-files = [ + config.age.secrets."staging-matrix-synapse-secret-config.yaml".path - # The registration file is automatically generated after starting the - # appservice for the first time. - # cp /var/lib/mautrix-telegram/telegram-registration.yaml \ - # /var/lib/matrix-synapse/ - # chown matrix-synapse:matrix-synapse \ - # /var/lib/matrix-synapse/telegram-registration.yaml - #"/var/lib/matrix-synapse/telegram-registration.yaml" - ]; - app-service-config-files = [ - "/var/lib/matrix-appservice-irc/registration.yml" - #"/var/lib/matrix-synapse/telegram-registration.yaml" - ]; - }; - - services.matrix-authentication-service = { - enable = true; - createDatabase = true; - extraConfigFiles = [ + # The registration file is automatically generated after starting the + # appservice for the first time. + # cp /var/lib/mautrix-telegram/telegram-registration.yaml \ + # /var/lib/matrix-synapse/ + # chown matrix-synapse:matrix-synapse \ + # /var/lib/matrix-synapse/telegram-registration.yaml + #"/var/lib/matrix-synapse/telegram-registration.yaml" + ]; + app-service-config-files = [ + "/var/lib/matrix-appservice-irc/registration.yml" + #"/var/lib/matrix-synapse/telegram-registration.yaml" + ]; + }; + matrix-authentication-service.extra-config-files = [ config.age.secrets."staging-matrix-authentication-service-secret-config.yml".path ]; - settings = { - http.public_base = "https://mas.${config.pub-solar-os.networking.domain}"; - http.issuer = "https://mas.${config.pub-solar-os.networking.domain}"; - http.listeners = [ - { - name = "web"; - resources = [ - { name = "discovery"; } - { name = "human"; } - { name = "oauth"; } - { name = "compat"; } - { name = "graphql"; } - { - name = "assets"; - path = "${config.services.matrix-authentication-service.package}/share/matrix-authentication-service/assets"; - } - ]; - binds = [ - { - host = "0.0.0.0"; - port = 8090; - } - ]; - proxy_protocol = false; - } - { - name = "internal"; - resources = [ - { name = "health"; } - ]; - binds = [ - { - host = "0.0.0.0"; - port = 8081; - } - ]; - proxy_protocol = false; - } - ]; - passwords.enabled = false; - }; }; services.openssh.openFirewall = true; diff --git a/modules/matrix/default.nix b/modules/matrix/default.nix index 1d95597..0f6963c 100644 --- a/modules/matrix/default.nix +++ b/modules/matrix/default.nix @@ -10,33 +10,46 @@ let serverDomain = "${config.pub-solar-os.networking.domain}"; in { - options.pub-solar-os.matrix-synapse = { - enable = lib.mkEnableOption "Enable matrix-synapse to run on the node"; + options.pub-solar-os = { + matrix = { + enable = lib.mkEnableOption "Enable matrix-synapse and matrix-authentication-service to run on the node"; - app-service-config-files = lib.mkOption { - description = "List of app service config files"; - type = lib.types.listOf lib.types.str; - default = [ ]; - }; + synapse = { + app-service-config-files = lib.mkOption { + description = "List of app service config files"; + type = lib.types.listOf lib.types.str; + default = [ ]; + }; - extra-config-files = lib.mkOption { - description = "List of extra synapse config files"; - type = lib.types.listOf lib.types.str; - default = [ ]; - }; + extra-config-files = lib.mkOption { + description = "List of extra synapse config files"; + type = lib.types.listOf lib.types.str; + default = [ ]; + }; - signing_key_path = lib.mkOption { - description = "Path to file containing the signing key"; - type = lib.types.str; - default = "${config.services.matrix-synapse.dataDir}/homeserver.signing.key"; - }; - sliding-sync.enable = lib.mkEnableOption { - description = "Whether to enable a sliding-sync proxy, no longer needed with synapse version 1.114+"; - default = false; + signing_key_path = lib.mkOption { + description = "Path to file containing the signing key"; + type = lib.types.str; + default = "${config.services.matrix-synapse.dataDir}/homeserver.signing.key"; + }; + + sliding-sync.enable = lib.mkEnableOption { + description = "Whether to enable a sliding-sync proxy, no longer needed with synapse version 1.114+"; + default = false; + }; + }; + + matrix-authentication-service = { + extra-config-files = lib.mkOption { + description = "List of extra mas config files"; + type = lib.types.listOf lib.types.str; + default = [ ]; + }; + }; }; }; - config = lib.mkIf config.pub-solar-os.matrix-synapse.enable { + config = lib.mkIf config.pub-solar-os.matrix.enable { services.matrix-synapse = { enable = true; settings = { @@ -265,6 +278,54 @@ in plugins = [ config.services.matrix-synapse.package.plugins.matrix-synapse-shared-secret-auth ]; }; + services.matrix-authentication-service = { + enable = true; + createDatabase = true; + extraConfigFiles = config.pub-solar-os.matrix.matrix-authentication-service.extra-config-files; + + settings = { + http.public_base = "https://mas.${config.pub-solar-os.networking.domain}"; + http.issuer = "https://mas.${config.pub-solar-os.networking.domain}"; + http.listeners = [ + { + name = "web"; + resources = [ + { name = "discovery"; } + { name = "human"; } + { name = "oauth"; } + { name = "compat"; } + { name = "graphql"; } + { + name = "assets"; + path = "${config.services.matrix-authentication-service.package}/share/matrix-authentication-service/assets"; + } + ]; + binds = [ + { + host = "0.0.0.0"; + port = 8090; + } + ]; + proxy_protocol = false; + } + { + name = "internal"; + resources = [ + { name = "health"; } + ]; + binds = [ + { + host = "0.0.0.0"; + port = 8081; + } + ]; + proxy_protocol = false; + } + ]; + passwords.enabled = false; + }; + }; + services.matrix-sliding-sync = { enable = config.pub-solar-os.matrix-synapse.sliding-sync.enable; settings = { diff --git a/secrets/matrix-authentication-service-secret-config.yml.age b/secrets/matrix-authentication-service-secret-config.yml.age new file mode 100644 index 0000000000000000000000000000000000000000..50cd3f21e6b0388f7639d20121f218efe5c20fa7 GIT binary patch literal 6276 zcmZ9O_g@W)|HqB$)^TrUC{kvZBWJH9&fcT5&#CC_z4vJ;Nk%9nWF%ZNDp^H@O0JQF zP|3Bf9V#p1>-)p!@%Vl}f5G$demq{U*YhpYsA5%Sh23X$>MZ7Y7P|)Ih5%v{q8$!x ztV#(*ARw4%9f7X*XriG&DhMv${-lu~4n$b8$)|+zlg=y)2Vh05B1O3bIa{Xw{=lIIaoC(y9}A zIyBg#RFha#hDRx6nQUwU+z9dfhh}%kqSXjK#i9W??RFoXk7nppT8RQART2brILfYp zqNo-V6~l!|sBXE=M#1|X7(5$ncGGMaKZ%)0^I-G}goKC#z~Cex5TnM6KzcV;X+^RK zI8R=j;&ji;aznxr1~y7TP!fy) zhubs&u@`N(fPo|_#vyk2)DoQoMy6SrL?W82<~u-mJ&_1yI@DqcQ)gw7Kr|>(U?NFu zI66g!Q8IY~02hx{n>|n|l!%a9pgu2{&vUEU9G6rCx2xoOKG=ldQD8VBUXCW4^a?AU z?86(~9G!rwlnOZ_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h}xP}Z<{JE}S^P_TVA11x~YIx8X z;4GW~GcVkDxo`I3Ra@blzgo}kyE+I{lyp*@cWxGh>GF?#$(RsfUCD@v;!k^icb+e$ za^{~LIpz2C!tO_rIRluy-{&+>H5t>xynuVt*JvhYO)&<9_<)9IYu6>784{A9{@Gf$ zao7FUo%`PH{)w-<6}Yh?=iAANlqBLTAb`768_VASBJ7S7@l(9?P9a-yS z0C!P>B4F^r&w)vwkMN@-C!7yIy|M7`>~rJH`JsxR^Z0dV^{aK6p&^;&_n+yiW8U>A zY&&#UIDg|yWn4{hKr(LTyHxs;s!`Cj&! z4-Lhzor1U2FI9GR*uIh5hh_yYsdXguwRK-z`_c@4X4;&*DdaS2kaII__Y7u)q!-}) zxNm838@oA?Rwy50hsrF!_$l$j~J>{)W$-7*HMu z-+Gd{|3O#d@12uN4d2ph?=I3C{vG^KFzqS8F-m@<>x0%guK99)i9G-DuKm2r5h*RB zM|`WiuaXf~)CB~Ne*E~>9^&jqzV{5J@E zp=fpYF?V0vfr-2NIGZ8LF^@OqU3z}v@$D;Zhih?XN3BH&AH2|{3CG6oQ^#b7{8zkpNg_;R+c8fqx&a930jD^48s&T{|CKz1`$-Gdt4uT)Z)f&*Fp( s`v@BEmGx%k)KAt5?$z`wi;9zK_~AvHq)$ literal 0 HcmV?d00001 diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 6eaede2..88a632a 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -68,6 +68,7 @@ in "matrix-synapse-signing-key.age".publicKeys = nachtigallKeys ++ adminKeys; "matrix-synapse-secret-config.yaml.age".publicKeys = nachtigallKeys ++ adminKeys; "matrix-synapse-sliding-sync-secret.age".publicKeys = nachtigallKeys ++ adminKeys; + "matrix-authentication-service-secret-config.yml.age".publicKeys = nachtigallKeys ++ adminKeys; "staging-matrix-synapse-secret-config.yaml.age".publicKeys = undergroundKeys ++ adminKeys; "staging-matrix-authentication-service-secret-config.yml.age".publicKeys = -- 2.44.2 From 041d311bb270d2e1d991950474d258ebe60535ea Mon Sep 17 00:00:00 2001 From: b12f Date: Wed, 30 Oct 2024 18:34:25 +0100 Subject: [PATCH 09/11] modules/matrix: rename used config options --- hosts/nachtigall/configuration.nix | 3 --- modules/matrix/default.nix | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index 8bfba8d..67e1c6d 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -63,21 +63,18 @@ # matrix-synapse age.secrets."matrix-synapse-signing-key" = { file = "${flake.self}/secrets/matrix-synapse-signing-key.age"; - path = "/run/agenix/matrix-synapse-signing-key"; mode = "400"; owner = "matrix-synapse"; }; age.secrets."matrix-synapse-secret-config.yaml" = { file = "${flake.self}/secrets/matrix-synapse-secret-config.yaml.age"; - path = "/run/agenix/matrix-synapse-secret-config.yaml"; mode = "400"; owner = "matrix-synapse"; }; age.secrets."matrix-synapse-sliding-sync-secret" = { file = "${flake.self}/secrets/matrix-synapse-sliding-sync-secret.age"; - path = "/run/agenix/matrix-synapse-sliding-sync-secret"; mode = "400"; owner = "matrix-synapse"; }; diff --git a/modules/matrix/default.nix b/modules/matrix/default.nix index 0f6963c..b8c0546 100644 --- a/modules/matrix/default.nix +++ b/modules/matrix/default.nix @@ -217,7 +217,7 @@ in } ]; - signing_key_path = config.pub-solar-os.matrix-synapse.signing_key_path; + signing_key_path = config.pub-solar-os.matrix.synapse.signing_key_path; stream_writers = { }; trusted_key_servers = [ { server_name = "matrix.org"; } ]; @@ -263,12 +263,12 @@ in }; user_ips_max_age = "28d"; - app_service_config_files = config.pub-solar-os.matrix-synapse.app-service-config-files; + app_service_config_files = config.pub-solar-os.matrix.synapse.app-service-config-files; }; withJemalloc = true; - extraConfigFiles = config.pub-solar-os.matrix-synapse.extra-config-files; + extraConfigFiles = config.pub-solar-os.matrix.synapse.extra-config-files; extras = [ "oidc" @@ -327,7 +327,7 @@ in }; services.matrix-sliding-sync = { - enable = config.pub-solar-os.matrix-synapse.sliding-sync.enable; + enable = config.pub-solar-os.matrix.synapse.sliding-sync.enable; settings = { SYNCV3_SERVER = "https://${publicDomain}"; SYNCV3_BINDADDR = "127.0.0.1:8011"; @@ -335,7 +335,7 @@ in # /metrics at this address SYNCV3_PROM = "127.0.0.1:9100"; }; - environmentFile = config.age.secrets."nachtigall-matrix-synapse-sliding-sync-secret".path; + environmentFile = config.age.secrets."matrix-synapse-sliding-sync-secret".path; }; pub-solar-os.backups.restic.matrix-synapse = { -- 2.44.2 From 7ba5a7bdd65a03b97877d31e4dbc52cb1c892b83 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Wed, 30 Oct 2024 20:30:39 +0100 Subject: [PATCH 10/11] matrix: disable sliding-sync proxy, it's built into synapse now, update synapse config to use matrix-authentication-service --- hosts/nachtigall/configuration.nix | 2 +- secrets/matrix-synapse-secret-config.yaml.age | Bin 4186 -> 5033 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index 67e1c6d..62dc644 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -88,7 +88,7 @@ pub-solar-os.matrix = { enable = true; synapse = { - sliding-sync.enable = true; + sliding-sync.enable = false; signing_key_path = config.age.secrets."matrix-synapse-signing-key".path; extra-config-files = [ config.age.secrets."matrix-synapse-secret-config.yaml".path diff --git a/secrets/matrix-synapse-secret-config.yaml.age b/secrets/matrix-synapse-secret-config.yaml.age index 86c590e2fecf761c0daf842244b494b0abdd5def..5f52638a36857a58713f7299042b571f9023a8d8 100644 GIT binary patch literal 5033 zcmZ9NXIE4QqlGorjIj|!5KvT%Wzgv@DlonGGv$mZ&YY=ddOK6BC>F#5!AL+wB@qi& zKv66xmRO^pv7-iwXs{xfsHm^^L+-lw{RPk3d+nmPm?oQCkT2p1*xaruZl48%;82s( zQ~ZAGWRnq3BH?H$HkJ?$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<0 zZ&n47OCLQPYdP86|0)}3ZD8t}>pnOHH^Adf-G?x=XK-v-ckRRyz0m*W+e4$h(%6G;O>muAI}jTXM!AzPoo^ z@jKep-yQf~xZ;t+xM9|VswZV_v#0FM?NU;?Xh)KnaAPLgkW?z2garw;xPYsHkX -- 2.44.2 From 3ec5c9f343cbe0bc84d39c53a38c6a419045a5d7 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Wed, 30 Oct 2024 20:32:47 +0100 Subject: [PATCH 11/11] style: fix formatting --- modules/matrix/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/matrix/default.nix b/modules/matrix/default.nix index b8c0546..958a6c1 100644 --- a/modules/matrix/default.nix +++ b/modules/matrix/default.nix @@ -335,7 +335,7 @@ in # /metrics at this address SYNCV3_PROM = "127.0.0.1:9100"; }; - environmentFile = config.age.secrets."matrix-synapse-sliding-sync-secret".path; + environmentFile = config.age.secrets."matrix-synapse-sliding-sync-secret".path; }; pub-solar-os.backups.restic.matrix-synapse = { -- 2.44.2