git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #140979 from Ma27/matrix-workers

nixos/matrix-synapse: minor improvements to implement worker-support

commitcbfe4a42f6eef54d96f491679fc0dd609efb49cb authorMaximilian Bosch <maximilian@mbosch.me> dateSat 9 Oct 2021, 15:24 (5 years ago) parentd86eb3bb44e0ef
4 files changed+55−1
nixos/modules/services/misc/matrix-synapse.nix+10 pkgs/servers/matrix-synapse/0001-setup-add-homeserver-as-console-script.patch+1−1 pkgs/servers/matrix-synapse/0002-Expose-generic-worker-as-binary-under-NixOS.patch+43 pkgs/servers/matrix-synapse/default.nix+1
nixos/modules/services/misc/matrix-synapse.nix+10
@@ -122,6 +122,14 @@ in {
122122 options = {
123123 services.matrix-synapse = {
124124 enable = mkEnableOption "matrix.org synapse";
125+ configFile = mkOption {
126+ type = types.str;
127+ readOnly = true;
128+ description = ''
129+ Path to the configuration file on the target system. Useful to configure e.g. workers
130+ that also need this.
131+ '';
132+ };
125133 package = mkOption {
126134 type = types.package;
127135 default = pkgs.matrix-synapse;
@@ -706,6 +714,8 @@ in {
706714 }
707715 ];
708716
717+ services.matrix-synapse.configFile = "${configFile}";
718+
709719 users.users.matrix-synapse = {
710720 group = "matrix-synapse";
711721 home = cfg.dataDir;
pkgs/servers/matrix-synapse/0001-setup-add-homeserver-as-console-script.patch+1−1
@@ -1,7 +1,7 @@
11From 36ffbb7ad2c535180cae473b470a43f9db4fbdcd Mon Sep 17 00:00:00 2001
22From: Maximilian Bosch <maximilian@mbosch.me>
33Date: Mon, 16 Aug 2021 13:27:28 +0200
4−Subject: [PATCH] setup: add homeserver as console script
4+Subject: [PATCH 1/2] setup: add homeserver as console script
55
66With this change, it will be added to `$out/bin` in `nixpkgs` directly.
77This became necessary since our old workaround, calling it as script,
pkgs/servers/matrix-synapse/0002-Expose-generic-worker-as-binary-under-NixOS.patchnew file+43
@@ -0,0 +1,43 @@
1+From 3089758015c64cc1e6788793c4fe40a0e1783457 Mon Sep 17 00:00:00 2001
2+From: Maximilian Bosch <maximilian@mbosch.me>
3+Date: Tue, 5 Oct 2021 22:33:12 +0200
4+Subject: [PATCH 2/2] Expose generic worker as binary under NixOS
5+
6+---
7+ setup.py | 3 ++-
8+ synapse/app/generic_worker.py | 6 +++++-
9+ 2 files changed, 7 insertions(+), 2 deletions(-)
10+
11+diff --git a/setup.py b/setup.py
12+index 27f1d842c..6383aed6f 100755
13+--- a/setup.py
14++++ b/setup.py
15+@@ -135,7 +135,8 @@ setup(
16+ python_requires="~=3.6",
17+ entry_points={
18+ 'console_scripts': [
19+- 'homeserver = synapse.app.homeserver:main'
20++ 'homeserver = synapse.app.homeserver:main',
21++ 'worker = synapse.app.generic_worker:main'
22+ ]
23+ },
24+ classifiers=[
25+diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py
26+index 3b7131af8..c77a6a95c 100644
27+--- a/synapse/app/generic_worker.py
28++++ b/synapse/app/generic_worker.py
29+@@ -491,6 +491,10 @@ def start(config_options):
30+ _base.start_worker_reactor("synapse-generic-worker", config)
31+
32+
33+-if __name__ == "__main__":
34++def main():
35+ with LoggingContext("main"):
36+ start(sys.argv[1:])
37++
38++
39++if __name__ == "__main__":
40++ main()
41+--
42+2.31.1
43+
pkgs/servers/matrix-synapse/default.nix+1
@@ -36,6 +36,7 @@ buildPythonApplication rec {
3636
3737 patches = [
3838 ./0001-setup-add-homeserver-as-console-script.patch
39+ ./0002-Expose-generic-worker-as-binary-under-NixOS.patch
3940 ];
4041
4142 buildInputs = [ openssl ];