1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# this file is a function, which returns functions, which in turn
# return derivations for various versions of workadventure, because
# apparently nix just works that way.
#
# Note that this is meant to be compatible with as many of the existing
# workadventure forks as possible — so some parts of this may seem outdated
# or be entirely useless with the "official" version, but are kept in
# case other forks still need them.
workadventuresrc: waname:
{ stdenv
, makeWrapper
, workadventure
, yarn2nix-moretea
, lib
, replace
, environment ? {}
, ... }:
let
envIf = name: script: if environment ? name then script else "";
in
yarn2nix-moretea.mkYarnPackage
(rec {
pname = "workadventurefront-${waname}";
version = "unstable";
name = pname + "-" + version;
src = "${workadventuresrc}/front";
yarnNix = ./. + "/${waname}.nix";
nativeBuildInputs = [
makeWrapper
# includes `replace-literal` for patching. This command is
# actually the basis for `substituteInPlace`!
replace
];
dontStrip = true;
patchPhase = ''
# copy input to actual input location (see the ./templater.sh file in newer wa versions)
cp dist/index.tmpl.html dist/index.tmpl.html.tmp
# remove google tag manager (for older versions)
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/workadventurefront/src/Messages/generated
HOME=$TMPDIR yarn --offline run build
cp -r deps/workadventurefront/dist/ $out/
'';
distPhase = ":";
installPhase = ":";
} // environment)
|