aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--front/default.nix22
1 files changed, 17 insertions, 5 deletions
diff --git a/front/default.nix b/front/default.nix
index 00db42c..26eb4b1 100644
--- a/front/default.nix
+++ b/front/default.nix
@@ -5,11 +5,20 @@
, yarn2nix-moretea
, lib
, replace
-, environment ? {}
+, settings ? {}
, ... }:
let
- envVar = (name: lib.optionalAttrs (environment ? ${name}) { ${name} = environment.${name}; });
+ # nix is nice enough that we can just convert options written in camelCase into CAMEL_CASE to make environment vars out of them, which workadventure will use during its build
+ toCamelCase =
+ (name: builtins.replaceStrings
+ (map
+ (c : "_${c}")
+ lib.strings.lowerChars)
+ lib.strings.upperChars
+ (lib.strings.toLower name));
+
+ envVar = (name: lib.optionalAttrs (settings ? ${toCamelCase name}) { ${name} = settings.${toCamelCase name}; });
envVars = envVar "DEBUG_MODE"
// envVar "API_URL"
@@ -29,7 +38,8 @@ let
// envVar "TURN_PASSWORD"
// envVar "JITSI_URL"
// envVar "JITSI_PRIVATE_MODE"
- // envVar "DEFAULT_MAP_URL";
+ // envVar "DEFAULT_MAP_URL"
+ // envVar "STUN_SERVER";
in yarn2nix-moretea.mkYarnPackage (rec {
pname = "workadventurefront";
version = "unstable";
@@ -52,8 +62,10 @@ in yarn2nix-moretea.mkYarnPackage (rec {
patchPhase = ''
# remove google tag manager
- replace-literal -efsw '<script async src="https://www.googletagmanager.com/gtag/js?id=UA-10196481-11"></script>' ' '
- '' + (if envVars ? DEFAULT_MAP_URL then ''replace-literal -efs -r -x .ts "/Floor0/floor0.json" "${envVars.DEFAULT_MAP_URL}"'' else "");
+ replace-literal -efsw '<script async src="https://www.googletagmanager.com/gtag/js?id=UA-10196481-11"></script>' ' ';
+ ''
+ + (if envVars ? DEFAULT_MAP_URL then ''replace-literal -efs -r -x .ts "/Floor0/floor0.json" "${envVars.DEFAULT_MAP_URL}";'' else "")
+ + (if envVars ? STUN_SERVER then ''replace-literal -efs -r -x .ts "stun:stun.l.google.com:19302" "${envVars.STUN_SERVER}";'' else "");
buildPhase = ''
mkdir -p $out