nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix

33 lines
1.1 KiB
Nix
Raw Normal View History

{ stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }:
2016-01-12 18:17:46 +00:00
let
platformSlug = if stdenv.targetPlatform.is32bit then
"linux32" else "linux64";
inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
2016-01-12 18:17:46 +00:00
in symlinkJoin {
name = "dwarf-therapist-${dwarf-therapist.version}";
2016-01-12 18:17:46 +00:00
paths = [ dwarf-therapist ];
2016-01-12 18:17:46 +00:00
buildInputs = [ makeWrapper ];
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.
wrapProgram $out/bin/dwarftherapist \
2016-01-12 18:17:46 +00:00
--run "cd $out/share/dwarftherapist"
rm -rf $out/share/dwarftherapist/memory_layouts/linux
2016-01-12 18:17:46 +00:00
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)
2016-01-12 18:17:46 +00:00
substitute \
${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
'';
}