Merge pull request #201568 from ncfavier/df
This commit is contained in:
commit
b33a7fa3fa
@ -69,7 +69,7 @@ let
|
||||
|
||||
dfhack = callPackage ./dfhack {
|
||||
inherit (perlPackages) XMLLibXML XMLLibXSLT;
|
||||
inherit dfVersion twbt;
|
||||
inherit dfVersion;
|
||||
stdenv = gccStdenv;
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
, buildEnv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, cmake
|
||||
, writeScriptBin
|
||||
, perl
|
||||
@ -13,8 +14,6 @@
|
||||
, allegro5
|
||||
, libGLU
|
||||
, libGL
|
||||
, enableTWBT ? true
|
||||
, twbt
|
||||
, SDL
|
||||
, dfVersion
|
||||
}:
|
||||
@ -23,24 +22,6 @@ with lib;
|
||||
|
||||
let
|
||||
dfhack-releases = {
|
||||
"0.43.05" = {
|
||||
dfHackRelease = "0.43.05-r3.1";
|
||||
sha256 = "1ds366i0qcfbn62w9qv98lsqcrm38npzgvcr35hf6ihqa6nc6xrl";
|
||||
xmlRev = "860a9041a75305609643d465123a4b598140dd7f";
|
||||
prerelease = false;
|
||||
};
|
||||
"0.44.05" = {
|
||||
dfHackRelease = "0.44.05-r2";
|
||||
sha256 = "1cwifdhi48a976xc472nf6q2k0ibwqffil5a4llcymcxdbgxdcc9";
|
||||
xmlRev = "2794f8a6d7405d4858bac486a0bb17b94740c142";
|
||||
prerelease = false;
|
||||
};
|
||||
"0.44.09" = {
|
||||
dfHackRelease = "0.44.09-r1";
|
||||
sha256 = "1nkfaa43pisbyik5inj5q2hja2vza5lwidg5z02jyh136jm64hwk";
|
||||
xmlRev = "3c0bf63674d5430deadaf7befaec42f0ec1e8bc5";
|
||||
prerelease = false;
|
||||
};
|
||||
"0.44.10" = {
|
||||
dfHackRelease = "0.44.10-r2";
|
||||
sha256 = "19bxsghxzw3bilhr8sm4axz7p7z8lrvbdsd1vdjf5zbg04rs866i";
|
||||
@ -66,22 +47,24 @@ let
|
||||
prerelease = true;
|
||||
};
|
||||
"0.47.04" = {
|
||||
dfHackRelease = "0.47.04-r2";
|
||||
sha256 = "18ppn1dqaxi6ahjzsvb9kw70rvca106a1hibhzc4rxmraypnqb89";
|
||||
xmlRev = "036b662a1bbc96b4911f3cbe74dfa1243b6459bc";
|
||||
dfHackRelease = "0.47.04-r5";
|
||||
sha256 = "sha256-0s+/LKbqsS/mrxKPDeniqykE5+Gy3ZzCa8yEDzMyssY=";
|
||||
xmlRev = "be0444cc165a1abff053d5893dc1f780f06526b7";
|
||||
prerelease = false;
|
||||
};
|
||||
"0.47.05" = {
|
||||
dfHackRelease = "0.47.05-r1";
|
||||
sha256 = "sha256-B0iv7fpIcnaO8sx9wPqI7/WuyLK15p8UYlYIcF5F5bw=";
|
||||
xmlRev = "11c379ffd31255f2a1415d98106114a46245e1c3";
|
||||
dfHackRelease = "0.47.05-r7";
|
||||
sha256 = "sha256-vBKUTSjfCnalkBzfjaIKcxUuqsGGOTtoJC1RHJIDlNc=";
|
||||
xmlRev = "f5019a5c6f19ef05a28bd974c3e8668b78e6e2a4";
|
||||
prerelease = false;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
release =
|
||||
if hasAttr dfVersion dfhack-releases
|
||||
if lib.isAttrs dfVersion
|
||||
then dfVersion
|
||||
else if hasAttr dfVersion dfhack-releases
|
||||
then getAttr dfVersion dfhack-releases
|
||||
else throw "[DFHack] Unsupported Dwarf Fortress version: ${dfVersion}";
|
||||
|
||||
@ -115,9 +98,9 @@ let
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
dfhack = stdenv.mkDerivation {
|
||||
pname = "dfhack-base";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "dfhack";
|
||||
inherit version;
|
||||
|
||||
# Beware of submodules
|
||||
@ -129,10 +112,20 @@ let
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
patches = [ ./fix-stonesense.patch ];
|
||||
patches = lib.optional (lib.versionOlder version "0.44.12-r3") (fetchpatch {
|
||||
name = "fix-stonesense.patch";
|
||||
url = "https://github.com/DFHack/stonesense/commit/f5be6fe5fb192f01ae4551ed9217e97fd7f6a0ae.patch";
|
||||
extraPrefix = "plugins/stonesense/";
|
||||
stripLen = 1;
|
||||
hash = "sha256-wje6Mkct29eyMOcJnbdefwBOLJko/s4JcJe52ojuW+8=";
|
||||
}) ++ lib.optional (lib.versionOlder version "0.47.04-r1") (fetchpatch {
|
||||
name = "fix-protobuf.patch";
|
||||
url = "https://github.com/DFHack/dfhack/commit/7bdf958518d2892ee89a7173224a069c4a2190d8.patch";
|
||||
hash = "sha256-p+mKhmYbnhWKNiGPMjbYO505Gcg634n0nudqH0NX3KY=";
|
||||
});
|
||||
|
||||
# gcc 11 fix
|
||||
NIX_CFLAGS_COMPILE = "-fpermissive";
|
||||
CXXFLAGS = lib.optionalString (lib.versionOlder version "0.47.05-r3") "-fpermissive";
|
||||
|
||||
# As of
|
||||
# https://github.com/DFHack/dfhack/commit/56e43a0dde023c5a4595a22b29d800153b31e3c4,
|
||||
@ -166,21 +159,13 @@ let
|
||||
ln -s ${ruby}/lib/libruby-*.so $out/hack/libruby.so
|
||||
'';
|
||||
|
||||
};
|
||||
in
|
||||
passthru = { inherit dfVersion; };
|
||||
|
||||
buildEnv {
|
||||
name = "dfhack-${version}";
|
||||
|
||||
passthru = { inherit version dfVersion; };
|
||||
|
||||
paths = [ dfhack ] ++ lib.optionals enableTWBT [ twbt.lib ];
|
||||
|
||||
meta = with 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 = [ "x86_64-linux" "i686-linux" ];
|
||||
maintainers = with maintainers; [ robbinch a1russell abbradar numinit ];
|
||||
};
|
||||
}
|
||||
meta = with 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 = [ "x86_64-linux" "i686-linux" ];
|
||||
maintainers = with maintainers; [ robbinch a1russell abbradar numinit ncfavier ];
|
||||
};
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
From f5be6fe5fb192f01ae4551ed9217e97fd7f6a0ae Mon Sep 17 00:00:00 2001
|
||||
From: Herwig Hochleitner <hhochleitner@gmail.com>
|
||||
Date: Sun, 1 Oct 2017 18:01:43 +0200
|
||||
Subject: [PATCH] include <GL/glext.h>
|
||||
|
||||
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 <allegro5/allegro_opengl.h>
|
||||
#include <allegro5/utf8.h>
|
||||
|
||||
+#include <GL/glext.h>
|
||||
+
|
||||
// allegro leaks X headers, undef some of it here:
|
||||
#undef TileShape
|
||||
#undef None
|
@ -104,6 +104,6 @@ stdenv.mkDerivation {
|
||||
homepage = "https://www.bay12games.com/dwarves/";
|
||||
license = licenses.unfreeRedistributable;
|
||||
platforms = attrNames platforms;
|
||||
maintainers = with maintainers; [ a1russell robbinch roconnor abbradar numinit shazow ];
|
||||
maintainers = with maintainers; [ a1russell robbinch roconnor abbradar numinit shazow ncfavier ];
|
||||
};
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
, theme ? themes.phoebus
|
||||
# General config options:
|
||||
, enableIntro ? true
|
||||
, enableTruetype ? true
|
||||
, enableTruetype ? null # defaults to 24, see init.txt
|
||||
, enableFPS ? false
|
||||
, enableTextMode ? false
|
||||
, enableSound ? true
|
||||
|
@ -9,21 +9,6 @@ with lib;
|
||||
|
||||
let
|
||||
twbt-releases = {
|
||||
"0.43.05" = {
|
||||
twbtRelease = "6.22";
|
||||
sha256 = "0di5d38f6jj9smsz0wjcs1zav4zba6hrk8cbn59kwpb1wamsh5c7";
|
||||
prerelease = false;
|
||||
};
|
||||
"0.44.05" = {
|
||||
twbtRelease = "6.35";
|
||||
sha256 = "0qjkgl7dsqzsd7pdq8a5bihhi1wplfkv1id7sj6dp3swjpsfxp8g";
|
||||
prerelease = false;
|
||||
};
|
||||
"0.44.09" = {
|
||||
twbtRelease = "6.41";
|
||||
sha256 = "0nsq15z05pbhqjvw2xqs1a9b1n2ma0aalhc3vh3mi4cd4k7lxh44";
|
||||
prerelease = false;
|
||||
};
|
||||
"0.44.10" = {
|
||||
twbtRelease = "6.49";
|
||||
sha256 = "1qjkc7k33qhxj2g18njzasccjqsis5y8zrw5vl90h4rs3i8ld9xz";
|
||||
@ -46,14 +31,14 @@ let
|
||||
};
|
||||
"0.47.04" = {
|
||||
twbtRelease = "6.xx";
|
||||
dfhackRelease = "0.47.04-r2";
|
||||
sha256 = "092dgp8fh1j4nqr9wbzn89ib1nhscclr8m91lfxsvg0mgn7j8xlv";
|
||||
dfhackRelease = "0.47.04-r5";
|
||||
sha256 = "sha256-+C3g4KJShCb2VXGQ4mtkDOufXZQ1P+ebDTmUzL3tNyU=";
|
||||
prerelease = true;
|
||||
};
|
||||
"0.47.05" = {
|
||||
twbtRelease = "6.xx";
|
||||
dfhackRelease = "0.47.05-r1";
|
||||
sha256 = "1nqhaf7271bm9rq9dmilhhk9q7v3841d0rv4y3fid40vfi4gpi3p";
|
||||
dfhackRelease = "0.47.05-r7";
|
||||
sha256 = "sha256-4xMKuSP5J6pMK+hwjTAcTI0gsLJfw+Xt+vh9CopR4tk=";
|
||||
prerelease = true;
|
||||
};
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
, substituteAll
|
||||
, runCommand
|
||||
, coreutils
|
||||
, gawk
|
||||
, dwarf-fortress
|
||||
, dwarf-therapist
|
||||
, enableDFHack ? false
|
||||
@ -16,18 +17,22 @@
|
||||
, twbt
|
||||
, themes ? { }
|
||||
, theme ? null
|
||||
, extraPackages ? [ ]
|
||||
# General config options:
|
||||
, enableIntro ? true
|
||||
, enableTruetype ? true
|
||||
, enableTruetype ? null # defaults to 24, see init.txt
|
||||
, enableFPS ? false
|
||||
, enableTextMode ? false
|
||||
, enableSound ? true
|
||||
# An attribute set of settings to override in data/init/*.txt.
|
||||
# For example, `init.FOO = true;` is translated to `[FOO:YES]` in init.txt
|
||||
, settings ? { }
|
||||
# TODO world-gen.txt, interface.txt require special logic
|
||||
}:
|
||||
|
||||
let
|
||||
dfhack_ = dfhack.override {
|
||||
inherit enableStoneSense;
|
||||
inherit enableTWBT;
|
||||
};
|
||||
|
||||
ptheme =
|
||||
@ -35,27 +40,65 @@ let
|
||||
then builtins.getAttr theme themes
|
||||
else theme;
|
||||
|
||||
unBool = b: if b then "YES" else "NO";
|
||||
baseEnv = buildEnv {
|
||||
name = "dwarf-fortress-base-env-${dwarf-fortress.dfVersion}";
|
||||
|
||||
# These are in inverse order for first packages to override the next ones.
|
||||
themePkg = lib.optional (theme != null) ptheme;
|
||||
pkgs = lib.optional enableDFHack dfhack_
|
||||
++ lib.optional enableSoundSense soundSense
|
||||
++ lib.optional enableTWBT twbt.art
|
||||
++ [ dwarf-fortress ];
|
||||
# These are in inverse order for first packages to override the next ones.
|
||||
paths = extraPackages
|
||||
++ lib.optional (theme != null) ptheme
|
||||
++ lib.optional enableDFHack dfhack_
|
||||
++ lib.optional enableSoundSense soundSense
|
||||
++ lib.optionals enableTWBT [ twbt.lib twbt.art ]
|
||||
++ [ dwarf-fortress ];
|
||||
|
||||
fixup = lib.singleton (runCommand "fixup" { } (''
|
||||
ignoreCollisions = true;
|
||||
};
|
||||
|
||||
settings_ = lib.recursiveUpdate {
|
||||
init = {
|
||||
PRINT_MODE = if enableTextMode then "TEXT" else if enableTWBT then "TWBT" else null;
|
||||
INTRO = enableIntro;
|
||||
TRUETYPE = enableTruetype;
|
||||
FPS = enableFPS;
|
||||
SOUND = enableSound;
|
||||
};
|
||||
} settings;
|
||||
|
||||
forEach = attrs: f: lib.concatStrings (lib.mapAttrsToList f attrs);
|
||||
|
||||
toTxt = v:
|
||||
if lib.isBool v then if v then "YES" else "NO"
|
||||
else if lib.isInt v then toString v
|
||||
else if lib.isString v then v
|
||||
else throw "dwarf-fortress: unsupported configuration value ${toString v}";
|
||||
|
||||
config = runCommand "dwarf-fortress-config" {
|
||||
nativeBuildInputs = [ gawk ];
|
||||
} (''
|
||||
mkdir -p $out/data/init
|
||||
'' + (if (theme != null) then ''
|
||||
cp ${lib.head themePkg}/data/init/init.txt $out/data/init/init.txt
|
||||
'' else ''
|
||||
cp ${dwarf-fortress}/data/init/init.txt $out/data/init/init.txt
|
||||
'') + lib.optionalString enableDFHack ''
|
||||
|
||||
edit_setting() {
|
||||
v=''${v//'&'/'\&'}
|
||||
if ! gawk -i inplace -v RS='\r?\n' '
|
||||
{ n += sub("\\[" ENVIRON["k"] ":[^]]*\\]", "[" ENVIRON["k"] ":" ENVIRON["v"] "]"); print }
|
||||
END { exit(!n) }
|
||||
' "$out/$file"; then
|
||||
echo "error: no setting named '$k' in $file" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
'' + forEach settings_ (file: kv: ''
|
||||
file=data/init/${lib.escapeShellArg file}.txt
|
||||
cp ${baseEnv}/"$file" "$out/$file"
|
||||
'' + forEach kv (k: v: lib.optionalString (v != null) ''
|
||||
export k=${lib.escapeShellArg k} v=${lib.escapeShellArg (toTxt v)}
|
||||
edit_setting
|
||||
'')) + lib.optionalString enableDFHack ''
|
||||
mkdir -p $out/hack
|
||||
|
||||
# Patch the MD5
|
||||
orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig")
|
||||
patched_md5=$(cat "${dwarf-fortress}/hash.md5")
|
||||
orig_md5=$(< "${dwarf-fortress}/hash.md5.orig")
|
||||
patched_md5=$(< "${dwarf-fortress}/hash.md5")
|
||||
input_file="${dfhack_}/hack/symbols.xml"
|
||||
output_file="$out/hack/symbols.xml"
|
||||
|
||||
@ -66,31 +109,21 @@ let
|
||||
echo " Replace: $patched_md5"
|
||||
|
||||
substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5"
|
||||
'' + lib.optionalString enableTWBT ''
|
||||
substituteInPlace $out/data/init/init.txt \
|
||||
--replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]'
|
||||
'' +
|
||||
lib.optionalString enableTextMode ''
|
||||
substituteInPlace $out/data/init/init.txt \
|
||||
--replace '[PRINT_MODE:2D]' '[PRINT_MODE:TEXT]'
|
||||
'' + ''
|
||||
substituteInPlace $out/data/init/init.txt \
|
||||
--replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \
|
||||
--replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \
|
||||
--replace '[FPS:NO]' '[FPS:${unBool enableFPS}]' \
|
||||
--replace '[SOUND:YES]' '[SOUND:${unBool enableSound}]'
|
||||
''));
|
||||
'');
|
||||
|
||||
# This is a separate environment because the config files to modify may come
|
||||
# from any of the paths in baseEnv.
|
||||
env = buildEnv {
|
||||
name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}";
|
||||
|
||||
paths = fixup ++ themePkg ++ pkgs;
|
||||
pathsToLink = [ "/" "/hack" "/hack/scripts" ];
|
||||
|
||||
paths = [ config baseEnv ];
|
||||
ignoreCollisions = true;
|
||||
};
|
||||
in
|
||||
|
||||
lib.throwIf (enableTWBT && !enableDFHack) "dwarf-fortress: TWBT requires DFHack to be enabled"
|
||||
lib.throwIf (enableStoneSense && !enableDFHack) "dwarf-fortress: StoneSense requires DFHack to be enabled"
|
||||
lib.throwIf (enableTextMode && enableTWBT) "dwarf-fortress: text mode and TWBT are mutually exclusive"
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "dwarf-fortress";
|
||||
version = dwarf-fortress.dfVersion;
|
||||
@ -114,7 +147,10 @@ stdenv.mkDerivation {
|
||||
runDFHack = ./dfhack.in;
|
||||
runSoundSense = ./soundSense.in;
|
||||
|
||||
passthru = { inherit dwarf-fortress dwarf-therapist; };
|
||||
passthru = {
|
||||
inherit dwarf-fortress dwarf-therapist twbt env;
|
||||
dfhack = dfhack_;
|
||||
};
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
|
4
pkgs/games/dwarf-fortress/wrapper/dfhack.in
Normal file → Executable file
4
pkgs/games/dwarf-fortress/wrapper/dfhack.in
Normal file → Executable file
@ -2,8 +2,8 @@
|
||||
|
||||
source @dfInit@
|
||||
|
||||
for i in dfhack.init-example dfhack-config/default hack/* stonesense/*; do
|
||||
update_path "$i"
|
||||
for i in *.init *.init-example dfhack-config/default dfhack-config/init hack/* stonesense/*; do
|
||||
if [ -e "$i" ]; then update_path "$i"; fi
|
||||
done
|
||||
|
||||
cd "$DF_DIR"
|
||||
|
Loading…
Reference in New Issue
Block a user