Browse Source

Set up matrix-rooms.cryto.net

Sven Slootweg 1 year ago
parent
commit
b23b4e9ea9
2 changed files with 55 additions and 0 deletions
  1. 37 0
      configuration/default.nix
  2. 18 0
      configuration/packages/matrix-rooms/default.nix

+ 37 - 0
configuration/default.nix

@ -8,6 +8,7 @@ let
8 8
					nodeApplication = self.callPackage ./lib/node-application.nix {};
9 9
					unpack = self.callPackage ./lib/unpack.nix {};
10 10
					mobileProxy = self.callPackage ./packages/mobile-proxy { configFile = null; };
11
					matrixRooms = self.callPackage ./packages/matrix-rooms {};
11 12
				};
12 13
			})
13 14
		];
@ -103,6 +104,7 @@ in {
103 104
				"iomfats.cryto.net"
104 105
				"castleroland.cryto.net"
105 106
				"awesomedude.cryto.net"
107
				"matrix-rooms.cryto.net"
106 108
			])
107 109
			(httpsHosts [
108 110
				# "haless.cryto.net"
@ -111,6 +113,7 @@ in {
111 113
				"iomfats.cryto.net"
112 114
				"castleroland.cryto.net"
113 115
				"awesomedude.cryto.net"
116
				"matrix-rooms.cryto.net"
114 117
			])
115 118
		];
116 119
@ -210,6 +213,10 @@ in {
210 213
					(nginxPresets.letsEncrypt)
211 214
					(nginxPresets.reverseProxy "http://127.0.0.1:3000/")
212 215
				];
216
				"matrix-rooms.cryto.net" = lib.mkMerge [
217
					(nginxPresets.letsEncrypt)
218
					(nginxPresets.reverseProxy "http://127.0.0.1:3842/")
219
				];
213 220
			};
214 221
		};
215 222
@ -272,5 +279,35 @@ in {
272 279
				HOME = "/tmp/mobile-proxy-home";
273 280
			};
274 281
		};
282
283
		users.extraUsers.matrix-rooms = {
284
			description = "mobile-proxy Service User";
285
		};
286
287
		systemd.services.matrix-rooms = let
288
			package = pkgs.cryto.matrixRooms;
289
		in {
290
			description = "Matrix Room List Viewer";
291
			wantedBy = ["multi-user.target"];
292
			after = ["network.target"];
293
294
			serviceConfig = {
295
				ExecStart = "${package}/bin/matrix-room-list-viewer"; /* FIXME: Change binary name in its package.json at some point */
296
				User = "matrix-rooms";
297
				Restart = "on-failure";
298
				PermissionsStartOnly = true;
299
			};
300
301
			# FIXME: Is a fake homes necessary for this application?
302
			preStart = ''
303
				mkdir -m 0700 -p /tmp/matrix-rooms-home
304
				chown matrix-rooms /tmp/matrix-rooms-home
305
			'';
306
307
			environment =  {
308
				HOME = "/tmp/matrix-rooms-home";
309
				NODE_ENV = "production";
310
			};
311
		};
275 312
	};
276 313
}

+ 18 - 0
configuration/packages/matrix-rooms/default.nix

@ -0,0 +1,18 @@
1
{ pkgs, ... }:
2
	pkgs.cryto.nodeApplication {
3
		name = "matrix-rooms";
4
		source = pkgs.stdenv.mkDerivation {
5
			name = "matrix-rooms-application";
6
			src = pkgs.cryto.fetchFromCrytoGit {
7
				owner = "joepie91";
8
				repo = "matrix-room-list-viewer";
9
				rev = "5912b79024cba33ee7e291f325d0286b8304af99";
10
				sha256 = "199in3m3vll0i0qsz869x2q6zqn1xxgyvia3fxnmschvfmybbf8r";
11
			};
12
13
			buildCommand = ''
14
				mkdir -p $out
15
				tar -xzvf $src -C $out
16
			'';
17
		};
18
	}