2016-01-12 17:56:59 +00:00
|
|
|
{ stdenv, lib, fetchurl
|
|
|
|
, SDL, dwarf-fortress-unfuck
|
2018-05-11 05:55:06 +01:00
|
|
|
|
|
|
|
# Our own "unfuck" libs for macOS
|
|
|
|
, ncurses, fmodex, gcc
|
2018-07-05 22:21:24 +01:00
|
|
|
|
2018-07-08 20:44:29 +01:00
|
|
|
, dfVersion, df-hashes
|
2016-01-12 17:56:59 +00:00
|
|
|
}:
|
|
|
|
|
2018-07-08 20:44:29 +01:00
|
|
|
with lib;
|
2018-05-11 05:55:06 +01:00
|
|
|
|
2016-01-12 17:56:59 +00:00
|
|
|
let
|
2018-05-11 05:55:06 +01:00
|
|
|
libpath = makeLibraryPath [ stdenv.cc.cc stdenv.cc.libc dwarf-fortress-unfuck SDL ];
|
|
|
|
|
|
|
|
homepage = http://www.bay12games.com/dwarves/;
|
|
|
|
|
2018-07-05 22:21:24 +01:00
|
|
|
# Map Dwarf Fortress platform names to Nixpkgs platform names.
|
2018-05-11 05:55:06 +01:00
|
|
|
# Other srcs are avilable like 32-bit mac & win, but I have only
|
|
|
|
# included the ones most likely to be needed by Nixpkgs users.
|
2018-07-05 22:21:24 +01:00
|
|
|
platforms = {
|
2019-08-13 22:52:01 +01:00
|
|
|
x86_64-linux = "linux";
|
|
|
|
i686-linux = "linux32";
|
|
|
|
x86_64-darwin = "osx";
|
|
|
|
i686-darwin = "osx32";
|
|
|
|
x86_64-cygwin = "win";
|
|
|
|
i686-cygwin = "win32";
|
2018-05-11 05:55:06 +01:00
|
|
|
};
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2019-09-24 10:24:13 +01:00
|
|
|
dfVersionTriple = splitVersion dfVersion;
|
2018-07-05 22:21:24 +01:00
|
|
|
baseVersion = elemAt dfVersionTriple 1;
|
|
|
|
patchVersion = elemAt dfVersionTriple 2;
|
|
|
|
|
2018-07-08 20:44:29 +01:00
|
|
|
game = if hasAttr dfVersion df-hashes
|
|
|
|
then getAttr dfVersion df-hashes
|
2018-07-05 22:21:24 +01:00
|
|
|
else throw "Unknown Dwarf Fortress version: ${dfVersion}";
|
2018-08-20 20:11:29 +01:00
|
|
|
dfPlatform = if hasAttr stdenv.hostPlatform.system platforms
|
|
|
|
then getAttr stdenv.hostPlatform.system platforms
|
|
|
|
else throw "Unsupported system: ${stdenv.hostPlatform.system}";
|
2018-07-05 22:21:24 +01:00
|
|
|
sha256 = if hasAttr dfPlatform game
|
|
|
|
then getAttr dfPlatform game
|
|
|
|
else throw "Unsupported dfPlatform: ${dfPlatform}";
|
|
|
|
|
2016-01-12 17:56:59 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2018-07-08 20:44:29 +01:00
|
|
|
name = "dwarf-fortress-${dfVersion}";
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-07-05 22:21:24 +01:00
|
|
|
src = fetchurl {
|
|
|
|
url = "${homepage}df_${baseVersion}_${patchVersion}_${dfPlatform}.tar.bz2";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
2016-01-12 17:56:59 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r * $out
|
|
|
|
rm $out/libs/lib*
|
|
|
|
|
2018-05-11 05:55:06 +01:00
|
|
|
exe=$out/${if stdenv.isLinux then "libs/Dwarf_Fortress"
|
|
|
|
else "dwarfort.exe"}
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-05-11 05:55:06 +01:00
|
|
|
# Store the original hash
|
|
|
|
md5sum $exe | awk '{ print $1 }' > $out/hash.md5.orig
|
|
|
|
'' + optionalString stdenv.isLinux ''
|
2016-01-12 17:56:59 +00:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
|
|
|
|
--set-rpath "${libpath}" \
|
2018-05-11 05:55:06 +01:00
|
|
|
$exe
|
|
|
|
'' + optionalString stdenv.isDarwin ''
|
|
|
|
# My custom unfucked dwarfort.exe for macOS. Can't use
|
|
|
|
# absolute paths because original doesn't have enough
|
|
|
|
# header space. Someone plz break into Tarn's house & put
|
|
|
|
# -headerpad_max_install_names into his LDFLAGS.
|
|
|
|
|
|
|
|
ln -s ${getLib ncurses}/lib/libncurses.dylib $out/libs
|
|
|
|
ln -s ${getLib gcc.cc}/lib/libstdc++.6.dylib $out/libs
|
|
|
|
ln -s ${getLib fmodex}/lib/libfmodex.dylib $out/libs
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-05-11 05:55:06 +01:00
|
|
|
install_name_tool \
|
|
|
|
-change /usr/lib/libncurses.5.4.dylib \
|
|
|
|
@executable_path/libs/libncurses.dylib \
|
|
|
|
-change /usr/local/lib/x86_64/libstdc++.6.dylib \
|
|
|
|
@executable_path/libs/libstdc++.6.dylib \
|
|
|
|
$exe
|
|
|
|
'' + ''
|
2016-01-23 20:57:58 +00:00
|
|
|
# Store the new hash
|
2018-05-11 05:55:06 +01:00
|
|
|
md5sum $exe | awk '{ print $1 }' > $out/hash.md5
|
2016-01-12 17:56:59 +00:00
|
|
|
'';
|
|
|
|
|
2018-07-05 22:21:24 +01:00
|
|
|
passthru = {
|
|
|
|
inherit baseVersion patchVersion dfVersion;
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-05-11 05:55:06 +01:00
|
|
|
meta = {
|
2016-01-12 17:56:59 +00:00
|
|
|
description = "A single-player fantasy game with a randomly generated adventure world";
|
2018-05-11 05:55:06 +01:00
|
|
|
inherit homepage;
|
2016-08-13 01:10:46 +01:00
|
|
|
license = licenses.unfreeRedistributable;
|
2018-07-05 22:21:24 +01:00
|
|
|
platforms = attrNames platforms;
|
2018-06-25 09:21:57 +01:00
|
|
|
maintainers = with maintainers; [ a1russell robbinch roconnor the-kenny abbradar numinit ];
|
2016-01-12 17:56:59 +00:00
|
|
|
};
|
|
|
|
}
|