2018-07-08 21:44:29 +02:00
|
|
|
{ stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }:
|
2016-01-12 19:17:46 +01:00
|
|
|
|
|
|
|
let
|
2017-12-07 00:53:24 +01:00
|
|
|
platformSlug = if stdenv.targetPlatform.is32bit then
|
|
|
|
"linux32" else "linux64";
|
2018-07-08 21:44:29 +02:00
|
|
|
inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
|
2016-01-12 19:17:46 +01:00
|
|
|
|
2016-04-26 14:27:48 +02:00
|
|
|
in symlinkJoin {
|
2018-07-08 21:44:29 +02:00
|
|
|
name = "dwarf-therapist-${dwarf-therapist.version}";
|
2016-01-12 19:17:46 +01:00
|
|
|
|
2018-07-08 21:44:29 +02:00
|
|
|
paths = [ dwarf-therapist ];
|
2016-01-12 19:17:46 +01:00
|
|
|
|
|
|
|
buildInputs = [ makeWrapper ];
|
|
|
|
|
2018-07-08 21:44:29 +02:00
|
|
|
passthru = { inherit dwarf-fortress dwarf-therapist; };
|
|
|
|
|
2016-01-12 19:17:46 +01:00
|
|
|
postBuild = ''
|
|
|
|
# DwarfTherapist assumes it's run in $out/share/dwarftherapist and
|
|
|
|
# therefore uses many relative paths.
|
2018-06-07 11:04:45 +02:00
|
|
|
wrapProgram $out/bin/dwarftherapist \
|
2016-01-12 19:17:46 +01:00
|
|
|
--run "cd $out/share/dwarftherapist"
|
|
|
|
|
2016-04-26 14:27:48 +02:00
|
|
|
rm -rf $out/share/dwarftherapist/memory_layouts/linux
|
2016-01-12 19:17:46 +01:00
|
|
|
mkdir -p $out/share/dwarftherapist/memory_layouts/linux
|
2018-07-08 21:44:29 +02:00
|
|
|
origmd5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8)
|
|
|
|
patchedmd5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8)
|
2016-01-12 19:17:46 +01:00
|
|
|
substitute \
|
2018-07-08 21:44:29 +02:00
|
|
|
${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile} \
|
2016-01-12 19:17:46 +01:00
|
|
|
$out/share/dwarftherapist/memory_layouts/${inifile} \
|
2016-01-23 21:57:58 +01:00
|
|
|
--replace "$origmd5" "$patchedmd5"
|
2016-01-12 19:17:46 +01:00
|
|
|
'';
|
|
|
|
}
|