summary refs log tree commit diff
path: root/pkgs/games/dwarf-fortress/game.nix
blob: 4c8712fd40ec277546eb069402800648cf9e0949 (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
53
54
55
56
57
{ stdenv, lib, fetchurl
, SDL, dwarf-fortress-unfuck
}:

let
  baseVersion = "44";
  patchVersion = "03";
  dfVersion = "0.${baseVersion}.${patchVersion}";
  libpath = lib.makeLibraryPath [ stdenv.cc.cc stdenv.glibc dwarf-fortress-unfuck SDL ];
  platform =
    if stdenv.system == "x86_64-linux" then "linux"
    else if stdenv.system == "i686-linux" then "linux32"
    else throw "Unsupported platform";
  sha256 =
    if stdenv.system == "x86_64-linux" then "0bgrkwcdghwch96krqdwq8lcjwr6svw0xl53d2jysyszfy7nfl88"
    else if stdenv.system == "i686-linux" then "1mvnbkjvm68z2q7h81jrh70qy9458b1spv0m3nlc680fm19hpz40"
    else throw "Unsupported platform";

in

assert dwarf-fortress-unfuck.dfVersion == dfVersion;

stdenv.mkDerivation {
  name = "dwarf-fortress-original-${dfVersion}";

  src = fetchurl {
    url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_${platform}.tar.bz2";
    inherit sha256;
  };

  installPhase = ''
    mkdir -p $out
    cp -r * $out
    rm $out/libs/lib*

    # Store the original hash
    md5sum $out/libs/Dwarf_Fortress | awk '{ print $1 }' > $out/hash.md5.orig

    patchelf \
      --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
      --set-rpath "${libpath}" \
      $out/libs/Dwarf_Fortress

    # Store the new hash
    md5sum $out/libs/Dwarf_Fortress | awk '{ print $1 }' > $out/hash.md5
  '';

  passthru = { inherit baseVersion patchVersion dfVersion; };

  meta = with stdenv.lib; {
    description = "A single-player fantasy game with a randomly generated adventure world";
    homepage = http://www.bay12games.com/dwarves;
    license = licenses.unfreeRedistributable;
    platforms = platforms.linux;
    maintainers = with maintainers; [ a1russell robbinch roconnor the-kenny abbradar ];
  };
}