dwarf-fortress: 0.40.24 -> 0.42.05, split derivations

This is a massive rework of the current dwarf_fortress package.
The main reason for rework is to split game, its libraries and wrappers,
enabling builds on Hydra and general maintainability.

dfhack, dwarf-fortress-unfuck, dwarf-fortress-original and dwarf-fortress
are now all separate derivations. All were updated to the latest versions
supporting DF 0.42.04 (some things taken from development branches):

dfhack: 20150927 -> 20160118
dwarf-fortress-unfuck: 0.40.24 -> 20160118
dwarf-fortress-original: 0.40.24 -> 0.42.05

dfhack got a patch for using more system libraries.

Wrapper scripts were also redone -- now they support DF_DIR variable (for
setting another data directory) and try to save more space by means of
symlinking. They now try to be more smart, updating those directories that were
not touched by user automatically.

All the new packages now reside in dwarf-fortress-packages. dwarf_fortress was
renamed into dwarf-fortress per our conventions, old name is deprecated. Also
duplicate dfhack derivation is removed.

Also drop dwarfFortress.enableDFHack config option; it can be re-added later
but now is deemed controversial.
This commit is contained in:
Nikolay Amiantov 2016-01-12 20:56:59 +03:00
parent e409d0fed3
commit 92cda7a6bb
19 changed files with 409 additions and 366 deletions

View file

