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

34 lines
1.2 KiB
Nix
Raw Normal View History

{ stdenv, symlinkJoin, dwarf-therapist, dwarf-fortress, makeWrapper }:
2016-01-12 19:17:46 +01: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 19:17:46 +01:00
in symlinkJoin {
name = "dwarf-therapist-${dwarf-therapist.version}";
2016-01-12 19:17:46 +01:00
paths = [ dwarf-therapist ];
2016-01-12 19:17:46 +01:00
buildInputs = [ makeWrapper ];
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.
wrapProgram $out/bin/dwarftherapist \
2016-01-12 19:17:46 +01:00
--run "cd $out/share/dwarftherapist"
ln -s $out/bin/dwarftherapist $out/bin/DwarfTherapist
2016-01-12 19:17:46 +01: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
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 \
${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
'';
}