diff --git a/configuration/default.nix b/configuration/default.nix index 1b14f4a..cca65da 100644 --- a/configuration/default.nix +++ b/configuration/default.nix @@ -8,6 +8,7 @@ let nodeApplication = self.callPackage ./lib/node-application.nix {}; unpack = self.callPackage ./lib/unpack.nix {}; mobileProxy = self.callPackage ./packages/mobile-proxy { configFile = null; }; + matrixRooms = self.callPackage ./packages/matrix-rooms {}; }; }) ]; @@ -103,6 +104,7 @@ in { "iomfats.cryto.net" "castleroland.cryto.net" "awesomedude.cryto.net" + "matrix-rooms.cryto.net" ]) (httpsHosts [ # "haless.cryto.net" @@ -111,6 +113,7 @@ in { "iomfats.cryto.net" "castleroland.cryto.net" "awesomedude.cryto.net" + "matrix-rooms.cryto.net" ]) ]; @@ -210,6 +213,10 @@ in { (nginxPresets.letsEncrypt) (nginxPresets.reverseProxy "http://127.0.0.1:3000/") ]; + "matrix-rooms.cryto.net" = lib.mkMerge [ + (nginxPresets.letsEncrypt) + (nginxPresets.reverseProxy "http://127.0.0.1:3842/") + ]; }; }; @@ -272,5 +279,35 @@ in { HOME = "/tmp/mobile-proxy-home"; }; }; + + users.extraUsers.matrix-rooms = { + description = "mobile-proxy Service User"; + }; + + systemd.services.matrix-rooms = let + package = pkgs.cryto.matrixRooms; + in { + description = "Matrix Room List Viewer"; + wantedBy = ["multi-user.target"]; + after = ["network.target"]; + + serviceConfig = { + ExecStart = "${package}/bin/matrix-room-list-viewer"; /* FIXME: Change binary name in its package.json at some point */ + User = "matrix-rooms"; + Restart = "on-failure"; + PermissionsStartOnly = true; + }; + + # FIXME: Is a fake homes necessary for this application? + preStart = '' + mkdir -m 0700 -p /tmp/matrix-rooms-home + chown matrix-rooms /tmp/matrix-rooms-home + ''; + + environment = { + HOME = "/tmp/matrix-rooms-home"; + NODE_ENV = "production"; + }; + }; }; } diff --git a/configuration/packages/matrix-rooms/default.nix b/configuration/packages/matrix-rooms/default.nix new file mode 100644 index 0000000..e464ff2 --- /dev/null +++ b/configuration/packages/matrix-rooms/default.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: + pkgs.cryto.nodeApplication { + name = "matrix-rooms"; + source = pkgs.stdenv.mkDerivation { + name = "matrix-rooms-application"; + src = pkgs.cryto.fetchFromCrytoGit { + owner = "joepie91"; + repo = "matrix-room-list-viewer"; + rev = "5912b79024cba33ee7e291f325d0286b8304af99"; + sha256 = "199in3m3vll0i0qsz869x2q6zqn1xxgyvia3fxnmschvfmybbf8r"; + }; + + buildCommand = '' + mkdir -p $out + tar -xzvf $src -C $out + ''; + }; + }