2019-06-16 12:59:06 -07:00
|
|
|
{ pkgs, stdenv, dwarf-therapist, dwarf-fortress, makeWrapper }:
|
2016-01-12 10:17:46 -08:00
|
|
|
|
|
|
|
let
|
2017-12-06 15:53:24 -08:00
|
|
|
platformSlug = if stdenv.targetPlatform.is32bit then
|
|
|
|
"linux32" else "linux64";
|
2018-07-08 12:44:29 -07:00
|
|
|
inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
|
2016-01-12 10:17:46 -08:00
|
|
|
|
2018-07-15 00:34:26 -07:00
|
|
|
in
|
2021-01-19 13:20:11 -08:00
|
|
|
|
2019-08-13 14:52:01 -07:00
|
|
|
stdenv.mkDerivation {
|
2018-07-08 12:44:29 -07:00
|
|
|
name = "dwarf-therapist-${dwarf-therapist.version}";
|
2021-01-19 13:20:11 -08:00
|
|
|
|
2018-07-12 01:42:52 -07:00
|
|
|
wrapper = ./dwarf-therapist.in;
|
2016-01-12 10:17:46 -08:00
|
|
|
|
2018-07-08 12:44:29 -07:00
|
|
|
paths = [ dwarf-therapist ];
|
2016-01-12 10:17:46 -08:00
|
|
|
|
2021-02-07 01:17:39 -08:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2016-01-12 10:17:46 -08:00
|
|
|
|
2018-07-08 12:44:29 -07:00
|
|
|
passthru = { inherit dwarf-fortress dwarf-therapist; };
|
|
|
|
|
2018-07-12 01:42:52 -07:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/bin
|
2018-06-15 12:26:33 -07:00
|
|
|
ln -s $out/bin/dwarftherapist $out/bin/DwarfTherapist
|
2018-07-12 01:42:52 -07:00
|
|
|
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"
|
2016-01-12 10:17:46 -08:00
|
|
|
|
2018-07-12 01:42:52 -07:00
|
|
|
chmod 755 $out/bin/dwarftherapist
|
|
|
|
|
|
|
|
# Fix up memory layouts
|
2016-04-26 05:27:48 -07:00
|
|
|
rm -rf $out/share/dwarftherapist/memory_layouts/linux
|
2016-01-12 10:17:46 -08:00
|
|
|
mkdir -p $out/share/dwarftherapist/memory_layouts/linux
|
2018-07-14 20:58:37 -07: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 10:17:46 -08:00
|
|
|
'';
|
2018-07-15 00:34:26 -07:00
|
|
|
|
|
|
|
preferLocalBuild = true;
|
2016-01-12 10:17:46 -08:00
|
|
|
}
|