From 9f14456ecc64033c1cc8714219f7d806c822a919 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Sun, 20 Sep 2026 20:02:44 -0400 Subject: [PATCH] mod: added sable web to yshtola config added formatter --- flake.nix | 4 + modules/machine/yshtola/configuration.nix | 116 ++++++++++++++++++---- 2 files changed, 102 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 576d786..fd32c2a 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,10 @@ }; in { meta = import ./meta; + formatter = nixpkgs.lib.genAttrs [ + "x86_64-linux" + "aarch64-darwin" + ] (system: nixpkgs.legacyPackages.${system}.nixfmt); common = { overlays = import ./modules/common/overlays.nix; diff --git a/modules/machine/yshtola/configuration.nix b/modules/machine/yshtola/configuration.nix index 187f301..e8b97a9 100644 --- a/modules/machine/yshtola/configuration.nix +++ b/modules/machine/yshtola/configuration.nix @@ -1,8 +1,10 @@ { + nur, pkgs, userName, ... -}: let +}: +let # INFO: set these to your liking matrixFqdn = "chat.wyattjmiller.com"; rtcFqdn = "rtc.wyattjmiller.com"; @@ -10,16 +12,50 @@ supportEmail = "wyatt@wyattjmiller.com"; livekitKeyFile = "/var/lib/livekit/livekit.key"; matrixRegistrationTokenFile = "/var/lib/matrix.key"; -in { + + sableWeb = nur.packages.${pkgs.stdenv.hostPlatform.system}.sable-web; + + sableConfig = pkgs.writeTextDir "config.json" ( + builtins.toJSON { + defaultHomeserver = 0; + homeserverList = [ matrixFqdn ]; + allowCustomHomeservers = false; + + disableAccountSwitcher = false; + hideUsernamePasswordFields = false; + + hashRouter = { + enabled = false; + basename = "/"; + }; + + featuredCommunities = { + spaces = [ + "#seventhdawn:chat.wyattjmiller.com" + ]; + rooms = [ + "#general:chat.wyattjmiller.com" + "#gposeglams:chat.wyattjmiller.com" + "#lobby-vc:chat.wyattjmiller.com" + "#annoucements:chat.wyattjmiller.com" + ]; + }; + } + ); +in +{ imports = [ ../../pwrMgmt ]; # Enable flakes for NixOS - nix.settings.experimental-features = ["nix-command" "flakes"]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; nix.settings = { - download-buffer-size = 134217728; # 128 MiB in bytes + download-buffer-size = 134217728; # 128 MiB in bytes }; # Custom kernel/boot stuff @@ -79,13 +115,13 @@ in { 8448 ]; - allowedUDPPortRanges =[ + allowedUDPPortRanges = [ # TURN UDP relays - { + { from = 49000; to = 50000; } - # + # { from = 50100; to = 50200; @@ -99,7 +135,11 @@ in { "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFV9eSc9L+aJLoKoexq2f/jb5rpyZnhuGiyhS8YQAbaS wyatt@wyattjmiller.com" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO4WKvKnnYpTbzZHFEslOKyfiiMqWxhW3AfX6E7ACmYU wyatt@wyattjmiller.com" ]; - extraGroups = ["wheel" "video" "network"]; + extraGroups = [ + "wheel" + "video" + "network" + ]; }; # fail2ban @@ -144,11 +184,13 @@ in { server = "${matrixFqdn}:443"; support_email = supportEmail; support_mxid = "@wymiller:${matrixFqdn}"; - - rtc_transports = [{ - type = "livekit"; - livekit_service_url = "https://${rtcFqdn}"; - }]; + + rtc_transports = [ + { + type = "livekit"; + livekit_service_url = "https://${rtcFqdn}"; + } + ]; }; }; }; @@ -176,8 +218,37 @@ in { virtualHosts = { "${matrixFqdn}" = { extraConfig = '' - encode zstd gzip - reverse_proxy localhost:8008 + @matrixEndpoints path \ + /_matrix/* \ + /_tuwunel/* \ + /.well-known/matrix/* + + handle @matrixEndpoints { + reverse_proxy 127.0.0.1:8008 + } + + @sableConfig path /config.json + handle @sableConfig { + root * ${sableConfig} + header Cache-Control "no-store" + file_server + } + + handle { + root * ${sableWeb} + + encode zstd gzip + try_files {path} /index.html + + file_server { + precompressed br + } + + header /assets/* Cache-Control "public, max-age=31536000, immutable" + header /sw.js Cache-Control "no-cache" + header /index.html Cache-Control "no-cache" + header Document-Policy "js-profiling" + } ''; }; "${matrixFqdn}:8448" = { @@ -220,7 +291,10 @@ in { matrix-registration-token-gen = { before = [ "tuwunel.service" ]; wantedBy = [ "multi-user.target" ]; - path = with pkgs; [ coreutils openssl ]; + path = with pkgs; [ + coreutils + openssl + ]; script = '' set -eu @@ -242,9 +316,15 @@ in { }; livekit-key-gen = { - before = [ "lk-jwt-service.service" "livekit.service" ]; + before = [ + "lk-jwt-service.service" + "livekit.service" + ]; wantedBy = [ "multi-user.target" ]; - path = with pkgs; [ coreutils openssl ]; + path = with pkgs; [ + coreutils + openssl + ]; script = '' set -eu