git.iko.soy/typeable/nixpkgs
on master help sign in
dwarf-fortress: supports darwin
commit236b89afebaf55a09c7ec3bea6136871c4d03884 authorMatthew Bauer <mjbauer95@gmail.com> dateThu 10 May 2018, 23:55 (9 years ago) parentb45552c
5 files changed+69−25
pkgs/games/dwarf-fortress/default.nix+4−2 pkgs/games/dwarf-fortress/game.nix+58−22 pkgs/games/dwarf-fortress/wrapper/default.nix+2 pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in+1 pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in+4−1
pkgs/games/dwarf-fortress/default.nix+4−2
@@ -1,4 +1,4 @@
1−{ pkgs, pkgsi686Linux }:
1+{ pkgs, pkgsi686Linux, stdenv }:
22
33let
44 callPackage = pkgs.newScope self;
@@ -13,7 +13,9 @@ let
1313
1414 soundSense = callPackage ./soundsense.nix { };
1515
16− dwarf-fortress-unfuck = callPackage ./unfuck.nix { };
16+ # unfuck is linux-only right now, we will just use it there
17+ dwarf-fortress-unfuck = if stdenv.isLinux then callPackage ./unfuck.nix { }
18+ else null;
1719
1820 dwarf-fortress = callPackage ./wrapper {
1921 themes = {
pkgs/games/dwarf-fortress/game.nix+58−22
@@ -1,57 +1,93 @@
11{ stdenv, lib, fetchurl
22, SDL, dwarf-fortress-unfuck
3+
4+# Our own "unfuck" libs for macOS
5+, ncurses, fmodex, gcc
36}:
47
8+with lib;
9+
510let
611 baseVersion = "44";
7− patchVersion = "09";
12+ patchVersion = "10";
813 dfVersion = "0.${baseVersion}.${patchVersion}";
9− libpath = lib.makeLibraryPath [ stdenv.cc.cc stdenv.glibc dwarf-fortress-unfuck SDL ];
10− platform =
11− if stdenv.system == "x86_64-linux" then "linux"
12− else if stdenv.system == "i686-linux" then "linux32"
13− else throw "Unsupported platform";
14− sha256 =
15− if stdenv.system == "x86_64-linux" then "1haikynkg1pqyrzzqk1qxm19p36ww58qp8brh3fjxssp4x71rcdy"
16− else if stdenv.system == "i686-linux" then "0lmbrdf7wjdwj5yx0khnq871yxvhfwqxjjyfkqcdy5ik18lvlkj8"
17− else throw "Unsupported platform";
14+
15+ libpath = makeLibraryPath [ stdenv.cc.cc stdenv.cc.libc dwarf-fortress-unfuck SDL ];
16+
17+ homepage = http://www.bay12games.com/dwarves/;
18+
19+ # Other srcs are avilable like 32-bit mac & win, but I have only
20+ # included the ones most likely to be needed by Nixpkgs users.
21+ srcs = {
22+ "x86_64-linux" = fetchurl {
23+ url = "${homepage}df_${baseVersion}_${patchVersion}_linux.tar.bz2";
24+ sha256 = "1haikynkg1pqyrzzqk1qxm19p36ww58qp8brh3fjxssp4x71rcdy";
25+ };
26+ "i686-linux" = fetchurl {
27+ url = "${homepage}df_${baseVersion}_${patchVersion}_linux32.tar.bz2";
28+ sha256 = "0lmbrdf7wjdwj5yx0khnq871yxvhfwqxjjyfkqcdy5ik18lvlkj8";
29+ };
30+ "x86_64-darwin" = fetchurl {
31+ url = "${homepage}df_${baseVersion}_${patchVersion}_osx.tar.bz2";
32+ sha256 = "1wpa45d81q8f5mhqmaxvdkz93k6cm3pg7vpsqjjjsp5s961gd74g";
33+ };
34+ };
1835
1936in
2037
21−assert dwarf-fortress-unfuck.dfVersion == dfVersion;
38+assert dwarf-fortress-unfuck != null ->
39+ dwarf-fortress-unfuck.dfVersion == dfVersion;
2240
2341stdenv.mkDerivation {
2442 name = "dwarf-fortress-original-${dfVersion}";
2543
26− src = fetchurl {
27− url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_${platform}.tar.bz2";
28− inherit sha256;
29− };
44+ src = if builtins.hasAttr stdenv.system srcs
45+ then builtins.getAttr stdenv.system srcs
46+ else throw "Unsupported systems";
3047
3148 installPhase = ''
3249 mkdir -p $out
3350 cp -r * $out
3451 rm $out/libs/lib*
3552
36− # Store the original hash
37− md5sum $out/libs/Dwarf_Fortress | awk '{ print $1 }' > $out/hash.md5.orig
53+ exe=$out/${if stdenv.isLinux then "libs/Dwarf_Fortress"
54+ else "dwarfort.exe"}
3855
56+ # Store the original hash
57+ md5sum $exe | awk '{ print $1 }' > $out/hash.md5.orig
58+ '' + optionalString stdenv.isLinux ''
3959 patchelf \
4060 --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
4161 --set-rpath "${libpath}" \
42− $out/libs/Dwarf_Fortress
62+ $exe
63+ '' + optionalString stdenv.isDarwin ''
64+ # My custom unfucked dwarfort.exe for macOS. Can't use
65+ # absolute paths because original doesn't have enough
66+ # header space. Someone plz break into Tarn's house & put
67+ # -headerpad_max_install_names into his LDFLAGS.
68+
69+ ln -s ${getLib ncurses}/lib/libncurses.dylib $out/libs
70+ ln -s ${getLib gcc.cc}/lib/libstdc++.6.dylib $out/libs
71+ ln -s ${getLib fmodex}/lib/libfmodex.dylib $out/libs
4372
73+ install_name_tool \
74+ -change /usr/lib/libncurses.5.4.dylib \
75+ @executable_path/libs/libncurses.dylib \
76+ -change /usr/local/lib/x86_64/libstdc++.6.dylib \
77+ @executable_path/libs/libstdc++.6.dylib \
78+ $exe
79+ '' + ''
4480 # Store the new hash
45− md5sum $out/libs/Dwarf_Fortress | awk '{ print $1 }' > $out/hash.md5
81+ md5sum $exe | awk '{ print $1 }' > $out/hash.md5
4682 '';
4783
4884 passthru = { inherit baseVersion patchVersion dfVersion; };
4985
50− meta = with stdenv.lib; {
86+ meta = {
5187 description = "A single-player fantasy game with a randomly generated adventure world";
52− homepage = http://www.bay12games.com/dwarves;
88+ inherit homepage;
5389 license = licenses.unfreeRedistributable;
54− platforms = platforms.linux;
90+ platforms = attrNames srcs;
5591 maintainers = with maintainers; [ a1russell robbinch roconnor the-kenny abbradar ];
5692 };
5793}
pkgs/games/dwarf-fortress/wrapper/default.nix+2
@@ -47,6 +47,8 @@ stdenv.mkDerivation rec {
4747 name = "dwarf-fortress-init";
4848 src = ./dwarf-fortress-init.in;
4949 inherit env;
50+ exe = if stdenv.isLinux then "libs/Dwarf_Fortress"
51+ else "dwarfort.exe";
5052 };
5153
5254 runDF = ./dwarf-fortress.in;
pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in+1
@@ -2,6 +2,7 @@ shopt -s extglob
22
33[ -z "$DF_DIR" ] && DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
44env_dir="@env@"
5+exe="$env_dir/@exe@"
56
67update_path() {
78 local path="$1"
pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in+4−1
@@ -2,5 +2,8 @@
22
33source @dfInit@
44
5+export DYLD_LIBRARY_PATH="$env_dir/libs"
6+export DYLD_FRAMEWORK_PATH="$env_dir/libs"
7+
58cd "$DF_DIR"
6−exec "$env_dir/libs/Dwarf_Fortress" "$@"
9+exec "$exe" "$@"