lol

Merge pull request #201568 from ncfavier/df

authored by

Naïm Favier and committed by
GitHub
b33a7fa3 84e81bb7

+115 -132
+1 -1
pkgs/games/dwarf-fortress/default.nix
··· 69 69 70 70 dfhack = callPackage ./dfhack { 71 71 inherit (perlPackages) XMLLibXML XMLLibXSLT; 72 - inherit dfVersion twbt; 72 + inherit dfVersion; 73 73 stdenv = gccStdenv; 74 74 }; 75 75
+34 -49
pkgs/games/dwarf-fortress/dfhack/default.nix
··· 2 2 , buildEnv 3 3 , lib 4 4 , fetchFromGitHub 5 + , fetchpatch 5 6 , cmake 6 7 , writeScriptBin 7 8 , perl ··· 13 14 , allegro5 14 15 , libGLU 15 16 , libGL 16 - , enableTWBT ? true 17 - , twbt 18 17 , SDL 19 18 , dfVersion 20 19 }: ··· 23 22 24 23 let 25 24 dfhack-releases = { 26 - "0.43.05" = { 27 - dfHackRelease = "0.43.05-r3.1"; 28 - sha256 = "1ds366i0qcfbn62w9qv98lsqcrm38npzgvcr35hf6ihqa6nc6xrl"; 29 - xmlRev = "860a9041a75305609643d465123a4b598140dd7f"; 30 - prerelease = false; 31 - }; 32 - "0.44.05" = { 33 - dfHackRelease = "0.44.05-r2"; 34 - sha256 = "1cwifdhi48a976xc472nf6q2k0ibwqffil5a4llcymcxdbgxdcc9"; 35 - xmlRev = "2794f8a6d7405d4858bac486a0bb17b94740c142"; 36 - prerelease = false; 37 - }; 38 - "0.44.09" = { 39 - dfHackRelease = "0.44.09-r1"; 40 - sha256 = "1nkfaa43pisbyik5inj5q2hja2vza5lwidg5z02jyh136jm64hwk"; 41 - xmlRev = "3c0bf63674d5430deadaf7befaec42f0ec1e8bc5"; 42 - prerelease = false; 43 - }; 44 25 "0.44.10" = { 45 26 dfHackRelease = "0.44.10-r2"; 46 27 sha256 = "19bxsghxzw3bilhr8sm4axz7p7z8lrvbdsd1vdjf5zbg04rs866i"; ··· 66 47 prerelease = true; 67 48 }; 68 49 "0.47.04" = { 69 - dfHackRelease = "0.47.04-r2"; 70 - sha256 = "18ppn1dqaxi6ahjzsvb9kw70rvca106a1hibhzc4rxmraypnqb89"; 71 - xmlRev = "036b662a1bbc96b4911f3cbe74dfa1243b6459bc"; 50 + dfHackRelease = "0.47.04-r5"; 51 + sha256 = "sha256-0s+/LKbqsS/mrxKPDeniqykE5+Gy3ZzCa8yEDzMyssY="; 52 + xmlRev = "be0444cc165a1abff053d5893dc1f780f06526b7"; 72 53 prerelease = false; 73 54 }; 74 55 "0.47.05" = { 75 - dfHackRelease = "0.47.05-r1"; 76 - sha256 = "sha256-B0iv7fpIcnaO8sx9wPqI7/WuyLK15p8UYlYIcF5F5bw="; 77 - xmlRev = "11c379ffd31255f2a1415d98106114a46245e1c3"; 56 + dfHackRelease = "0.47.05-r7"; 57 + sha256 = "sha256-vBKUTSjfCnalkBzfjaIKcxUuqsGGOTtoJC1RHJIDlNc="; 58 + xmlRev = "f5019a5c6f19ef05a28bd974c3e8668b78e6e2a4"; 78 59 prerelease = false; 79 60 }; 80 61 81 62 }; 82 63 83 64 release = 84 - if hasAttr dfVersion dfhack-releases 65 + if lib.isAttrs dfVersion 66 + then dfVersion 67 + else if hasAttr dfVersion dfhack-releases 85 68 then getAttr dfVersion dfhack-releases 86 69 else throw "[DFHack] Unsupported Dwarf Fortress version: ${dfVersion}"; 87 70 ··· 115 98 exit 1 116 99 fi 117 100 ''; 118 - 119 - dfhack = stdenv.mkDerivation { 120 - pname = "dfhack-base"; 101 + in 102 + stdenv.mkDerivation { 103 + pname = "dfhack"; 121 104 inherit version; 122 105 123 106 # Beware of submodules ··· 129 112 fetchSubmodules = true; 130 113 }; 131 114 132 - patches = [ ./fix-stonesense.patch ]; 115 + patches = lib.optional (lib.versionOlder version "0.44.12-r3") (fetchpatch { 116 + name = "fix-stonesense.patch"; 117 + url = "https://github.com/DFHack/stonesense/commit/f5be6fe5fb192f01ae4551ed9217e97fd7f6a0ae.patch"; 118 + extraPrefix = "plugins/stonesense/"; 119 + stripLen = 1; 120 + hash = "sha256-wje6Mkct29eyMOcJnbdefwBOLJko/s4JcJe52ojuW+8="; 121 + }) ++ lib.optional (lib.versionOlder version "0.47.04-r1") (fetchpatch { 122 + name = "fix-protobuf.patch"; 123 + url = "https://github.com/DFHack/dfhack/commit/7bdf958518d2892ee89a7173224a069c4a2190d8.patch"; 124 + hash = "sha256-p+mKhmYbnhWKNiGPMjbYO505Gcg634n0nudqH0NX3KY="; 125 + }); 133 126 134 127 # gcc 11 fix 135 - NIX_CFLAGS_COMPILE = "-fpermissive"; 128 + CXXFLAGS = lib.optionalString (lib.versionOlder version "0.47.05-r3") "-fpermissive"; 136 129 137 130 # As of 138 131 # https://github.com/DFHack/dfhack/commit/56e43a0dde023c5a4595a22b29d800153b31e3c4, ··· 166 159 ln -s ${ruby}/lib/libruby-*.so $out/hack/libruby.so 167 160 ''; 168 161 169 - }; 170 - in 162 + passthru = { inherit dfVersion; }; 171 163 172 - buildEnv { 173 - name = "dfhack-${version}"; 174 - 175 - passthru = { inherit version dfVersion; }; 176 - 177 - paths = [ dfhack ] ++ lib.optionals enableTWBT [ twbt.lib ]; 178 - 179 - meta = with lib; { 180 - description = "Memory hacking library for Dwarf Fortress and a set of tools that use it"; 181 - homepage = "https://github.com/DFHack/dfhack/"; 182 - license = licenses.zlib; 183 - platforms = [ "x86_64-linux" "i686-linux" ]; 184 - maintainers = with maintainers; [ robbinch a1russell abbradar numinit ]; 185 - }; 186 - } 164 + meta = with lib; { 165 + description = "Memory hacking library for Dwarf Fortress and a set of tools that use it"; 166 + homepage = "https://github.com/DFHack/dfhack/"; 167 + license = licenses.zlib; 168 + platforms = [ "x86_64-linux" "i686-linux" ]; 169 + maintainers = with maintainers; [ robbinch a1russell abbradar numinit ncfavier ]; 170 + }; 171 + }
-23
pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch
··· 1 - From f5be6fe5fb192f01ae4551ed9217e97fd7f6a0ae Mon Sep 17 00:00:00 2001 2 - From: Herwig Hochleitner <hhochleitner@gmail.com> 3 - Date: Sun, 1 Oct 2017 18:01:43 +0200 4 - Subject: [PATCH] include <GL/glext.h> 5 - 6 - this fixes `GLhandleARB` not being defined 7 - --- 8 - plugins/stonesense/common.h | 2 ++ 9 - 1 file changed, 2 insertions(+) 10 - 11 - diff --git a/plugins/stonesense/common.h b/plugins/stonesense/common.h 12 - index eb36691..ef45389 100644 13 - --- a/plugins/stonesense/common.h 14 - +++ b/plugins/stonesense/common.h 15 - @@ -31,6 +31,8 @@ using namespace df::enums; 16 - #include <allegro5/allegro_opengl.h> 17 - #include <allegro5/utf8.h> 18 - 19 - +#include <GL/glext.h> 20 - + 21 - // allegro leaks X headers, undef some of it here: 22 - #undef TileShape 23 - #undef None
+1 -1
pkgs/games/dwarf-fortress/game.nix
··· 104 104 homepage = "https://www.bay12games.com/dwarves/"; 105 105 license = licenses.unfreeRedistributable; 106 106 platforms = attrNames platforms; 107 - maintainers = with maintainers; [ a1russell robbinch roconnor abbradar numinit shazow ]; 107 + maintainers = with maintainers; [ a1russell robbinch roconnor abbradar numinit shazow ncfavier ]; 108 108 }; 109 109 }
+1 -1
pkgs/games/dwarf-fortress/lazy-pack.nix
··· 19 19 , theme ? themes.phoebus 20 20 # General config options: 21 21 , enableIntro ? true 22 - , enableTruetype ? true 22 + , enableTruetype ? null # defaults to 24, see init.txt 23 23 , enableFPS ? false 24 24 , enableTextMode ? false 25 25 , enableSound ? true
+4 -19
pkgs/games/dwarf-fortress/twbt/default.nix
··· 9 9 10 10 let 11 11 twbt-releases = { 12 - "0.43.05" = { 13 - twbtRelease = "6.22"; 14 - sha256 = "0di5d38f6jj9smsz0wjcs1zav4zba6hrk8cbn59kwpb1wamsh5c7"; 15 - prerelease = false; 16 - }; 17 - "0.44.05" = { 18 - twbtRelease = "6.35"; 19 - sha256 = "0qjkgl7dsqzsd7pdq8a5bihhi1wplfkv1id7sj6dp3swjpsfxp8g"; 20 - prerelease = false; 21 - }; 22 - "0.44.09" = { 23 - twbtRelease = "6.41"; 24 - sha256 = "0nsq15z05pbhqjvw2xqs1a9b1n2ma0aalhc3vh3mi4cd4k7lxh44"; 25 - prerelease = false; 26 - }; 27 12 "0.44.10" = { 28 13 twbtRelease = "6.49"; 29 14 sha256 = "1qjkc7k33qhxj2g18njzasccjqsis5y8zrw5vl90h4rs3i8ld9xz"; ··· 46 31 }; 47 32 "0.47.04" = { 48 33 twbtRelease = "6.xx"; 49 - dfhackRelease = "0.47.04-r2"; 50 - sha256 = "092dgp8fh1j4nqr9wbzn89ib1nhscclr8m91lfxsvg0mgn7j8xlv"; 34 + dfhackRelease = "0.47.04-r5"; 35 + sha256 = "sha256-+C3g4KJShCb2VXGQ4mtkDOufXZQ1P+ebDTmUzL3tNyU="; 51 36 prerelease = true; 52 37 }; 53 38 "0.47.05" = { 54 39 twbtRelease = "6.xx"; 55 - dfhackRelease = "0.47.05-r1"; 56 - sha256 = "1nqhaf7271bm9rq9dmilhhk9q7v3841d0rv4y3fid40vfi4gpi3p"; 40 + dfhackRelease = "0.47.05-r7"; 41 + sha256 = "sha256-4xMKuSP5J6pMK+hwjTAcTI0gsLJfw+Xt+vh9CopR4tk="; 57 42 prerelease = true; 58 43 }; 59 44 };
+72 -36
pkgs/games/dwarf-fortress/wrapper/default.nix
··· 4 4 , substituteAll 5 5 , runCommand 6 6 , coreutils 7 + , gawk 7 8 , dwarf-fortress 8 9 , dwarf-therapist 9 10 , enableDFHack ? false ··· 16 17 , twbt 17 18 , themes ? { } 18 19 , theme ? null 20 + , extraPackages ? [ ] 19 21 # General config options: 20 22 , enableIntro ? true 21 - , enableTruetype ? true 23 + , enableTruetype ? null # defaults to 24, see init.txt 22 24 , enableFPS ? false 23 25 , enableTextMode ? false 24 26 , enableSound ? true 27 + # An attribute set of settings to override in data/init/*.txt. 28 + # For example, `init.FOO = true;` is translated to `[FOO:YES]` in init.txt 29 + , settings ? { } 30 + # TODO world-gen.txt, interface.txt require special logic 25 31 }: 26 32 27 33 let 28 34 dfhack_ = dfhack.override { 29 35 inherit enableStoneSense; 30 - inherit enableTWBT; 31 36 }; 32 37 33 38 ptheme = ··· 35 40 then builtins.getAttr theme themes 36 41 else theme; 37 42 38 - unBool = b: if b then "YES" else "NO"; 43 + baseEnv = buildEnv { 44 + name = "dwarf-fortress-base-env-${dwarf-fortress.dfVersion}"; 39 45 40 - # These are in inverse order for first packages to override the next ones. 41 - themePkg = lib.optional (theme != null) ptheme; 42 - pkgs = lib.optional enableDFHack dfhack_ 43 - ++ lib.optional enableSoundSense soundSense 44 - ++ lib.optional enableTWBT twbt.art 45 - ++ [ dwarf-fortress ]; 46 + # These are in inverse order for first packages to override the next ones. 47 + paths = extraPackages 48 + ++ lib.optional (theme != null) ptheme 49 + ++ lib.optional enableDFHack dfhack_ 50 + ++ lib.optional enableSoundSense soundSense 51 + ++ lib.optionals enableTWBT [ twbt.lib twbt.art ] 52 + ++ [ dwarf-fortress ]; 46 53 47 - fixup = lib.singleton (runCommand "fixup" { } ('' 54 + ignoreCollisions = true; 55 + }; 56 + 57 + settings_ = lib.recursiveUpdate { 58 + init = { 59 + PRINT_MODE = if enableTextMode then "TEXT" else if enableTWBT then "TWBT" else null; 60 + INTRO = enableIntro; 61 + TRUETYPE = enableTruetype; 62 + FPS = enableFPS; 63 + SOUND = enableSound; 64 + }; 65 + } settings; 66 + 67 + forEach = attrs: f: lib.concatStrings (lib.mapAttrsToList f attrs); 68 + 69 + toTxt = v: 70 + if lib.isBool v then if v then "YES" else "NO" 71 + else if lib.isInt v then toString v 72 + else if lib.isString v then v 73 + else throw "dwarf-fortress: unsupported configuration value ${toString v}"; 74 + 75 + config = runCommand "dwarf-fortress-config" { 76 + nativeBuildInputs = [ gawk ]; 77 + } ('' 48 78 mkdir -p $out/data/init 49 - '' + (if (theme != null) then '' 50 - cp ${lib.head themePkg}/data/init/init.txt $out/data/init/init.txt 51 - '' else '' 52 - cp ${dwarf-fortress}/data/init/init.txt $out/data/init/init.txt 53 - '') + lib.optionalString enableDFHack '' 79 + 80 + edit_setting() { 81 + v=''${v//'&'/'\&'} 82 + if ! gawk -i inplace -v RS='\r?\n' ' 83 + { n += sub("\\[" ENVIRON["k"] ":[^]]*\\]", "[" ENVIRON["k"] ":" ENVIRON["v"] "]"); print } 84 + END { exit(!n) } 85 + ' "$out/$file"; then 86 + echo "error: no setting named '$k' in $file" >&2 87 + exit 1 88 + fi 89 + } 90 + '' + forEach settings_ (file: kv: '' 91 + file=data/init/${lib.escapeShellArg file}.txt 92 + cp ${baseEnv}/"$file" "$out/$file" 93 + '' + forEach kv (k: v: lib.optionalString (v != null) '' 94 + export k=${lib.escapeShellArg k} v=${lib.escapeShellArg (toTxt v)} 95 + edit_setting 96 + '')) + lib.optionalString enableDFHack '' 54 97 mkdir -p $out/hack 55 98 56 99 # Patch the MD5 57 - orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig") 58 - patched_md5=$(cat "${dwarf-fortress}/hash.md5") 100 + orig_md5=$(< "${dwarf-fortress}/hash.md5.orig") 101 + patched_md5=$(< "${dwarf-fortress}/hash.md5") 59 102 input_file="${dfhack_}/hack/symbols.xml" 60 103 output_file="$out/hack/symbols.xml" 61 104 ··· 66 109 echo " Replace: $patched_md5" 67 110 68 111 substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5" 69 - '' + lib.optionalString enableTWBT '' 70 - substituteInPlace $out/data/init/init.txt \ 71 - --replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]' 72 - '' + 73 - lib.optionalString enableTextMode '' 74 - substituteInPlace $out/data/init/init.txt \ 75 - --replace '[PRINT_MODE:2D]' '[PRINT_MODE:TEXT]' 76 - '' + '' 77 - substituteInPlace $out/data/init/init.txt \ 78 - --replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \ 79 - --replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \ 80 - --replace '[FPS:NO]' '[FPS:${unBool enableFPS}]' \ 81 - --replace '[SOUND:YES]' '[SOUND:${unBool enableSound}]' 82 - '')); 112 + ''); 83 113 114 + # This is a separate environment because the config files to modify may come 115 + # from any of the paths in baseEnv. 84 116 env = buildEnv { 85 117 name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}"; 86 - 87 - paths = fixup ++ themePkg ++ pkgs; 88 - pathsToLink = [ "/" "/hack" "/hack/scripts" ]; 89 - 118 + paths = [ config baseEnv ]; 90 119 ignoreCollisions = true; 91 120 }; 92 121 in 122 + 123 + lib.throwIf (enableTWBT && !enableDFHack) "dwarf-fortress: TWBT requires DFHack to be enabled" 124 + lib.throwIf (enableStoneSense && !enableDFHack) "dwarf-fortress: StoneSense requires DFHack to be enabled" 125 + lib.throwIf (enableTextMode && enableTWBT) "dwarf-fortress: text mode and TWBT are mutually exclusive" 93 126 94 127 stdenv.mkDerivation { 95 128 pname = "dwarf-fortress"; ··· 114 147 runDFHack = ./dfhack.in; 115 148 runSoundSense = ./soundSense.in; 116 149 117 - passthru = { inherit dwarf-fortress dwarf-therapist; }; 150 + passthru = { 151 + inherit dwarf-fortress dwarf-therapist twbt env; 152 + dfhack = dfhack_; 153 + }; 118 154 119 155 buildCommand = '' 120 156 mkdir -p $out/bin
+2 -2
pkgs/games/dwarf-fortress/wrapper/dfhack.in
··· 2 2 3 3 source @dfInit@ 4 4 5 - for i in dfhack.init-example dfhack-config/default hack/* stonesense/*; do 6 - update_path "$i" 5 + for i in *.init *.init-example dfhack-config/default dfhack-config/init hack/* stonesense/*; do 6 + if [ -e "$i" ]; then update_path "$i"; fi 7 7 done 8 8 9 9 cd "$DF_DIR"