workadventuresrc: { 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"; version = "unstable"; # TODO: perhaps move this into its own file, to make it easily # replacable across all workadventure packages. src = "${workadventuresrc}/front"; # 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 ]; dontStrip = true; patchPhase = '' # remove google tag manager replace-literal -efsw '' ' '; # 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/${pname}/src/Messages/generated HOME=$TMPDIR yarn --offline run build cp -r deps/${pname}/dist/ $out/ ''; distPhase = ":"; installPhase = ":"; } // environment)