diff --git a/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix b/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix index f86ef4bea7ab..6e3a13692a72 100644 --- a/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix +++ b/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix @@ -30,11 +30,17 @@ in symlinkJoin { # Fix up memory layouts rm -rf $out/share/dwarftherapist/memory_layouts/linux mkdir -p $out/share/dwarftherapist/memory_layouts/linux - origmd5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8) - patchedmd5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8) - substitute \ - ${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile} \ - $out/share/dwarftherapist/memory_layouts/${inifile} \ - --replace "$origmd5" "$patchedmd5" + orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8) + patched_md5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8) + input_file="${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile}" + output_file="$out/share/dwarftherapist/memory_layouts/${inifile}" + + echo "[Dwarf Therapist Wrapper] Fixing Dwarf Fortress MD5 prefix:" + echo " Input: $input_file" + echo " Search: $orig_md5" + echo " Output: $output_file" + echo " Replace: $patched_md5" + + substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5" ''; } diff --git a/pkgs/games/dwarf-fortress/wrapper/default.nix b/pkgs/games/dwarf-fortress/wrapper/default.nix index 105143916d10..33523270b19d 100644 --- a/pkgs/games/dwarf-fortress/wrapper/default.nix +++ b/pkgs/games/dwarf-fortress/wrapper/default.nix @@ -37,6 +37,39 @@ let paths = themePkg ++ pkgs; pathsToLink = [ "/" "/hack" "/hack/scripts" ]; + + postBuild = '' + # De-symlink init.txt + cp $out/data/init/init.txt init.txt + rm -f $out/data/init/init.txt + mv init.txt $out/data/init/init.txt + '' + lib.optionalString enableDFHack '' + # De-symlink symbols.xml + rm $out/hack/symbols.xml + + # Patch the MD5 + orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig") + patched_md5=$(cat "${dwarf-fortress}/hash.md5") + input_file="${dfhack_}/hack/symbols.xml" + output_file="$out/hack/symbols.xml" + + echo "[DFHack Wrapper] Fixing Dwarf Fortress MD5:" + echo " Input: $input_file" + echo " Search: $orig_md5" + echo " Output: $output_file" + echo " Replace: $patched_md5" + + substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5" + '' + lib.optionalString enableTWBT '' + substituteInPlace $out/data/init/init.txt \ + --replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]' + '' + '' + substituteInPlace $out/data/init/init.txt \ + --replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \ + --replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \ + --replace '[FPS:NO]' '[FPS:${unBool enableFPS}]' + ''; + ignoreCollisions = true; }; in @@ -78,26 +111,5 @@ stdenv.mkDerivation rec { chmod 755 $out/bin/soundsense ''; - postBuild = '' - # De-symlink init.txt - cp $out/data/init/init.txt init.txt - rm $out/data/init/init.txt - mv init.txt $out/data/init/init.txt - '' + lib.optionalString enableDFHack '' - rm $out/hack/symbols.xml - echo "[$out/hack/symbols.xml] $(cat ${dwarf-fortress}/hash.md5.orig) => $(cat ${dwarf-fortress}/hash.md5)" - substitute ${dfhack_}/hack/symbols.xml $out/hack/symbols.xml \ - --replace $(cat ${dwarf-fortress}/hash.md5.orig) \ - $(cat ${dwarf-fortress}/hash.md5) - '' + lib.optionalString enableTWBT '' - substituteInPlace $out/data/init/init.txt \ - --replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]' - '' + '' - substituteInPlace $out/data/init/init.txt \ - --replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \ - --replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \ - --replace '[FPS:NO]' '[FPS:${unBool enableFPS}]' - ''; - preferLocalBuild = true; }