aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2021-08-23 15:18:17 +0200
committerstuebinm2021-08-23 15:20:01 +0200
commit4ad2010194037ad25c54631995e89b9d9ee878b3 (patch)
tree80e5a9765a4af3a2f76b210349d1012314f4f05d
parent8db4bbc5eccaac218c68fb0853f1972dadd7a40c (diff)
init exneuland as alternative backendexneuland
It appears to work (somewhat). Limitations: - exneuland is not configurable; can only have it once - frontend untested since last update broke things
-rw-r--r--TODO3
-rw-r--r--default.nix28
-rw-r--r--exneuland.nix23
-rw-r--r--instance-options.nix11
-rw-r--r--nix/sources.json30
5 files changed, 89 insertions, 6 deletions
diff --git a/TODO b/TODO
index 52cdd5b..0318b27 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,3 @@
- periodically update the tcm version until they declare a stable version
- - add option to use exneuland as backend
+ - rework the entire ./default.nix, it's confusing
+ - figure out what they did to the frontend
diff --git a/default.nix b/default.nix
index 8e631bd..9002aec 100644
--- a/default.nix
+++ b/default.nix
@@ -27,7 +27,23 @@ let
SOCKET_IDLE_TIME = toString commonConfig.socketIdleTime;
};
- servicesBack = mapAttrs' (instanceName: instanceConfig: {
+ servicesBack = mapAttrs' (instanceName: instanceConfig:
+ if instanceConfig.exneuland.enable then {
+ name = "wa-exneuland-${instanceName}";
+ value = {
+ description = "Exneuland backend for ${instanceName}";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network.target" ];
+ serviceConfig = {
+ ExecStart =
+ "${instanceConfig.exneuland.package}/bin/exneuland start";
+ Restart = "always";
+ DynamicUser = true;
+ User = "exneuland-backend";
+ Group = "exneuland-backend";
+ };
+ };
+ } else {
name = "wa-back-${instanceName}";
value = mkIf instanceConfig.backend.enable {
description = "WorkAdventure backend ${instanceName}";
@@ -66,9 +82,9 @@ let
) instances;
servicesPusher = mapAttrs' (instanceName: instanceConfig:
- {
+ {
name = "wa-pusher-${instanceName}";
- value = mkIf instanceConfig.pusher.enable {
+ value = mkIf (instanceConfig.pusher.enable && !instanceConfig.exneuland.enable) {
description = "WorkAdventure pusher ${instanceName}";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
@@ -132,8 +148,10 @@ let
};
"/pusher/" = {
- #proxyPass = "http://10.233.3.1:9000";
- proxyPass = "http://localhost:${toString instanceConfig.pusher.port}/";
+ proxyPass =
+ if instanceConfig.exneuland.enable
+ then "http://localhost:4000"
+ else "http://localhost:${toString instanceConfig.pusher.port}/";
proxyWebsockets = true;
};
diff --git a/exneuland.nix b/exneuland.nix
new file mode 100644
index 0000000..1e9b2b1
--- /dev/null
+++ b/exneuland.nix
@@ -0,0 +1,23 @@
+{ pkgs ? import (import ./nix/sources.nix {}).nixpkgs {}
+, unstable-pkgs ? import (import ./nix/sources.nix {}).nixpkgs-unstable {}
+, exneuland-src ? (import ./nix/sources.nix {}).exneuland
+, ...}:
+
+let
+ packages = pkgs.beam.packagesWith pkgs.beam.interpreters.erlang;
+
+in (packages.mixRelease.override {elixir = unstable-pkgs.elixir_1_12; }) rec {
+ pname = "exneuland";
+ version = "0.0.1";
+ src = exneuland-src;
+
+ mixEnv = "prod";
+
+ mixDeps = packages.fetchMixDeps {
+ pname = "mix-deps-${pname}";
+ inherit src mixEnv version;
+ sha256 = "0nyips2ky6rmgq3xdhrhg4fnw4m2pmck6p1amw9m7qisdqlxhv25";
+ };
+
+ buildInputs = with pkgs; [ rebar3 protobuf ];
+}
diff --git a/instance-options.nix b/instance-options.nix
index 17e398d..f2c5ce9 100644
--- a/instance-options.nix
+++ b/instance-options.nix
@@ -13,6 +13,17 @@ with pkgs;
description = "The package set to use. It should contain a front, backend, pusher, and maps package.";
};
+ exneuland = {
+ enable = mkOption {
+ default = true;
+ type = types.bool;
+ };
+ package = mkOption {
+ default = import ./exneuland.nix {};
+ type = types.package;
+ };
+ };
+
backend = {
enable = mkOption {
default = true;
diff --git a/nix/sources.json b/nix/sources.json
index f653057..08a668e 100644
--- a/nix/sources.json
+++ b/nix/sources.json
@@ -1,4 +1,34 @@
{
+ "exneuland": {
+ "branch": "main",
+ "repo": "https://gitlab.com/hexchen/exneuland",
+ "rev": "5f7640942a332e722a782c29d852eeeb262dd8b8",
+ "type": "git"
+ },
+ "nixpkgs": {
+ "branch": "release-21.05",
+ "description": "Nix Packages collection",
+ "homepage": "",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "dcb27f623fe9b2bb1275029af3148ca7156ede2d",
+ "sha256": "08sdvg2qr801a0v465zyrrbi028b3dm2adb320v7an4878z05nkl",
+ "type": "tarball",
+ "url": "https://github.com/nixos/nixpkgs/archive/dcb27f623fe9b2bb1275029af3148ca7156ede2d.tar.gz",
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
+ },
+ "nixpkgs-unstable": {
+ "branch": "nixpkgs-unstable",
+ "description": "Nix Packages collection",
+ "homepage": "",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "14b0f20fa1f56438b74100513c9b1f7c072cf789",
+ "sha256": "0lzirqazbpx5jda2sppa3ylkn1ywcq1z8v9510pxdpmkp969d1ck",
+ "type": "tarball",
+ "url": "https://github.com/nixos/nixpkgs/archive/14b0f20fa1f56438b74100513c9b1f7c072cf789.tar.gz",
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
+ },
"tcm": {
"branch": "develop",
"description": "A collaborative web application (virtual office) presented as a 16-bit RPG video game",