From c2e4fbb59ffcc9104339b5f7c9f4a81a85ca37ce Mon Sep 17 00:00:00 2001 From: servius Date: Tue, 24 Feb 2026 20:22:14 +0530 Subject: [PATCH] chore: move cinny to a different file --- nixos/tako/services/matrix/cinny.nix | 71 ++++++++++++++++++++++++ nixos/tako/services/matrix/default.nix | 2 +- nixos/tako/services/matrix/tuwunel.nix | 75 +++++--------------------- 3 files changed, 86 insertions(+), 62 deletions(-) create mode 100644 nixos/tako/services/matrix/cinny.nix diff --git a/nixos/tako/services/matrix/cinny.nix b/nixos/tako/services/matrix/cinny.nix new file mode 100644 index 00000000..2acfd36f --- /dev/null +++ b/nixos/tako/services/matrix/cinny.nix @@ -0,0 +1,71 @@ +{ + pkgs, + config, + ... +}: let + base_domain = "darksailor.dev"; + cinnyConfig = builtins.toJSON { + defaultHomeserver = 0; + homeserverList = ["darksailor.dev" "matrix.org"]; + allowCustomHomeservers = false; + hashRouter = { + enabled = true; + basename = "/"; + }; + }; + cinnyConfigFile = pkgs.writeText "cinny-config.json" cinnyConfig; + cinny = with pkgs; + buildNpmPackage rec { + pname = "cinny-unwrapped"; + version = "4.10.5"; + + src = fetchFromGitHub { + owner = "cinnyapp"; + repo = "cinny"; + tag = "v${version}"; + hash = "sha256-Napy3AcsLRDZPcBh3oq1U30FNtvoNtob0+AZtZSvcbM="; + }; + + nodejs = nodejs_22; + + npmDepsHash = "sha256-2Lrd0jAwAH6HkwLHyivqwaEhcpFAIALuno+MchSIfxo="; + + nativeBuildInputs = [ + python3 + pkg-config + ]; + + buildInputs = + [ + pixman + cairo + pango + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [giflib]; + + installPhase = '' + runHook preInstall + + cp -r dist $out + + runHook postInstall + ''; + }; +in { + services.caddy.virtualHosts = { + "matrix.${base_domain}".extraConfig = '' + handle /_matrix/* { + reverse_proxy /_matrix/* localhost:${toString (builtins.elemAt config.services.matrix-tuwunel.settings.global.port 0)} + } + handle_path /config.json { + file_server + root ${cinnyConfigFile} + } + handle { + root * ${cinny} + try_files {path} /index.html + file_server + } + ''; + }; +} diff --git a/nixos/tako/services/matrix/default.nix b/nixos/tako/services/matrix/default.nix index 97ae9d9e..da175959 100644 --- a/nixos/tako/services/matrix/default.nix +++ b/nixos/tako/services/matrix/default.nix @@ -1,7 +1,7 @@ {...}: { imports = [ ./tuwunel.nix - # ./signal.nix // libolm deprecated + # ./signal.nix # ./discord.nix ]; } diff --git a/nixos/tako/services/matrix/tuwunel.nix b/nixos/tako/services/matrix/tuwunel.nix index 7bb04ffa..e755ea8c 100644 --- a/nixos/tako/services/matrix/tuwunel.nix +++ b/nixos/tako/services/matrix/tuwunel.nix @@ -8,53 +8,6 @@ client_id = "tuwunel"; rtc_domain = "matrix-rtc.${base_domain}"; jwt_port = 8081; - cinnyConfig = builtins.toJSON { - defaultHomeserver = 0; - homeserverList = ["darksailor.dev" "matrix.org"]; - allowCustomHomeservers = false; - hashRouter = { - enabled = true; - basename = "/"; - }; - }; - cinnyConfigFile = pkgs.writeText "cinny-config.json" cinnyConfig; - cinny = with pkgs; - buildNpmPackage rec { - pname = "cinny-unwrapped"; - version = "4.10.5"; - - src = fetchFromGitHub { - owner = "cinnyapp"; - repo = "cinny"; - tag = "v${version}"; - hash = "sha256-Napy3AcsLRDZPcBh3oq1U30FNtvoNtob0+AZtZSvcbM="; - }; - - nodejs = nodejs_22; - - npmDepsHash = "sha256-2Lrd0jAwAH6HkwLHyivqwaEhcpFAIALuno+MchSIfxo="; - - nativeBuildInputs = [ - python3 - pkg-config - ]; - - buildInputs = - [ - pixman - cairo - pango - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [giflib]; - - installPhase = '' - runHook preInstall - - cp -r dist $out - - runHook postInstall - ''; - }; in { sops = { secrets."tuwunel/client_id" = { @@ -108,20 +61,20 @@ in { package = pkgs.matrix-tuwunel; }; services.caddy.virtualHosts = { - "matrix.${base_domain}".extraConfig = '' - handle /_matrix/* { - reverse_proxy /_matrix/* localhost:${toString port} - } - handle_path /config.json { - file_server - root ${cinnyConfigFile} - } - handle { - root * ${cinny} - try_files {path} /index.html - file_server - } - ''; + # "matrix.${base_domain}".extraConfig = '' + # handle /_matrix/* { + # reverse_proxy /_matrix/* localhost:${toString port} + # } + # handle_path /config.json { + # file_server + # root ${cinnyConfigFile} + # } + # handle { + # root * ${cinny} + # try_files {path} /index.html + # file_server + # } + # ''; "${base_domain}".extraConfig = '' reverse_proxy /.well-known/* localhost:${toString port} '';