Merge pull request #12339 from abbradar/df-new

Dwarf Fortress updates
This commit is contained in:
Nikolay Amiantov 2016-01-26 03:07:54 +03:00
commit fc51e4f7dc
23 changed files with 547 additions and 413 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,33 @@
{ 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 = rec {
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 { };
dwarf-fortress = callPackage ./wrapper {
themes = {
"phoebus" = phoebus-theme;
};
};
df = fetchurl {
url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_linux.tar.bz2";
sha256 = "0d4jrs45qj89vq9mjg7fxxhis7zivvb0vzjpmkk274b778kccdys";
dwarf-therapist-original = callPackage ./dwarf-therapist {
texlive = pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-basic float caption wrapfig adjmulticol sidecap preprint enumitem;
};
};
dwarf-therapist = callPackage ./dwarf-therapist/wrapper.nix { };
phoebus-theme = callPackage ./themes/phoebus.nix { };
};
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

@ -0,0 +1,40 @@
{ stdenv, fetchFromGitHub, coreutils, qt4, texlive }:
let
version = "36.0.0";
in
stdenv.mkDerivation {
name = "dwarf-therapist-original-${version}";
src = fetchFromGitHub {
owner = "splintermind";
repo = "Dwarf-Therapist";
rev = "v${version}";
sha256 = "08xjawb25sibkkfqwd4mlq73dgmgc6lxbbd673rx7yhrsjh4z4h3";
};
outputs = [ "out" "layouts" ];
buildInputs = [ qt4 ];
nativeBuildInputs = [ texlive ];
enableParallelBuilding = false;
configurePhase = ''
qmake PREFIX=$out
'';
# Move layout files so they cannot be found by Therapist
postInstall = ''
mkdir -p $layouts
mv $out/share/dwarftherapist/memory_layouts/* $layouts
rmdir $out/share/dwarftherapist/memory_layouts
'';
meta = {
description = "Tool to manage dwarves in in a running game of Dwarf Fortress";
maintainers = with stdenv.lib.maintainers; [ the-kenny abbradar ];
license = stdenv.lib.licenses.mit;
platforms = stdenv.lib.platforms.linux;
homepage = https://code.google.com/r/splintermind-attributes/;
};
}

View File

@ -0,0 +1,43 @@
{ buildEnv, lib, dwarf-therapist-original, dwarf-fortress-original, makeWrapper }:
let
df = dwarf-fortress-original;
dt = dwarf-therapist-original;
inifile = "linux/v0${df.baseVersion}.${df.patchVersion}.ini";
dfHashFile = "${df}/hash.md5";
in buildEnv {
name = "dwarf-therapist-${lib.getVersion dt}";
paths = [ dt ];
buildInputs = [ makeWrapper ];
postBuild = ''
# DwarfTherapist assumes it's run in $out/share/dwarftherapist and
# therefore uses many relative paths.
rm $out/bin
mkdir $out/bin
makeWrapper ${dt}/bin/DwarfTherapist $out/bin/DwarfTherapist \
--run "cd $out/share/dwarftherapist"
# Fix checksum of memory access directives. We really need #4621 fixed!
recreate_dir() {
rm "$out/$1"
mkdir -p "$out/$1"
for i in "${dt}/$1/"*; do
ln -s "$i" "$out/$1"
done
}
recreate_dir share
recreate_dir share/dwarftherapist
mkdir -p $out/share/dwarftherapist/memory_layouts/linux
origmd5=$(cat "${dfHashFile}.orig" | cut -c1-8)
patchedmd5=$(cat "${dfHashFile}" | cut -c1-8)
substitute \
${dt.layouts}/${inifile} \
$out/share/dwarftherapist/memory_layouts/${inifile} \
--replace "$origmd5" "$patchedmd5"
'';
}

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,48 @@
{ 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
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 = {
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,33 @@
{ stdenv, fetchFromGitHub }:
# On upgrade check https://github.com/fricy/Phoebus/blob/master/manifest.json
# for compatibility information.
stdenv.mkDerivation {
name = "phoebus-theme-20160118";
src = fetchFromGitHub {
owner = "fricy";
repo = "Phoebus";
rev = "2c5777b0f307b1d752a8a484c6a05b67531c84a9";
sha256 = "0a5ixm181wz7crr3rpa2mh0drb371j5hvizqninvdnhah2mypz8v";
};
installPhase = ''
mkdir $out
cp -r data raw $out
'';
passthru.dfVersion = "0.42.05";
preferLocalBuild = true;
meta = with stdenv.lib; {
description = "Phoebus graphics set for Dwarf Fortress";
homepage = "http://www.bay12forums.com/smf/index.php?topic=137096.0";
platforms = platforms.all;
maintainers = with maintainers; [ a1russell abbradar ];
# https://github.com/fricy/Phoebus/issues/5
license = licenses.free;
};
}

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,68 @@
{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll
, enableDFHack ? false, dfhack
, themes ? {}
, theme ? null
}:
let
ptheme =
if builtins.isString theme
then builtins.getAttr theme themes
else theme;
# These are in inverse order for first packages to override the next ones.
pkgs = lib.optional (theme != null) ptheme
++ lib.optional enableDFHack dfhack
++ [ dwarf-fortress-original ];
env = buildEnv {
name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}";
paths = pkgs;
ignoreCollisions = true;
postBuild = lib.optionalString enableDFHack ''
# #4621
if [ -L "$out/hack" ]; then
rm $out/hack
mkdir $out/hack
for i in ${dfhack}/hack/*; do
ln -s $i $out/hack
done
fi
rm $out/hack/symbols.xml
substitute ${dfhack}/hack/symbols.xml $out/hack/symbols.xml \
--replace $(cat ${dwarf-fortress-original}/hash.md5.orig) \
$(cat ${dwarf-fortress-original}/hash.md5)
'';
};
in
assert lib.all (x: x.dfVersion == dwarf-fortress-original.dfVersion) pkgs;
stdenv.mkDerivation rec {
name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}";
dfInit = substituteAll {
name = "dwarf-fortress-init";
src = ./dwarf-fortress-init.in;
inherit env;
};
runDF = ./dwarf-fortress.in;
runDFHack = ./dfhack.in;
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 ''
substitute $runDFHack $out/bin/dfhack \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var dfInit
chmod 755 $out/bin/dfhack
'';
preferLocalBuild = true;
}

View File

@ -0,0 +1,11 @@
#!@stdenv_shell@ -e
source @dfInit@
for i in dfhack.init-example dfhack-config/default hack/*; do
update_path "$i"
done
cd "$DF_DIR"
LD_LIBRARY_PATH="$env_dir/hack/libs:$env_dir/hack:$LD_LIBRARY_PATH" \
LD_PRELOAD=$env_dir/hack/libdfhack.so exec $env_dir/libs/Dwarf_Fortress "$@"

View File

@ -0,0 +1,41 @@
shopt -s extglob
[ -z "$DF_DIR" ] && DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
env_dir="@env@"
update_path() {
local path="$1"
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 "$env_dir/$path" "$DF_DIR/$path"
fi
}
forcecopy_path() {
local path="$1"
mkdir -p "$DF_DIR/$(dirname "$path")"
rm -rf "$DF_DIR/$path"
cp -rL --no-preserve=all "$env_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 "$env_dir"
for i in data/init/* data/!(init|index|announcement) raw; do
update_path "$i"
done
forcecopy_path data/index
# For some reason, it's needed to be writable...
forcecopy_path data/announcement

View File

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

View File

@ -1,48 +0,0 @@
{ stdenv, coreutils, fetchgit, qt4, dwarf_fortress, bash, makeWrapper }:
let
version = "31.0.0";
df = dwarf_fortress;
in
stdenv.mkDerivation rec {
name = "dwarf-therapist-${version}";
src = fetchgit {
url = "https://github.com/splintermind/Dwarf-Therapist.git";
rev = "refs/tags/v${version}";
sha256 = "02d6k8c3vm401v04ln9q405njarx869jpfyf42lwskijrzjygk9x";
};
# Needed for hashing
dfHashFile = "${df}/share/df_linux/hash.md5";
buildInputs = [ coreutils qt4 df makeWrapper ];
enableParallelBuilding = false;
configurePhase = ''
qmake 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/;
};
}

View File

@ -14124,23 +14124,15 @@ 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-therapist = callPackage ../games/dwarf-therapist { };
dwarf-fortress = dwarf-fortress-packages.dwarf-fortress.override { };
dwarf-therapist = dwarf-fortress-packages.dwarf-therapist;
d1x_rebirth = callPackage ../games/d1x-rebirth { };
@ -15978,6 +15970,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;