From 85056ee698bdf85dc0db9ca0865dc2b0a2c16ed4 Mon Sep 17 00:00:00 2001 From: Herwig Hochleitner Date: Sun, 1 Oct 2017 21:26:51 +0200 Subject: [PATCH] dwarf-fortress-packages.dfhack: add stoneSense support --- pkgs/games/dwarf-fortress/default.nix | 1 + pkgs/games/dwarf-fortress/dfhack/default.nix | 14 ++++++----- .../dfhack/fix-stonesense.patch | 23 +++++++++++++++++++ .../dwarf-fortress/dfhack/skip-ruby.patch | 10 -------- pkgs/games/dwarf-fortress/stonesense.nix | 15 ++++++++++++ pkgs/games/dwarf-fortress/wrapper/default.nix | 9 ++++++-- pkgs/games/dwarf-fortress/wrapper/dfhack.in | 2 +- 7 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch delete mode 100644 pkgs/games/dwarf-fortress/dfhack/skip-ruby.patch create mode 100644 pkgs/games/dwarf-fortress/stonesense.nix diff --git a/pkgs/games/dwarf-fortress/default.nix b/pkgs/games/dwarf-fortress/default.nix index c759c4c60dae..bdd55b5aeda7 100644 --- a/pkgs/games/dwarf-fortress/default.nix +++ b/pkgs/games/dwarf-fortress/default.nix @@ -12,6 +12,7 @@ let }; soundSense = callPackage ./soundsense.nix { }; + stoneSense = callPackage ./stonesense.nix { }; dwarf-fortress-unfuck = callPackage ./unfuck.nix { }; diff --git a/pkgs/games/dwarf-fortress/dfhack/default.nix b/pkgs/games/dwarf-fortress/dfhack/default.nix index 0df91bb8df05..dbb3e7c32e25 100644 --- a/pkgs/games/dwarf-fortress/dfhack/default.nix +++ b/pkgs/games/dwarf-fortress/dfhack/default.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchgit, cmake, writeScriptBin -, perl, XMLLibXML, XMLLibXSLT -, zlib +{ stdenv, lib, fetchgit, cmake, writeScriptBin, callPackage +, perl, XMLLibXML, XMLLibXSLT, zlib +, enableStoneSense ? false, allegro5, mesa }: let @@ -43,11 +43,12 @@ in stdenv.mkDerivation rec { inherit rev sha256; }; - patches = [ ./skip-ruby.patch ]; + patches = [ ./fix-stonesense.patch ]; nativeBuildInputs = [ cmake perl XMLLibXML XMLLibXSLT fakegit ]; # We don't use system libraries because dfhack needs old C++ ABI. - buildInputs = [ zlib ]; + buildInputs = [ zlib ] + ++ lib.optionals enableStoneSense [ allegro5 mesa ]; preConfigure = '' # Trick build system into believing we have .git @@ -59,7 +60,8 @@ in stdenv.mkDerivation rec { export LD_LIBRARY_PATH="$PWD/depends/protobuf:$LD_LIBRARY_PATH" ''; - cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" ]; + cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" "-DDOWNLOAD_RUBY=OFF" ] + ++ lib.optionals enableStoneSense [ "-DBUILD_STONESENSE=ON" "-DSTONESENSE_INTERNAL_SO=OFF" ]; enableParallelBuilding = true; diff --git a/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch b/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch new file mode 100644 index 000000000000..da860cd55624 --- /dev/null +++ b/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch @@ -0,0 +1,23 @@ +From f5be6fe5fb192f01ae4551ed9217e97fd7f6a0ae Mon Sep 17 00:00:00 2001 +From: Herwig Hochleitner +Date: Sun, 1 Oct 2017 18:01:43 +0200 +Subject: [PATCH] include + +this fixes `GLhandleARB` not being defined +--- + plugins/stonesense/common.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/plugins/stonesense/common.h b/plugins/stonesense/common.h +index eb36691..ef45389 100644 +--- a/plugins/stonesense/common.h ++++ b/plugins/stonesense/common.h +@@ -31,6 +31,8 @@ using namespace df::enums; + #include + #include + ++#include ++ + // allegro leaks X headers, undef some of it here: + #undef TileShape + #undef None \ No newline at end of file diff --git a/pkgs/games/dwarf-fortress/dfhack/skip-ruby.patch b/pkgs/games/dwarf-fortress/dfhack/skip-ruby.patch deleted file mode 100644 index 877f6c3d215a..000000000000 --- a/pkgs/games/dwarf-fortress/dfhack/skip-ruby.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/plugins/ruby/CMakeLists.txt b/plugins/ruby/CMakeLists.txt -index f1ef12ac..0976e18a 100644 ---- a/plugins/ruby/CMakeLists.txt -+++ b/plugins/ruby/CMakeLists.txt -@@ -1,5 +1,5 @@ - # Allow build system to turn off downloading of libruby.so. --OPTION(DOWNLOAD_RUBY "Download prebuilt libruby.so for ruby plugin." ON) -+OPTION(DOWNLOAD_RUBY "Download prebuilt libruby.so for ruby plugin." OFF) - - IF (DOWNLOAD_RUBY) diff --git a/pkgs/games/dwarf-fortress/stonesense.nix b/pkgs/games/dwarf-fortress/stonesense.nix new file mode 100644 index 000000000000..52de513ac8fd --- /dev/null +++ b/pkgs/games/dwarf-fortress/stonesense.nix @@ -0,0 +1,15 @@ +{ stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + name = "stonesense"; + src = fetchFromGitHub { + owner = "DFHack"; + repo = "stonesense"; + rev = "be793a080e66db1ff79ac284070632ec1a896708"; + sha256 = "1kibqblxp16z75zm48kk59w483933rkg4w339f28fcrbpg4sn92s"; + }; + + nativeBuildInputs = [ cmake ]; + + cmakeFlags = [ "-DDFHACK_BUILD_ARCH=64" ]; +} diff --git a/pkgs/games/dwarf-fortress/wrapper/default.nix b/pkgs/games/dwarf-fortress/wrapper/default.nix index 232e0b7b3b54..05e851db6f85 100644 --- a/pkgs/games/dwarf-fortress/wrapper/default.nix +++ b/pkgs/games/dwarf-fortress/wrapper/default.nix @@ -1,11 +1,16 @@ { stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll , enableDFHack ? false, dfhack , enableSoundSense ? false, soundSense, jdk +, enableStoneSense ? false , themes ? {} , theme ? null }: let + dfhack_ = dfhack.override { + inherit enableStoneSense; + }; + ptheme = if builtins.isString theme then builtins.getAttr theme themes @@ -13,7 +18,7 @@ let # These are in inverse order for first packages to override the next ones. pkgs = lib.optional (theme != null) ptheme - ++ lib.optional enableDFHack dfhack + ++ lib.optional enableDFHack dfhack_ ++ lib.optional enableSoundSense soundSense ++ [ dwarf-fortress-original ]; @@ -26,7 +31,7 @@ let postBuild = lib.optionalString enableDFHack '' rm $out/hack/symbols.xml - substitute ${dfhack}/hack/symbols.xml $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) ''; diff --git a/pkgs/games/dwarf-fortress/wrapper/dfhack.in b/pkgs/games/dwarf-fortress/wrapper/dfhack.in index c8d8d287403b..4cf884ebed2c 100644 --- a/pkgs/games/dwarf-fortress/wrapper/dfhack.in +++ b/pkgs/games/dwarf-fortress/wrapper/dfhack.in @@ -2,7 +2,7 @@ source @dfInit@ -for i in dfhack.init-example dfhack-config/default hack/*; do +for i in dfhack.init-example dfhack-config/default hack/* stonesense/*; do update_path "$i" done