aboutsummaryrefslogtreecommitdiff
path: root/front/default.nix
diff options
context:
space:
mode:
authorstuebinm2021-02-26 21:25:38 +0100
committerstuebinm2021-02-26 21:27:40 +0100
commitc530245617f9e224b205f6f0efd9fb7f90c0183a (patch)
tree84bace679217d873ec076a1507be0371caf7b638 /front/default.nix
parentfe9853c5f4e5b029e88c73ed76ea1aaea107cc55 (diff)
parent210a4860ef16f3f00cd5265d238c2a7372a0daa5 (diff)
Move nix files for workadventure into this repo instead of importing them
Since I change things frequently rn and often only very specific commits of both repositories will work together at all, it doesn't seem logical to have them in separate repos any more.
Diffstat (limited to 'front/default.nix')
-rw-r--r--front/default.nix62
1 files changed, 62 insertions, 0 deletions
diff --git a/front/default.nix b/front/default.nix
new file mode 100644
index 0000000..440fa00
--- /dev/null
+++ b/front/default.nix
@@ -0,0 +1,62 @@
+{ stdenv
+, fetchFromGitHub
+, makeWrapper
+, workadventure
+, yarn2nix-moretea
+, lib
+, replace
+, environment ? {}
+, ... }:
+
+let
+ envIf = name: script: if environment ? name then script else "";
+in
+yarn2nix-moretea.mkYarnPackage
+ (rec {
+ pname = "workadventurefront";
+ version = "unstable";
+
+ # TODO: perhaps move this into its own file, to make it easily
+ # replacable across all workadventure packages.
+ src = fetchFromGitHub {
+ owner = "thecodingmachine";
+ repo = "workadventure";
+ rev = "6e9c71598004dc9cbab9418efb3c0ac892da7ca2";
+ sha256 = "0rvra0dy631al4aylacyqldkyd6biawz2shsikgcy30nv5lzc78c";
+ } + "/front";
+
+ # NOTE: this is optional and generated dynamically if omitted
+ yarnNix = ./yarn.nix;
+
+ nativeBuildInputs = [
+ makeWrapper
+ # includes `replace-literal` for patching. This command is
+ # actually the basis for `substituteInPlace`!
+ replace
+ ];
+
+ dontStrip = true;
+
+ patchPhase = ''
+ # remove google tag manager
+ replace-literal -efsw '<script async src="https://www.googletagmanager.com/gtag/js?id=UA-10196481-11"></script>' ' ';
+ # remove quill js cdn
+ replace-literal -efsr -x .ts 'fileref.setAttribute("href", "https://cdn.quilljs.com/1.3.7/quill.snow.css");' ' ';
+ replace-literal -efsr '"@types/quill": "^1.3.7",' ' ';
+ replace-literal -efsr '"quill": "^1.3.7",' ' ';
+ ''
+ + envIf "RESOLUTION" ''replace-literal -efsr -x .ts 'const RESOLUTION = 2' 'const RESOLUTION = ${environment.RESOLUTION}' ''
+ + envIf "ZOOM_LEVEL" ''replace-literal -efsr -x .ts 'const ZOOM_LEVEL = 1' 'const ZOOM_LEVEL = ${environment.ZOOM_LEVEL}' ''
+ + envIf "POSITION_DELAY" ''replace-literal -efsr -x .ts 'const POSITION_DELAY = 200' 'const POSITION_DELAY = ${environment.POSITION_DELAY}' ''
+ + envIf "MAX_EXTRAPOLATION_TIME" ''replace-literal -efsr -x .ts 'const MAX_EXTRAPOLATION_TIME = 100' 'const MAX_EXTRAPOLATION_TIME = ${environment.MAX_EXTRAPOLATION_TIME}' '';
+
+ buildPhase = ''
+ mkdir -p $out
+ ln -s ${workadventure.messages.outPath}/generated deps/${pname}/src/Messages/generated
+ HOME=$TMPDIR yarn --offline run build
+ cp -r deps/${pname}/dist/ $out/
+ '';
+
+ distPhase = ":";
+ installPhase = ":";
+ } // environment)