diff options
author | stuebinm | 2021-02-18 15:30:59 +0100 |
---|---|---|
committer | stuebinm | 2021-02-18 15:30:59 +0100 |
commit | 8788bba867874725439a76dc94891e4438568650 (patch) | |
tree | ba05b94edc9308730ef8cb640c9663f3f744d51f /front | |
parent | 129d1b26773099a9b1a823a697b451a24409f362 (diff) |
patch out quill.js cdn
Note that only the sources are patched out; the quill npm package is still
in the nix set and the javascript, it just silently fails to laod at runtime
now.
Diffstat (limited to '')
-rw-r--r-- | front/default.nix | 86 |
1 files changed, 54 insertions, 32 deletions
diff --git a/front/default.nix b/front/default.nix index 26eb4b1..dc3f115 100644 --- a/front/default.nix +++ b/front/default.nix @@ -9,7 +9,9 @@ , ... }: let - # 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 + # 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 @@ -18,8 +20,17 @@ let lib.strings.upperChars (lib.strings.toLower name)); - envVar = (name: lib.optionalAttrs (settings ? ${toCamelCase name}) { ${name} = settings.${toCamelCase name}; }); + # helper function for defining optional environment arguments, which + # may be passed to this package through the `settings` argument + envVar = + (name: lib.optionalAttrs + (settings ? ${toCamelCase name}) + { ${name} = settings.${toCamelCase name}; }); + # all (currently known) options for workadventure-front. Note that + # some of them are pseudo-options, which are not actually implemented + # by workadventure (yet?) and which are instead handled during the + # patch phase of this derivation. envVars = envVar "DEBUG_MODE" // envVar "API_URL" // envVar "UPLOADER_URL" @@ -40,40 +51,51 @@ let // envVar "JITSI_PRIVATE_MODE" // envVar "DEFAULT_MAP_URL" // envVar "STUN_SERVER"; -in yarn2nix-moretea.mkYarnPackage (rec { - pname = "workadventurefront"; - version = "unstable"; +in + yarn2nix-moretea.mkYarnPackage + (rec { + pname = "workadventurefront"; + version = "unstable"; - src = fetchFromGitLab - { - owner = "fediventure"; - repo = "workadventure"; - rev = "1bcf0757fd5203132edd17fc806d81e7699111a7"; - sha256 = "0wwgfrcrpimpxjhk073yxlkcp1p0bn0glxd9wisyq5kv8s7jw1yz"; - } + "/front"; + # TODO: perhaps move this into its own file, to make it easily + # replacable across all workadventure packages. + src = fetchFromGitLab { + owner = "fediventure"; + repo = "workadventure"; + rev = "1bcf0757fd5203132edd17fc806d81e7699111a7"; + sha256 = "0wwgfrcrpimpxjhk073yxlkcp1p0bn0glxd9wisyq5kv8s7jw1yz"; + } + "/front"; + # NOTE: this is optional and generated dynamically if omitted + yarnNix = ./yarn.nix; - # 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 + ]; - nativeBuildInputs = [ makeWrapper replace ]; + dontStrip = true; - 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",' ' '; + '' + + (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 ""); - 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 "") - + (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 + ln -s ${workadventure-messages.outPath}/generated deps/${pname}/src/Messages/generated + HOME=$TMPDIR yarn --offline run build + cp -r deps/${pname}/dist/ $out/ + ''; - 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 = ":"; -} // envVars) + distPhase = ":"; + installPhase = ":"; + } // envVars) |