ctucx.git: nixfiles

ctucx' nixfiles

commit 0da1dadc239a56a5e1dac08a2d8fc86792fc098f
parent c15b11aaaadbb1eb33efe0a8d17fce8c0a1d60b2
Author: Leah (ctucx) <git@ctu.cx>
Date: Wed, 3 Apr 2024 14:46:22 +0200

machines/trabbi/matrix: use `sliding-sync-server` packaged in nixpkgs
5 files changed, 11 insertions(+), 128 deletions(-)
M
machines/trabbi/matrix/synapse.nix
|
19
+++++++++++--------
M
modules/default.nix
|
1
-
D
modules/linux/matrix-sliding-sync.nix
|
95
-------------------------------------------------------------------------------
D
pkgs/matrix-sliding-sync.nix
|
23
-----------------------
M
pkgs/overlay.nix
|
1
-
diff --git a/machines/trabbi/matrix/synapse.nix b/machines/trabbi/matrix/synapse.nix
@@ -6,6 +6,7 @@
 
   age.secrets = {
     restic-matrix-synapse.file        = ./. + "/../../../secrets/${config.networking.hostName}/restic/matrix-synapse.age";
+    matrix-sliding-sync-env.file      = ./. + "/../../../secrets/${config.networking.hostName}/matrix-synapse/sliding-sync-env.age";
     matrix-registration_shared_secret = {
       file  = ./. + "/../../../secrets/${config.networking.hostName}/matrix-synapse/registration_shared_secret.age";
       owner = "matrix-synapse";

@@ -43,6 +44,16 @@
     matrix-synapse = {
       enable         = true;
       withJemalloc   = true;
+
+      sliding-sync = {
+        enable = true;
+        environmentFile = config.age.secrets.matrix-sliding-sync-env.path;
+        settings = {
+          SYNCV3_SERVER   = "https://matrix.ctu.cx";
+          SYNCV3_BINDADDR = "[::1]:8009";
+        };
+      };
+
       settings       = {
         server_name                     = "ctu.cx";
         public_baseurl                  = "https://matrix.ctu.cx/";

@@ -65,14 +76,6 @@
       };
     };
 
-    matrix-sliding-sync-proxy = {
-      enable = true;
-      dbName = "syncv3";
-      bind = "[::1]:8009";
-      server = "http://[::1]:8008";
-      package = pkgs.matrix-sliding-sync;
-    };
-
     nginx = {
       enable       = true;
       virtualHosts = {
diff --git a/modules/default.nix b/modules/default.nix
@@ -17,7 +17,6 @@
      ./linux/email-notify.nix
      ./linux/dns.nix
      ./linux/gotosocial.nix
-     ./linux/matrix-sliding-sync.nix
      ./linux/nginx-sni-proxy.nix
     ] else [])
     (if (currentSystem == "aarch64-darwin") then [
diff --git a/modules/linux/matrix-sliding-sync.nix b/modules/linux/matrix-sliding-sync.nix
@@ -1,94 +0,0 @@
-{ config, pkgs, lib, ... }:
-with lib;
-
-let
-  cfg = config.services.matrix-sliding-sync-proxy;
-  user = if cfg.user == null then "matrix-sliding-sync-proxy" else cfg.user;
-
-in {
-
-  options = {
-    services.matrix-sliding-sync-proxy = {
-
-      enable = mkEnableOption "the experimental matrix sliding sync proxy";
-
-      package = mkOption {
-        type = types.package;
-        default = pkgs.matrix-sliding-sync-proxy;
-        description = "Package to use for the service.";
-      };
-
-      server = mkOption {
-        type = types.str;
-        default = "https://localhost:8448/";
-        description = "Server to proxy requests for.";
-      };
-
-      dbName = mkOption {
-        default = null;
-        type = types.nullOr types.str;
-        example = "syncv3";
-        description = "Postgres database name to access.";
-      };
-
-      bind = mkOption {
-        type = types.str;
-        default = "localhost:8008";
-        description = "Port to bind the proxy to.";
-      };
-
-      dbHost = mkOption {
-        default = "/run/postgresql";
-        type = types.str;
-        description = "Path to postgresql socket.";
-      };
-
-      user = mkOption {
-        default = null;
-        description =
-          "User under which the service runs. Created automatically if null.";
-      };
-
-    };
-  };
-
-  config = mkIf cfg.enable {
-    assertions = [{
-      assertion = cfg.dbName != null;
-      message = ''
-        A Postgres database is required for matrix-sliding-sync-proxy to work.
-        See `services.matrix-sliding-sync-proxy.db` in `man configuration.nix` for details.
-      '';
-    }];
-
-    systemd.services.matrix-sliding-sync = {
-      after    = [ "network-online.target" "postgresql.service" ];
-      wantedBy = [ "multi-user.target" ];
-      script = ''
-        cd ${cfg.package}/share
-        exec ${cfg.package}/bin/syncv3
-      '';
-      serviceConfig = {
-        User       = user;
-        Restart    = "always";
-        RestartSec = 5;
-      };
-      environment = {
-        SYNCV3_DB = "user=${user} dbname=${cfg.dbName} sslmode=disable host=${cfg.dbHost}";
-        SYNCV3_BINDADDR = "${cfg.bind}";
-        SYNCV3_SERVER = "${cfg.server}";
-        SYNCV3_SECRET = "foobar";
-      };
-    };
-
-    users = mkIf (cfg.user == null) {
-      users.matrix-sliding-sync-proxy = {
-        isSystemUser = true;
-        group = "matrix-sliding-sync-proxy";
-      };
-      groups.matrix-sliding-sync-proxy = { };
-    };
-
-  };
-
-}-
\ No newline at end of file
diff --git a/pkgs/matrix-sliding-sync.nix b/pkgs/matrix-sliding-sync.nix
@@ -1,22 +0,0 @@
-{ lib, buildGoModule, fetchFromGitHub }:
-
-buildGoModule rec {
-  pname = "matrix-sliding-sync-proxy";
-  version = "0.99.1";
-
-  src = fetchFromGitHub {
-    owner = "matrix-org";
-    repo = "sliding-sync";
-    rev = "v${version}";
-    sha256 = "sha256-g1yMGb8taToEFG6N057yPcdZB855r0f6EwnJ98FIiic=";
-  };
-
-  subPackages = [ "cmd/syncv3" ];
-
-  vendorHash = "sha256-FmibAVjKeJUrMSlhoE7onLoa4EVjQvjDI4oU4PB5LBE=";
-
-  postInstall = ''
-    mkdir -p $out/share
-    cp -r ./client $out/share/client
-  '';
-}-
\ No newline at end of file
diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix
@@ -17,7 +17,6 @@ final: prev:
   mbusd                  = final.callPackage ./mbusd.nix {};
   homebridge             = final.callPackage ./homebridge {};
   agenix                 = final.callPackage ./agenix {};
-  matrix-sliding-sync    = final.callPackage ./matrix-sliding-sync.nix {};
   mastoFE-standalone     = final.callPackage ./masto-fe-standalone {};
 
   usbtan-cli             = final.callPackage ./usbtan-cli {};