From c46949747779b5e679774ceb23a530ed4736c52b Mon Sep 17 00:00:00 2001
From: stuebinm
Date: Fri, 5 Feb 2021 22:19:01 +0100
Subject: configurable stun server
---
front/default.nix | 22 +++++++++++++++++-----
1 file 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 '' ' '
- '' + (if envVars ? DEFAULT_MAP_URL then ''replace-literal -efs -r -x .ts "/Floor0/floor0.json" "${envVars.DEFAULT_MAP_URL}"'' else "");
+ replace-literal -efsw '' ' ';
+ ''
+ + (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
--
cgit v1.2.3