nixpkgs-suyu/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix
Matthew Bauer 530427c7ab dwarf-fortress: refactors
This will make it easier for people to access old versions.

You can now access attributes like:

- dwarf-fortress_0_44_11
- dwarf-fortress_0_43_05
- etc.
2018-07-09 16:13:52 -04:00

32 lines
1.1 KiB
Nix

{ stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }:
let
platformSlug = if stdenv.targetPlatform.is32bit then
"linux32" else "linux64";
inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
in symlinkJoin {
name = "dwarf-therapist-${dwarf-therapist.version}";
paths = [ dwarf-therapist ];
buildInputs = [ makeWrapper ];
passthru = { inherit dwarf-fortress dwarf-therapist; };
postBuild = ''
# DwarfTherapist assumes it's run in $out/share/dwarftherapist and
# therefore uses many relative paths.
wrapProgram $out/bin/dwarftherapist \
--run "cd $out/share/dwarftherapist"
rm -rf $out/share/dwarftherapist/memory_layouts/linux
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)
substitute \
${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile} \
$out/share/dwarftherapist/memory_layouts/${inifile} \
--replace "$origmd5" "$patchedmd5"
'';
}