diff options
author | stuebinm | 2021-02-05 22:19:01 +0100 |
---|---|---|
committer | stuebinm | 2021-02-05 22:19:01 +0100 |
commit | c46949747779b5e679774ceb23a530ed4736c52b (patch) | |
tree | 543acfbb477be393d8ddd9f1be2ff7aeeb58bf35 /front | |
parent | 71ed23142c5ab6db05263b6e5c52f8fab1d84425 (diff) |
configurable stun server
Diffstat (limited to 'front')
-rw-r--r-- | front/default.nix | 22 |
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 |