@ -1,62 +0,0 @@
{ stdenv, fetchgit, dwarf_fortress, cmake, zlib, perl, XMLLibXML, XMLLibXSLT
}:
let
baseVersion = "40";
patchVersion = "24-r3";
src = fetchgit {
url = "https://github.com/DFHack/dfhack.git";
rev = "0849099f2083e100cae6f64940b4eff4c28ce2eb";
sha256 = "0lnqrayi8hwfivkrxb7fw8lb6v95i04pskny1px7084n7nzvyv8b";
};
in
assert stdenv.system == "i686-linux";
assert dwarf_fortress.name == "dwarf-fortress-0.40.24";
stdenv.mkDerivation rec {
name = "dfhack-0.${baseVersion}.${patchVersion}";
inherit baseVersion patchVersion src;
buildInputs = [ cmake zlib perl XMLLibXML XMLLibXSLT ];
preConfigure = ''
export cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix/dfhack $cmakeFlags"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/build/depends/protobuf
'';
installPhase = ''
mkdir -p $out/dfhack
make install
cp ../package/linux/dfhack $out/dfhack/
mkdir -p $out/bin
cat > $out/bin/dfhack_install_dir <<EOF
#!/bin/sh
test -z "\$1" && echo "This creates a Dwarf Fortress/DFHack game directory. Please specify a directory (preferably empty or non-existent) for this." && exit 1
set -e
mkdir -p "\$1"
cd "\$1"
cp -r ${dwarf_fortress}/share/df_linux/* .
cp -r $out/dfhack/* .
chmod -R u+w .
# use LD_LIBRARY_PATH setting from dwarf-fortress wrapper
sed -e 's%# Now run%`grep LD_LIBRARY_PATH ${dwarf_fortress}/bin/dwarf-fortress`%' $out/dfhack/dfhack > dfhack
# write md5sum of binary
sed -e s/c42f55948a448645d6609102ef6439e8/`md5sum ${dwarf_fortress}/share/df_linux/libs/Dwarf_Fortress | cut -f1 -d\ `/ $out/dfhack/hack/symbols.xml > hack/symbols.xml
echo "DFHack installed successfully in \$1. To play, run ./dfhack in it."
EOF
chmod +x $out/bin/dfhack_install_dir
'';
meta = {
description = "A Dwarf Fortress memory access library";
homepage = https://github.com/DFHack/dfhack;
license = stdenv.lib.licenses.bsd2;
maintainers = with stdenv.lib.maintainers; [ robbinch ];
};
}

View file

@ -1,217 +1,19 @@
{ stdenv, fetchgit, fetchurl, cmake, glew, ncurses
, SDL, SDL_image, SDL_ttf, gtk2, glib
, mesa, openal, pango, atk, gdk_pixbuf, glibc, libsndfile
# begin dfhack-only parameters
, XMLLibXML
, XMLLibXSLT
, perl
, zlib
# end dfhack-only parameters
, enableDFHack ? false
}:
{ pkgs, pkgsi686Linux }:
let
baseVersion = "40";
patchVersion = "24";
srcs = {
df_unfuck = fetchgit {
url = "https://github.com/svenstaro/dwarf_fortress_unfuck";
rev = "39742d64d2886fb594d79e7cc4b98fb917f26811";
sha256 = "19vwx6kpv1sf93bx5v8x47f7x2cgxsqk82v6j1a72sa3q7m5cpc7";
callPackage = pkgs.newScope self;
callPackage_i686 = pkgsi686Linux.newScope self;
self = {
dwarf-fortress-original = callPackage_i686 ./game.nix { };
dfhack = callPackage_i686 ./dfhack {
inherit (pkgsi686Linux.perlPackages) XMLLibXML XMLLibXSLT;
};
dfhack = fetchgit {
url = "https://github.com/DFHack/dfhack.git";
rev = "0849099f2083e100cae6f64940b4eff4c28ce2eb";
sha256 = "0lnqrayi8hwfivkrxb7fw8lb6v95i04pskny1px7084n7nzvyv8b";
};
dwarf-fortress-unfuck = callPackage_i686 ./unfuck.nix { };
df = fetchurl {
url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_linux.tar.bz2";
sha256 = "0d4jrs45qj89vq9mjg7fxxhis7zivvb0vzjpmkk274b778kccdys";
};
dwarf-fortress = callPackage ./wrapper { };
};
dfHackWorksWithCurrentVersion = true;
dfHackEnabled = dfHackWorksWithCurrentVersion && enableDFHack;
in
assert stdenv.system == "i686-linux";
stdenv.mkDerivation rec {
name = "dwarf-fortress-0.${baseVersion}.${patchVersion}";
inherit baseVersion patchVersion;
buildInputs = [
SDL
SDL_image
SDL_ttf
gtk2
glib
glew
mesa
ncurses
openal
glibc
libsndfile
pango
atk
cmake
gdk_pixbuf
XMLLibXML
XMLLibXSLT
perl
zlib
];
src = "${srcs.df_unfuck} ${srcs.df}" + stdenv.lib.optionalString dfHackEnabled " ${srcs.dfhack}";
sourceRoot = srcs.df_unfuck.name;
dfHackSourceRoot = srcs.dfhack.name;
cmakeFlags = [
"-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib}/lib/glib-2.0/include"
"-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2}/lib/gtk-2.0/include"
];
permission = ./df_permission;
dfHackTemplate = ./dwarf-fortress-hacked.in;
dfHackRunTemplate = ./dfhack-run.in;
dwarfFortressTemplate = ./dwarf-fortress.in;
installDfDataToHome = ./install-df-data-to-home.sh;
installDfhackDataToHome = ./install-dfhack-data-to-home.sh;
installDfDataContentToHome = ./install-df-data-content-to-home.sh;
exportLibsTemplate = ./export-libs.sh.in;
exportWorkaround = ./export-workaround.sh;
postUnpack = stdenv.lib.optionalString dfHackEnabled ''
if [ "$dontMakeSourcesWritable" != 1 ]; then
chmod -R u+w "$dfHackSourceRoot"
fi
'';
preConfigure = stdenv.lib.optionalString dfHackEnabled ''
export cmakeFlags="-DCMAKE_INSTALL_PREFIX=$out/share/df_linux $cmakeFlags"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/build/depends/protobuf
'';
postConfigure = stdenv.lib.optionalString dfHackEnabled ''
if [ -z "$originalSourceRoot" ]; then
originalSourceRoot=$sourceRoot
export sourceRoot=$dfHackSourceRoot
pushd ../../$sourceRoot
eval "''${configurePhase:-configurePhase}"
popd
export sourceRoot=$originalSourceRoot
unset originalSourceRoot
fi
'';
installPhase = ''
set -x
mkdir -p $out/bin
mkdir -p $out/share/df_linux
pushd ../../
cp -r ./df_linux/* $out/share/df_linux
rm $out/share/df_linux/libs/lib*
# Store the original hash
orig_hash=$(md5sum $out/share/df_linux/libs/Dwarf_Fortress | awk '{ print $1 }')
echo $orig_hash | cut -c1-8 > $out/share/df_linux/hash.md5.orig # for dwarf-therapist
echo $orig_hash > $out/share/df_linux/full-hash-orig.md5 # for dfhack
cp -f ./${srcs.df_unfuck.name}/build/libgraphics.so $out/share/df_linux/libs/libgraphics.so
cp $permission $out/share/df_linux/nix_permission
# Placeholder files for hashes of patched binary
touch $out/share/df_linux/hash.md5.patched
touch $out/share/df_linux/full-hash-patched.md5
mkdir -p $out/share/df_linux/shell
cp $installDfDataToHome $out/share/df_linux/shell/install-df-data-to-home.sh
cp $installDfhackDataToHome $out/share/df_linux/shell/install-dfhack-data-to-home.sh
cp $installDfDataContentToHome $out/share/df_linux/shell/install-df-data-content-to-home.sh
cp $exportWorkaround $out/share/df_linux/shell/export-workaround.sh
substitute $exportLibsTemplate $out/share/df_linux/shell/export-libs.sh \
--subst-var-by stdenv_cc ${stdenv.cc} \
--subst-var-by SDL ${SDL} \
--subst-var-by SDL_image ${SDL_image} \
--subst-var-by SDL_ttf ${SDL_ttf} \
--subst-var-by gtk2 ${gtk2} \
--subst-var-by glib ${glib} \
--subst-var-by libsndfile ${libsndfile} \
--subst-var-by mesa ${mesa} \
--subst-var-by openal ${openal} \
--subst-var-by zlib ${zlib} \
substitute $dwarfFortressTemplate $out/bin/dwarf-fortress \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var prefix
chmod 755 $out/bin/dwarf-fortress
popd
'' + stdenv.lib.optionalString dfHackEnabled ''
originalSourceRoot=$sourceRoot
export sourceRoot=$dfHackSourceRoot
pushd ../../$sourceRoot/build
mkdir -p $out/dfhack
make install
cp ../package/linux/dfhack $out/dfhack/
mkdir -p $out/bin
substitute $dfHackTemplate $out/bin/dfhack \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var prefix
chmod 755 $out/bin/dfhack
substitute $dfHackRunTemplate $out/bin/dfhack-run \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var prefix
chmod 755 $out/bin/dfhack-run
popd
export sourceRoot=$originalSourceRoot
unset originalSourceRoot
'';
fixupPhase = ''
# Fix rpath
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ stdenv.cc.cc stdenv.glibc ]}:$out/share/df_linux/libs" $out/share/df_linux/libs/Dwarf_Fortress
patchelf --set-interpreter ${glibc}/lib/ld-linux.so.2 $out/share/df_linux/libs/Dwarf_Fortress
# Store new hash
patched_hash=$(md5sum $out/share/df_linux/libs/Dwarf_Fortress | awk '{ print $1 }')
echo $patched_hash | cut -c1-8 > $out/share/df_linux/hash.md5.patched # for dwarf-therapist
echo $patched_hash > $out/share/df_linux/full-hash-patched.md5 # for dfhack
'' + stdenv.lib.optionalString dfHackEnabled ''
find $out/share/df_linux/hack \( \
\( -type f -a -name "*.so*" \) -o \
\( -type f -a -perm +0100 \) \
\) -print -exec patchelf --shrink-rpath {} \;
sed -i "s/$(cat $out/share/df_linux/full-hash-orig.md5)/$(cat $out/share/df_linux/full-hash-patched.md5)/" $out/share/df_linux/hack/symbols.xml
'';
meta = {
description = "A single-player fantasy game with a randomly generated adventure world";
homepage = http://www.bay12games.com/dwarves;
license = stdenv.lib.licenses.unfreeRedistributable;
maintainers = with stdenv.lib.maintainers; [ a1russell robbinch roconnor the-kenny ];
};
}
in self

View file

@ -1,11 +0,0 @@
#!@stdenv_shell@
data_dir=${XDG_DATA_HOME:-$HOME/.local/share}/df_linux
pkg_dir=@prefix@/share/df_linux
. $pkg_dir/shell/install-df-data-to-home.sh
. $pkg_dir/shell/install-dfhack-data-to-home.sh
. $pkg_dir/shell/export-libs.sh
cd "$data_dir"
exec ./dfhack-run "$@"

View file

@ -0,0 +1,49 @@
{ stdenv, fetchgit, cmake, writeScriptBin
, perl, XMLLibXML, XMLLibXSLT
, zlib
, jsoncpp, protobuf, tinyxml
}:
let
rev = "f61ff9147e00f3c379ac0458e79eb556a5de1b68";
dfVersion = "0.42.05";
fakegit = writeScriptBin "git" ''
#! ${stdenv.shell}
if [ "$*" = "describe --tags --long" ]; then
echo "${dfVersion}-unknown"
elif [ "$*" = "rev-parse HEAD" ]; then
echo "${rev}"
else
exit 1
fi
'';
in stdenv.mkDerivation {
name = "dfhack-20160118";
# Beware of submodules
src = fetchgit {
url = "https://github.com/DFHack/dfhack";
inherit rev;
sha256 = "1ah3cplp4mb9pq7rm1cmn8klfjxw3y2xfzy7734i81b3iwiwlpi4";
};
patches = [ ./use-system-libraries.patch ];
nativeBuildInputs = [ cmake perl XMLLibXML XMLLibXSLT fakegit ];
# we can't use native Lua; upstream uses private headers
buildInputs = [ zlib jsoncpp protobuf tinyxml ];
enableParallelBuilding = true;
passthru = { inherit dfVersion; };
meta = with stdenv.lib; {
description = "Memory hacking library for Dwarf Fortress and a set of tools that use it";
homepage = https://github.com/DFHack/dfhack/;
license = licenses.zlib;
platforms = [ "i686-linux" ];
maintainers = with maintainers; [ robbinch a1russell abbradar ];
};
}

View file

@ -0,0 +1,138 @@
From 1196fcb987b6aadb49075d817b3615bf8a6d7d51 Mon Sep 17 00:00:00 2001
From: Nikolay Amiantov <ab@fmap.me>
Date: Wed, 6 Jan 2016 03:07:20 +0300
Subject: [PATCH 2/2] Use as much system libraries as possible
---
CMakeLists.txt | 5 -----
depends/CMakeLists.txt | 3 ---
library/CMakeLists.txt | 10 +++++-----
plugins/CMakeLists.txt | 4 ++--
plugins/mapexport/CMakeLists.txt | 4 ++--
plugins/stockpiles/CMakeLists.txt | 4 ++--
6 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1933390..d871df4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -152,8 +152,6 @@ ELSEIF(MSVC)
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od")
ENDIF()
-# use shared libraries for protobuf
-ADD_DEFINITIONS(-DPROTOBUF_USE_DLLS)
ADD_DEFINITIONS(-DLUA_BUILD_AS_DLL)
if(APPLE)
@@ -173,11 +171,8 @@ if(NOT UNIX)
endif()
set(ZLIB_ROOT /usr/lib/i386-linux-gnu)
find_package(ZLIB REQUIRED)
-include_directories(depends/protobuf)
include_directories(depends/lua/include)
include_directories(depends/md5)
-include_directories(depends/jsoncpp)
-include_directories(depends/tinyxml)
include_directories(depends/tthread)
include_directories(${ZLIB_INCLUDE_DIRS})
include_directories(depends/clsocket/src)
diff --git a/depends/CMakeLists.txt b/depends/CMakeLists.txt
index bf0345b..2a1a852 100644
--- a/depends/CMakeLists.txt
+++ b/depends/CMakeLists.txt
@@ -1,10 +1,7 @@
#list depends here.
add_subdirectory(lua)
add_subdirectory(md5)
-add_subdirectory(protobuf)
-add_subdirectory(tinyxml)
add_subdirectory(tthread)
-add_subdirectory(jsoncpp)
# build clsocket static and only as a dependency. Setting those options here overrides its own default settings.
OPTION(CLSOCKET_SHARED "Build clsocket lib as shared." OFF)
OPTION(CLSOCKET_DEP_ONLY "Build for use inside other CMake projects as dependency." ON)
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 5071d9e..d346d1e 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -203,10 +203,10 @@ LIST(APPEND PROJECT_SOURCES ${PROJECT_PROTO_SRCS})
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
- COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
+ COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
--cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/
${PROJECT_PROTOS}
- DEPENDS protoc-bin ${PROJECT_PROTOS}
+ DEPENDS ${PROJECT_PROTOS}
)
# Merge headers into sources
@@ -249,12 +249,12 @@ IF(UNIX)
ENDIF()
IF(APPLE)
- SET(PROJECT_LIBS dl dfhack-md5 dfhack-tinyxml dfhack-tinythread)
+ SET(PROJECT_LIBS dl dfhack-md5 tinyxml dfhack-tinythread)
ELSEIF(UNIX)
- SET(PROJECT_LIBS rt dl dfhack-md5 dfhack-tinyxml dfhack-tinythread)
+ SET(PROJECT_LIBS rt dl dfhack-md5 tinyxml dfhack-tinythread)
ELSE(WIN32)
#FIXME: do we really need psapi?
- SET(PROJECT_LIBS psapi dfhack-md5 dfhack-tinyxml dfhack-tinythread)
+ SET(PROJECT_LIBS psapi dfhack-md5 tinyxml dfhack-tinythread)
ENDIF()
ADD_LIBRARY(dfhack-version STATIC DFHackVersion.cpp)
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 9781401..ece508c 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -69,11 +69,11 @@ STRING(REPLACE ".proto" ".pb.h" PROJECT_PROTO_HDRS "${PROJECT_PROTOS}")
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
- COMMAND protoc-bin -I=${dfhack_SOURCE_DIR}/library/proto/
+ COMMAND protoc -I=${dfhack_SOURCE_DIR}/library/proto/
-I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
--cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/
${PROJECT_PROTOS}
- DEPENDS protoc-bin ${PROJECT_PROTOS}
+ DEPENDS ${PROJECT_PROTOS}
)
add_custom_target(generate_proto DEPENDS ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS})
diff --git a/plugins/mapexport/CMakeLists.txt b/plugins/mapexport/CMakeLists.txt
index 429507a..7e2390a 100644
--- a/plugins/mapexport/CMakeLists.txt
+++ b/plugins/mapexport/CMakeLists.txt
@@ -32,8 +32,8 @@ LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
#Generate sources from our proto files and store them in the source tree
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
-COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
-DEPENDS protoc-bin ${PROJECT_PROTOS}
+COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
+DEPENDS ${PROJECT_PROTOS}
)
IF(WIN32)
diff --git a/plugins/stockpiles/CMakeLists.txt b/plugins/stockpiles/CMakeLists.txt
index 713c3d6..dd2d4cb 100644
--- a/plugins/stockpiles/CMakeLists.txt
+++ b/plugins/stockpiles/CMakeLists.txt
@@ -33,8 +33,8 @@ LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
#Generate sources from our proto files and store them in the source tree
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
-COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
-DEPENDS protoc-bin ${PROJECT_PROTOS}
+COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
+DEPENDS ${PROJECT_PROTOS}
)
IF(WIN32)
--
2.6.3

View file

@ -1,13 +0,0 @@
#!@stdenv_shell@
data_dir=${XDG_DATA_HOME:-$HOME/.local/share}/df_linux
pkg_dir=@prefix@/share/df_linux
. $pkg_dir/shell/install-df-data-to-home.sh
. $pkg_dir/shell/install-dfhack-data-to-home.sh
. $pkg_dir/shell/install-df-data-content-to-home.sh
. $pkg_dir/shell/export-libs.sh
. $pkg_dir/shell/export-workaround.sh
cd "$data_dir"
exec ./dfhack "$@"

View file

@ -1,14 +0,0 @@
#!@stdenv_shell@
set -ex
data_dir=${XDG_DATA_HOME:-$HOME/.local/share}/df_linux
pkg_dir=@prefix@/share/df_linux
. $pkg_dir/shell/install-df-data-to-home.sh
. $pkg_dir/shell/install-df-data-content-to-home.sh
. $pkg_dir/shell/export-libs.sh
. $pkg_dir/shell/export-workaround.sh
cd $data_dir
$pkg_dir/libs/Dwarf_Fortress "$@"

View file

@ -1,12 +0,0 @@
export LD_LIBRARY_PATH=\
@stdenv_cc@/lib:\
@SDL@/lib:\
@SDL_image@/lib/:\
@SDL_ttf@/lib/:\
@gtk2@/lib/:\
@glib@/lib/:\
@mesa@/lib/:\
@openal@/lib/:\
@libsndfile@/lib:\
@zlib@/lib:\
$data_dir/df_linux/libs/

View file

@ -1 +0,0 @@
export SDL_DISABLE_LOCK_KEYS=1 # Work around for bug in Debian/Ubuntu SDL patch.

View file

@ -0,0 +1,52 @@
{ stdenv, lib, fetchurl
, SDL, dwarf-fortress-unfuck
}:
let
baseVersion = "42";
patchVersion = "05";
dfVersion = "0.${baseVersion}.${patchVersion}";
libpath = lib.makeLibraryPath [ stdenv.cc.cc stdenv.glibc dwarf-fortress-unfuck SDL ];
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}_linux.tar.bz2";
sha256 = "0g7r0v2lsqj9ryxh12q8yrk96bgs00rf2ncw228cwwqgmps3xcws";
};
installPhase = ''
mkdir -p $out
cp -r * $out
rm $out/libs/lib*
# Store the original hash
orig_hash=$(md5sum $out/libs/Dwarf_Fortress | awk '{ print $1 }')
echo $orig_hash | cut -c1-8 > $out/hash.md5.orig # for dwarf-therapist
echo $orig_hash > $out/full-hash-orig.md5 # for dfhack
patchelf \
--set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
--set-rpath "${libpath}" \
$out/libs/Dwarf_Fortress
# Store new hash
patched_hash=$(md5sum $out/libs/Dwarf_Fortress | awk '{ print $1 }')
echo $patched_hash | cut -c1-8 > $out/hash.md5.patched # for dwarf-therapist
echo $patched_hash > $out/full-hash-patched.md5 # for dfhack
'';
passthru = { inherit baseVersion patchVersion dfVersion; };
meta = {
description = "A single-player fantasy game with a randomly generated adventure world";
homepage = http://www.bay12games.com/dwarves;
license = lib.licenses.unfreeRedistributable;
maintainers = with lib.maintainers; [ a1russell robbinch roconnor the-kenny abbradar ];
};
}

View file

@ -1,4 +0,0 @@
for link in announcement art dipscript help index initial_movies movies shader.fs shader.vs sound speech; do
cp -r $pkg_dir/data/$link "$data_dir/data/$link"
chmod -R u+rw "$data_dir/data/$link"
done

View file

@ -1,12 +0,0 @@
mkdir -p $data_dir
if [[ $(readlink $data_dir/raw) != "$pkg_dir/raw" ]]; then
rm -f $data_dir/raw
ln -s $pkg_dir/raw $data_dir/raw
fi
if [[ $(readlink $data_dir/libs) != "$pkg_dir/libs" ]]; then
rm -f $data_dir/libs
ln -s $pkg_dir/libs $data_dir/libs
fi
mkdir -p "$data_dir/data"
cp -rn $pkg_dir/data/init $data_dir/data/init
chmod -R u+rw $data_dir/data/init

View file

@ -1,16 +0,0 @@
if [[ $(readlink $data_dir/hack) != "$pkg_dir/hack" ]]; then
rm -f $data_dir/hack
ln -s $pkg_dir/hack $data_dir/hack
fi
if [[ $(readlink $data_dir/dfhack) != "$pkg_dir/dfhack" ]]; then
rm -f $data_dir/dfhack
ln -s $pkg_dir/dfhack $data_dir/dfhack
fi
if [[ $(readlink $data_dir/dfhack.init-example) != "$pkg_dir/dfhack.init-example" ]]; then
rm -f $data_dir/dfhack.init-example
ln -s $pkg_dir/dfhack.init-example $data_dir/dfhack.init-example
fi
if [[ $(readlink $data_dir/dfhack-run) != "$pkg_dir/dfhack-run" ]]; then
rm -f $data_dir/dfhack-run
ln -s $pkg_dir/dfhack-run $data_dir/dfhack-run
fi

View file

@ -0,0 +1,41 @@
{ stdenv, fetchgit, cmake
, mesa, SDL, SDL_image, SDL_ttf, glew, openalSoft
, ncurses, glib, gtk2, libsndfile
}:
stdenv.mkDerivation {
name = "dwarf_fortress_unfuck-20160118";
src = fetchgit {
url = "https://github.com/svenstaro/dwarf_fortress_unfuck";
rev = "9a796c6d3cd7d41784e9d1d22a837a1ee0ff8553";
sha256 = "0ibxdn684zpk3v2gigardq6z9mydc2s9hns8hlxjyyyhnk1ar61g";
};
cmakeFlags = [
"-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib}/lib/glib-2.0/include"
"-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2}/lib/gtk-2.0/include"
];
nativeBuildInputs = [ cmake ];
buildInputs = [
mesa SDL SDL_image SDL_ttf glew openalSoft
ncurses gtk2 libsndfile
];
installPhase = ''
install -D -m755 ../build/libgraphics.so $out/lib/libgraphics.so
'';
enableParallelBuilding = true;
passthru.dfVersion = "0.42.05";
meta = with stdenv.lib; {
description = "Unfucked multimedia layer for Dwarf Fortress";
homepage = https://github.com/svenstaro/dwarf_fortress_unfuck;
license = licenses.free;
platforms = [ "i686-linux" ];
maintainers = with maintainers; [ abbradar ];
};
}

View file

@ -0,0 +1,47 @@
{ stdenv, lib, dwarf-fortress-original, substituteAll
, enableDFHack ? false, dfhack
}:
assert enableDFHack -> (dfhack.dfVersion == dwarf-fortress-original.dfVersion);
stdenv.mkDerivation rec {
name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}";
runDF = ./dwarf-fortress.in;
runDFHack = ./dfhack.in;
dfInit = substituteAll {
name = "dwarf-fortress-init";
src = ./dwarf-fortress-init.in;
dwarfFortress = dwarf-fortress-original;
};
inherit dfhack;
df = dwarf-fortress-original;
buildCommand = ''
mkdir -p $out/bin
substitute $runDF $out/bin/dwarf-fortress \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var dfInit
chmod 755 $out/bin/dwarf-fortress
'' + lib.optionalString enableDFHack ''
mkdir -p $out/hack
substitute $dfhack/hack/symbols.xml $out/hack/symbols.xml \
--replace $(cat $df/full-hash-orig.md5) $(cat $df/full-hash-patched.md5)
substitute $runDFHack $out/bin/dfhack \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var dfInit \
--subst-var dfhack \
--subst-var-by dfhackWrapper $out
chmod 755 $out/bin/dfhack
'';
preferLocalBuild = true;
meta = {
description = "A single-player fantasy game with a randomly generated adventure world";
homepage = http://www.bay12games.com/dwarves;
maintainers = with lib.maintainers; [ a1russell robbinch roconnor the-kenny ];
};
}

View file

@ -0,0 +1,17 @@
#!@stdenv_shell@ -e
hack_dir="@dfhack@"
hack_wrap_dir="@dfhackWrapper@"
source @dfInit@
cd "$hack_dir"
for i in dfhack.init-example dfhack-config/default hack/!(symbols.xml|*.so|dfhack-run|binpatch); do
update_path "$hack_dir" "$i"
done
update_path "$hack_wrap_dir" "hack/symbols.xml"
cd "$DF_DIR"
LD_LIBRARY_PATH="$hack_dir/hack/libs:$hack_dir/hack:$LD_LIBRARY_PATH" \
LD_PRELOAD=$hack_dir/hack/libdfhack.so exec $game_dir/libs/Dwarf_Fortress "$@"

View file

@ -0,0 +1,43 @@
shopt -s extglob
[ -z "$DF_DIR" ] && DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
game_dir="@dwarfFortress@"
update_path() {
local pkg_dir="$1"
local path="$2"
mkdir -p "$DF_DIR/$(dirname "$path")"
# If user has replaced these data directories, let them stay.
if [ ! -e "$DF_DIR/$path" ] || [ -L "$DF_DIR/$path" ]; then
rm -f "$DF_DIR/$path"
ln -s "$pkg_dir/$path" "$DF_DIR/$path"
fi
}
forcecopy_path() {
local pkg_dir="$1"
local path="$2"
mkdir -p "$DF_DIR/$(dirname "$path")"
rm -rf "$DF_DIR/$path"
cp -rL --no-preserve=all "$pkg_dir/$path" "$DF_DIR/$path"
}
mkdir -p "$DF_DIR"
cat <<EOF >&2
Using $DF_DIR as Dwarf Fortress overlay directory.
If you do any changes in it, don't forget to clean it when updating the game version!
We try to detect changes based on data directories being symbolic links -- keep this in mind.
EOF
cd "$game_dir"
for i in data/init/* data/!(init|index|announcement) raw; do
update_path "$game_dir" "$i"
done
forcecopy_path "$game_dir" data/index
# For some reason, it's needed to be writable...
forcecopy_path "$game_dir" data/announcement

View file

@ -0,0 +1,6 @@
#!@stdenv_shell@ -e
source @dfInit@
cd "$DF_DIR"
exec $game_dir/libs/Dwarf_Fortress "$@"

View file

@ -14104,21 +14104,13 @@ let
cuyo = callPackage ../games/cuyo { };
dfhack = callPackage_i686 ../games/dfhack {
inherit (pkgsi686Linux.perlPackages) XMLLibXML XMLLibXSLT;
};
dhewm3 = callPackage ../games/dhewm3 {};
drumkv1 = callPackage ../applications/audio/drumkv1 { };
dwarf_fortress = callPackage_i686 ../games/dwarf-fortress {
SDL_image = pkgsi686Linux.SDL_image.override {
libpng = pkgsi686Linux.libpng12;
};
inherit (pkgsi686Linux.perlPackages) XMLLibXML XMLLibXSLT;
enableDFHack = config.dwarfFortress.enableDFHack or false;
};
dwarf-fortress-packages = callPackage ../games/dwarf-fortress { };
dwarf-fortress = dwarf-fortress-packages.dwarf-fortress.override { };
dwarf-therapist = callPackage ../games/dwarf-therapist { };
@ -15956,6 +15948,7 @@ aliases = with self; rec {
aircrackng = aircrack-ng; # added 2016-01-14
quake3game = ioquake3; # added 2016-01-14
scim = sc-im; # added 2016-01-22
dwarf_fortress = dwarf-fortress; # added 2016-01-23
};
tweakAlias = _n: alias: with lib;