{ wowClient, trinityCoreTools, stdenv, lib, symlinkJoin }: let extractor = assetVariant: let tool = { "map" = "mapextractor"; "dbc" = "mapextractor"; "camera" = "mapextractor"; "vmaps" = "vmap4extractor"; "mmaps" = "mmaps_generator"; }.${assetVariant}; toolInvocation = { "map" = "${tool} -i ${toString wowClient} -o $out -e 1"; "dbc" = "${tool} -i ${toString wowClient} -o $out -e 2"; "camera" = "${tool} -i ${toString wowClient} -o $out -e 4"; "vmaps" = "${tool}"; "mmaps" = "${tool}"; }.${assetVariant}; assembleInvocation = { "vmaps" = "vmap4assembler Buildings $out/vmaps"; "mmaps" = "rm -rf $out/mmaps && mv mmaps $out/mmaps"; }.${assetVariant} or null; targetDirectory = { "map" = "maps"; "dbc" = "dbc"; "camera" = "Cameras"; "vmaps" = "vmaps"; "mmaps" = "mmaps"; }.${assetVariant}; in stdenv.mkDerivation { pname = "${assetVariant}-${wowClient.passthru.locale}"; version = wowClient.version; src = if assetVariant == "mmaps" then symlinkJoin { name = "${wowClient.name}-with-extracted-maps-and-vmaps-and-dbc"; paths = [ wowClient (extractor "dbc") (extractor "map") (extractor "vmaps") ]; } else wowClient; preferLocalBuild = assetVariant != "mmaps"; nativeBuildInputs = [ trinityCoreTools ]; buildPhase = '' mkdir -p $out/${targetDirectory} ${toolInvocation} ''; installPhase = lib.optionalString (assembleInvocation != null) '' ${assembleInvocation} ''; }; in extractor