From 8109dc3abc7af83e9e5b182a6fbe37a0e96f9e6c Mon Sep 17 00:00:00 2001 From: magic_rb Date: Sat, 7 Oct 2023 19:55:39 +0200 Subject: [PATCH] Update synapse container Signed-off-by: magic_rb --- flake.lock | 6 +- .../matrix/synapse/generic_worker.nix | 1 + .../matrix/synapse/synapse-package.nix | 10 +++ nixng/containers/matrix/synapse/synapse.nix | 88 +++++++++---------- 4 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 nixng/containers/matrix/synapse/synapse-package.nix diff --git a/flake.lock b/flake.lock index b54de9b..cb6b717 100644 --- a/flake.lock +++ b/flake.lock @@ -1112,11 +1112,11 @@ "nixpkgs": "nixpkgs_8" }, "locked": { - "lastModified": 1689967002, - "narHash": "sha256-CYpbDmABaiRtH7MtIjBKAJ2H2MDqZU8Mur3Qkgj6J3w=", + "lastModified": 1696701494, + "narHash": "sha256-8R+nrspQZ0mMiOk66bDjlVrEZsYwb6siDIR41oFuUTs=", "owner": "nix-community", "repo": "NixNG", - "rev": "3cba1cfa9cfd8051333d45a60cc180907461a2dd", + "rev": "c12525e008a489cf5a41447242d4a51ee7eab461", "type": "github" }, "original": { diff --git a/nixng/containers/matrix/synapse/generic_worker.nix b/nixng/containers/matrix/synapse/generic_worker.nix index c46e7e0..8fc0f15 100644 --- a/nixng/containers/matrix/synapse/generic_worker.nix +++ b/nixng/containers/matrix/synapse/generic_worker.nix @@ -18,6 +18,7 @@ makeSystem { }; services.synapse.workers.${name} = { + package = import ./synapse-package.nix pkgs; settings = { worker_app = "synapse.app.generic_worker"; diff --git a/nixng/containers/matrix/synapse/synapse-package.nix b/nixng/containers/matrix/synapse/synapse-package.nix new file mode 100644 index 0000000..945f32b --- /dev/null +++ b/nixng/containers/matrix/synapse/synapse-package.nix @@ -0,0 +1,10 @@ +pkgs: +pkgs.matrix-synapse.override { + extras = [ + "redis" + "cache-memory" + "postgres" + "url-preview" + "user-search" + ]; +} diff --git a/nixng/containers/matrix/synapse/synapse.nix b/nixng/containers/matrix/synapse/synapse.nix index 8612c61..065fdec 100644 --- a/nixng/containers/matrix/synapse/synapse.nix +++ b/nixng/containers/matrix/synapse/synapse.nix @@ -11,7 +11,8 @@ makeSystem { { pkgs, lib, ... }: let inherit (lib) - singleton; + singleton + makeSearchPathOutput; in { dumb-init = { @@ -19,54 +20,49 @@ makeSystem { type.services = { }; }; - init.services.synapse = { - enabled = true; - shutdownOnExit = true; - script = - let - synapseConfig = (pkgs.formats.yaml {}).generate "synapse.yaml" + services.synapse = { + enable = true; + package = import ./synapse-package.nix pkgs; + settings = { + listeners = + [ + # The HTTP replication port { - listeners = - [ - # The HTTP replication port - { - port = 9093; - bind_addresses = [ "0.0.0.0" ]; - type = "http"; - resources = [ - { - names = [ "replication" ]; - } - ]; - } - { - port = 6167; - tls = false; - type = "http"; - x_forwarded = true; - bind_adrresses = [ "0.0.0.0" ]; - resources = singleton { - names = [ "client" "federation" ]; - compress = false; - }; - } - ]; + port = 9093; + bind_addresses = [ "0.0.0.0" ]; + type = "http"; + resources = [ + { + names = [ "replication" ]; + } + ]; + } + { + port = 6167; + tls = false; + type = "http"; + x_forwarded = true; + bind_adrresses = [ "0.0.0.0" ]; + resources = singleton { + names = [ "client" "federation" ]; + compress = false; + }; + } + ]; - public_baseurl = "https://matrix.redalder.org/"; + public_baseurl = "https://matrix.redalder.org/"; - # Add a random shared secret to authenticate traffic. - worker_replication_secret = ""; - }; - in - pkgs.writeShellScript "synapse" '' - ${pkgs.matrix-synapse}/bin/synapse_homeserver \ - --config-path ${synapseConfig} \ - --config-path ${commonConfig pkgs} \ - --config-path /secrets/extra.yaml \ - --config-path /var/lib/registrations/extra.yaml \ - --keys-directory /var/lib/synapse/keys \ - $([ -e /var/lib/synapse/signing.key ] || echo --generate-keys) - ''; + # Add a random shared secret to authenticate traffic. + worker_replication_secret = ""; + }; + arguments = { + "config-path" = [ + (commonConfig pkgs) + "/secrets/extra.yaml" + "/var/lib/registrations/extra.yaml" + ]; + "keys-directory" = "/var/lib/synapse/keys"; + }; }; }; }