about summary refs log tree commit diff
path: root/pkgs/games/dwarf-therapist/default.nix
blob: 9ecfe3c0acdd5741b16f4f22722291bce32940c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{ stdenv, coreutils, fetchurl, qt4, dwarf_fortress, bash, makeWrapper }:

let
  version = "30.1.0";
  df = dwarf_fortress;
in
stdenv.mkDerivation rec {
  name = "dwarf-therapist-${version}";

  src = fetchurl {
    url = "https://github.com/splintermind/Dwarf-Therapist/archive/v${version}.tar.gz";
    sha256 = "1x9dkis6b3f8iqcfrc2cj9mcgkwf0rzhxhq2lgy4xdr2n0yjkyv7";
  };

  # Needed for hashing
  dfHashFile = "${df}/share/df_linux/hash.md5";

  buildInputs = [ coreutils qt4 df makeWrapper ];
  enableParallelBuilding = false;

  configurePhase = ''
    substituteInPlace dwarftherapist.pro \
      --replace /usr/bin $out/bin     \
      --replace /usr/share $out/share \
      --replace "INSTALLS += doc" ""

    qmake INSTALL_PREFIX=$out
  '';

  postInstall = ''
    # DwarfTherapist assumes it's run in $out/share/dwarftherapist and
    # therefore uses many relative paths.
    rm $out/bin/dwarftherapist
    wrapProgram $out/bin/DwarfTherapist \
      --run "cd $out/share/dwarftherapist"
  '';

  postFixup = ''
    # Fix checksum of memory access directives
    substituteInPlace $out/share/dwarftherapist/memory_layouts/linux/v0${df.baseVersion}.${df.patchVersion}.ini \
      --replace $(cat "${dfHashFile}.orig") $(cat "${dfHashFile}.patched")
  '';

  meta = {
    description = "Tool to manage dwarves in in a running game of Dwarf Fortress";
    maintainers = with stdenv.lib.maintainers; [ the-kenny ];
    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.linux;
    hydraPlatforms = [];
    homepage = https://code.google.com/r/splintermind-attributes/;
  };
}