diff options
Diffstat (limited to 'pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix')
-rw-r--r-- | pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix b/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix index 322a21ec3ad9..071ab2af0c5c 100644 --- a/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix +++ b/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix @@ -1,12 +1,16 @@ -{ stdenv, symlinkJoin, dwarf-therapist, dwarf-fortress, makeWrapper }: +{ pkgs, stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }: let platformSlug = if stdenv.targetPlatform.is32bit then "linux32" else "linux64"; inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini"; -in symlinkJoin { +in + +stdenv.mkDerivation rec { name = "dwarf-therapist-${dwarf-therapist.version}"; + + wrapper = ./dwarf-therapist.in; paths = [ dwarf-therapist ]; @@ -14,20 +18,33 @@ in symlinkJoin { passthru = { inherit dwarf-fortress dwarf-therapist; }; - postBuild = '' - # DwarfTherapist assumes it's run in $out/share/dwarftherapist and - # therefore uses many relative paths. - wrapProgram $out/bin/dwarftherapist \ - --run "cd $out/share/dwarftherapist" + buildCommand = '' + mkdir -p $out/bin ln -s $out/bin/dwarftherapist $out/bin/DwarfTherapist + substitute $wrapper $out/bin/dwarftherapist \ + --subst-var-by stdenv_shell ${stdenv.shell} \ + --subst-var-by install $out \ + --subst-var-by therapist ${dwarf-therapist} \ + --subst-var-by qt_plugin_path "${pkgs.qt5.qtbase}/lib/qt-${pkgs.qt5.qtbase.qtCompatVersion}/plugins/platforms" + chmod 755 $out/bin/dwarftherapist + + # 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" ''; + + preferLocalBuild = true; } |