2021-06-29 03:42:37 +01:00
|
|
|
{ stdenv, dwarf-therapist, dwarf-fortress, substituteAll, coreutils, wrapQtAppsHook }:
|
2016-01-12 18:17:46 +00:00
|
|
|
|
|
|
|
let
|
2021-06-29 03:42:37 +01:00
|
|
|
platformSlug =
|
|
|
|
if stdenv.targetPlatform.is32bit then
|
|
|
|
"linux32" else "linux64";
|
2018-07-08 20:44:29 +01:00
|
|
|
inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
|
2016-01-12 18:17:46 +00:00
|
|
|
|
2018-07-15 08:34:26 +01:00
|
|
|
in
|
2021-01-19 21:20:11 +00:00
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
stdenv.mkDerivation {
|
2018-07-08 20:44:29 +01:00
|
|
|
name = "dwarf-therapist-${dwarf-therapist.version}";
|
2021-01-19 21:20:11 +00:00
|
|
|
|
2021-06-29 03:42:37 +01:00
|
|
|
wrapper = substituteAll {
|
|
|
|
src = ./dwarf-therapist.in;
|
|
|
|
stdenv_shell = "${stdenv.shell}";
|
|
|
|
rm = "${coreutils}/bin/rm";
|
|
|
|
ln = "${coreutils}/bin/ln";
|
|
|
|
cat = "${coreutils}/bin/cat";
|
|
|
|
mkdir = "${coreutils}/bin/mkdir";
|
|
|
|
dirname = "${coreutils}/bin/dirname";
|
|
|
|
therapist = "${dwarf-therapist}";
|
|
|
|
};
|
2016-01-12 18:17:46 +00:00
|
|
|
|
2018-07-08 20:44:29 +01:00
|
|
|
paths = [ dwarf-therapist ];
|
2016-01-12 18:17:46 +00:00
|
|
|
|
2021-06-29 03:42:37 +01:00
|
|
|
nativeBuildInputs = [ wrapQtAppsHook ];
|
2016-01-12 18:17:46 +00:00
|
|
|
|
2018-07-08 20:44:29 +01:00
|
|
|
passthru = { inherit dwarf-fortress dwarf-therapist; };
|
|
|
|
|
2018-07-12 09:42:52 +01:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/bin
|
2021-06-29 03:42:37 +01:00
|
|
|
|
|
|
|
install -Dm755 $wrapper $out/bin/dwarftherapist
|
2018-06-15 20:26:33 +01:00
|
|
|
ln -s $out/bin/dwarftherapist $out/bin/DwarfTherapist
|
2016-01-12 18:17:46 +00:00
|
|
|
|
2021-06-29 03:42:37 +01:00
|
|
|
substituteInPlace $out/bin/dwarftherapist \
|
|
|
|
--subst-var-by install $out
|
|
|
|
wrapQtApp $out/bin/dwarftherapist
|
2018-07-12 09:42:52 +01:00
|
|
|
|
|
|
|
# Fix up memory layouts
|
2016-04-26 13:27:48 +01:00
|
|
|
rm -rf $out/share/dwarftherapist/memory_layouts/linux
|
2016-01-12 18:17:46 +00:00
|
|
|
mkdir -p $out/share/dwarftherapist/memory_layouts/linux
|
2018-07-15 04:58:37 +01:00
|
|
|
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"
|
2016-01-12 18:17:46 +00:00
|
|
|
'';
|
2018-07-15 08:34:26 +01:00
|
|
|
|
|
|
|
preferLocalBuild = true;
|
2016-01-12 18:17:46 +00:00
|
|
|
}
|