2018-07-08 20:44:29 +01:00
|
|
|
{ stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }:
|
2016-01-12 18:17:46 +00:00
|
|
|
|
|
|
|
let
|
2017-12-06 23:53:24 +00: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
|
|
|
|
2016-04-26 13:27:48 +01:00
|
|
|
in symlinkJoin {
|
2018-07-08 20:44:29 +01:00
|
|
|
name = "dwarf-therapist-${dwarf-therapist.version}";
|
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
|
|
|
|
|
|
|
buildInputs = [ makeWrapper ];
|
|
|
|
|
2018-07-08 20:44:29 +01:00
|
|
|
passthru = { inherit dwarf-fortress dwarf-therapist; };
|
|
|
|
|
2016-01-12 18:17:46 +00:00
|
|
|
postBuild = ''
|
|
|
|
# DwarfTherapist assumes it's run in $out/share/dwarftherapist and
|
|
|
|
# therefore uses many relative paths.
|
2018-06-07 10:04:45 +01:00
|
|
|
wrapProgram $out/bin/dwarftherapist \
|
2016-01-12 18:17:46 +00:00
|
|
|
--run "cd $out/share/dwarftherapist"
|
|
|
|
|
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-08 20:44:29 +01:00
|
|
|
origmd5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8)
|
|
|
|
patchedmd5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8)
|
2016-01-12 18:17:46 +00:00
|
|
|
substitute \
|
2018-07-08 20:44:29 +01:00
|
|
|
${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile} \
|
2016-01-12 18:17:46 +00:00
|
|
|
$out/share/dwarftherapist/memory_layouts/${inifile} \
|
2016-01-23 20:57:58 +00:00
|
|
|
--replace "$origmd5" "$patchedmd5"
|
2016-01-12 18:17:46 +00:00
|
|
|
'';
|
|
|
|
}
|