Merge pull request #43085 from matthewbauer/dwarf-fortress

Dwarf Fortress refactors
This commit is contained in:
Matthew Bauer 2018-07-09 17:40:16 -04:00 committed by GitHub
commit 97605d3e57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 211 additions and 69 deletions

View File

@ -1,10 +1,19 @@
{ pkgs, stdenv, stdenvNoCC, gccStdenv }:
{ pkgs, stdenv, stdenvNoCC, gccStdenv, lib, recurseIntoAttrs }:
let
callPackage = pkgs.newScope self;
df-games = lib.listToAttrs (map (dfVersion: {
name = "dwarf-fortress_${lib.replaceStrings ["."] ["_"] dfVersion}";
value = callPackage ./wrapper {
inherit (self) themes;
dwarf-fortress = callPackage ./game.nix { inherit dfVersion; };
};
}) (lib.attrNames self.df-hashes));
self = rec {
dwarf-fortress-original = callPackage ./game.nix { };
df-hashes = builtins.fromJSON (builtins.readFile ./game.json);
dwarf-fortress = df-games.dwarf-fortress_0_44_11;
dfhack = callPackage ./dfhack {
inherit (pkgs.perlPackages) XMLLibXML XMLLibXSLT;
@ -15,29 +24,27 @@ let
# unfuck is linux-only right now, we will just use it there
dwarf-fortress-unfuck = if stdenv.isLinux then callPackage ./unfuck.nix { }
else null;
else null;
dwarf-fortress = callPackage ./wrapper {
inherit themes;
};
dwarf-therapist-original = pkgs.qt5.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 {
inherit (dwarf-fortress) dwarf-fortress;
dwarf-therapist = pkgs.qt5.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 { };
legends-browser = callPackage ./legends-browser {};
themes = callPackage ./themes {
themes = recurseIntoAttrs (callPackage ./themes {
stdenv = stdenvNoCC;
};
});
# aliases
phoebus-theme = themes.phoebus;
cla-theme = themes.cla;
dwarf-fortress-original = dwarf-fortress.dwarf-fortress;
};
in self
in self // df-games

View File

@ -1,7 +1,8 @@
{ stdenv, fetchFromGitHub, coreutils, qtbase, qtdeclarative, cmake, texlive, ninja }:
{ stdenv, fetchFromGitHub, coreutils, qtbase
, qtdeclarative, cmake, texlive, ninja }:
stdenv.mkDerivation rec {
name = "dwarf-therapist-original-${version}";
name = "dwarf-therapist-${version}";
version = "40.1.0";
src = fetchFromGitHub {

View File

@ -1,20 +1,19 @@
{ stdenv, symlinkJoin, lib, dwarf-therapist-original, dwarf-fortress-original, makeWrapper }:
{ stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }:
let
df = dwarf-fortress-original;
dt = dwarf-therapist-original;
platformSlug = if stdenv.targetPlatform.is32bit then
"linux32" else "linux64";
inifile = "linux/v0.${df.baseVersion}.${df.patchVersion}_${platformSlug}.ini";
dfHashFile = "${df}/hash.md5";
inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini";
in symlinkJoin {
name = "dwarf-therapist-${dt.version}";
name = "dwarf-therapist-${dwarf-therapist.version}";
paths = [ dt ];
paths = [ dwarf-therapist ];
buildInputs = [ makeWrapper ];
passthru = { inherit dwarf-fortress dwarf-therapist; };
postBuild = ''
# DwarfTherapist assumes it's run in $out/share/dwarftherapist and
# therefore uses many relative paths.
@ -23,10 +22,10 @@ in symlinkJoin {
rm -rf $out/share/dwarftherapist/memory_layouts/linux
mkdir -p $out/share/dwarftherapist/memory_layouts/linux
origmd5=$(cat "${dfHashFile}.orig" | cut -c1-8)
patchedmd5=$(cat "${dfHashFile}" | cut -c1-8)
origmd5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8)
patchedmd5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8)
substitute \
${dt}/share/dwarftherapist/memory_layouts/${inifile} \
${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile} \
$out/share/dwarftherapist/memory_layouts/${inifile} \
--replace "$origmd5" "$patchedmd5"
'';

View File

@ -0,0 +1,86 @@
{
"0.43.05": {
"linux": "1r0b96yrdf24m9476k5x7rmp3faxr0kfwwdf35agpvlb1qbi6v45",
"linux32": "16l1lydpkbnl3zhz4i2snmjk7pps8vmw3zv0bjgr8dncbsrycd03",
"osx": "1j2zdkjnmxy8yn599pm0qmbi4zjp1m8h4ggqjxhyzp135h0lqqf9",
"osx32": "09ym4mflp5z78pk5mvj7b44xihnsvrxmh0b5kix6h1m6z3cc90l4",
"win": "0m337wh4c47ij1f3zrimvy7baff7nzrmgjbmrwdy89d0z90xpnx8",
"win_s": "0bjk5m1qkn3ldhqiwbq24y2m9fz9r574d54ngdb8b4ri2xfl1fbp",
"win32": "162rl9ygpj66pis87bqc5bwc0mk75hxv6ianhn87pbl4rh7g8ax8",
"win32_s": "0gv1jyw5fdskjjs27pr41grbmkk7ipqn0ry615f5g79k3mhl200i",
"legacy": "09lvbmg1gq257qchlbmq7hxc5nl9r39jpf73zhmwb5xfbpprn0zs",
"legacy_s": "023a5b27fm65w7gmzjssyyci70fdjk2zbv965y4n0f23kc4rj9gl",
"legacy32": "1m75arxj1q82l2dkk8qcargm3xczxlqi8krwvg3iimddky34gipq",
"legacy32_s": "1hgzsk66isfr5vcraxwgl7cvycl14kwf8w9kzxr8jyp5z7k24q29"
},
"0.44.05": {
"linux": "18bjyhjp5458bfbizm8vq4s00pqpfs097qp6pv76m84kgbc4ghg3",
"linux32": "1b9i4kf4c8s6bhqwn8jx100mg7fqp8nmswrai5w8dsma01py4amr",
"osx": "1ssc8vq3ad38x9c04j8gg96kxv0g2npi3jwcg40676byx5nrx7b6",
"osx32": "12i7x8idcbvp5h62jyc7b7j98jf4lrisnwglvnrms6jclj0b3g0q",
"win": "1kaifarjx0akg7s5a2ngfw0vm0vyr4jnax5rrbv96dliqn5knddz",
"win_s": "1a1xikrjdv4b0yfgnp5s8d6xn0njylynsqd8zixdc01vccl5kqm6",
"win32": "1j3cq0h7jdvxbsbpfxa7bli45smvy9m4fji0j6849kj7x0vcpwq4",
"win32_s": "10cw1n48ffkrv9ms07ka5b5370d9k2fm051cnnq03lkcvlwrq145",
"legacy": "0y7xpgmwn4nshhc7apyf8mj5ycl0q5vckdaviwzz6w1x31s3dp6n",
"legacy_s": "0j8rbw9ww1avmh8zhyzljjj6in87q4qffpffdl394fsi74n8px0d",
"legacy32": "0d3l4jvx53a01fjf1lf20ar9lfyykfhk05dlrfwz3w4k7vj4vvlf",
"legacy32_s": "1c5x9x44bblz7anhmk4y9a7p1b39b9k7gzvj4pi55jzfq0k60kl7"
},
"0.44.09": {
"linux": "1haikynkg1pqyrzzqk1qxm19p36ww58qp8brh3fjxssp4x71rcdy",
"linux32": "0lmbrdf7wjdwj5yx0khnq871yxvhfwqxjjyfkqcdy5ik18lvlkj8",
"osx": "01dss8g9lmi8majp6lxcfw166ydz4himkz6am5pi29gixaf4vfqs",
"osx32": "1iwlvmz1ir9k0kzn6726frmkznvsg9a99bbqnxvwcnq3nnnjxw3s",
"win": "08g5irgp59dfjgj3jxc8ixwzgnz2wghcl8cg1b1g4088dsf2x3x8",
"win_s": "1xyb4msn9wfrh7x136r8xn3sjz6z8c4zksbzifa0z0bpa3pdviap",
"win32": "0m8bs2mnyi1r4x84fwnfgd1ijdcf08xsq5zy84476svci932g5kz",
"win32_s": "0pl319qmyy96ibzlgj4wfj19dv1wzyg8ig6q11l4c7rivzc9286i",
"legacy": "0l8nrvppfzazhjsfkd5nd0bxnc6ljk8fs6yg8qh69g7q7zvzgnd3",
"legacy_s": "1c49z539a31czzq0rnhg6yrv1zbaja35sd0ssr4k7lsghjv84k1z",
"legacy32": "155xg6dpb8frlw7d9h7m1y0spw55wl4nkn7zrm70bpyp39pydlqp",
"legacy32_s": "05qkzjfx1ybrv96wya1dirdfxdkhj6a440sjpzwbqpkqgr8z57a3"
},
"0.44.10": {
"linux": "1cqm43hn3ar9d8a7y7dwq48ajp72cirn1gclh8r2fykkypprxmp2",
"linux32": "0gdb6sq8725nwdisxwha8f5b6arq570s73aj4gdrh611gxh13r6n",
"osx": "1wpa45d81q8f5mhqmaxvdkz93k6cm3pg7vpsqjjjsp5s961gd74g",
"osx32": "0rsy1n19n12gh8rddgi3db32in488f2nizq8kw25hga03hsh4r6x",
"win": "04i0ka12hmn3chsyfmk2pbknr1pdf3p8yaz7kv82ri4g6dvsjfv6",
"win_s": "01m6nqcrz4rhdc8wb31azj3vmjid8bdpqaf9wkz4g4vvjyy7xiyz",
"win32": "1nymin8wbzbh8gm2702dy7h5spdijdxnysdz71ldyl0xx4vw68d9",
"win32_s": "1skz0jpfm6j9bins04kn96f3v3k0kvjqlh25x3129r3hh8xacnd3",
"legacy": "0s84vpfr2b5y1kda9allqjrpkaxw15mkblk9dq08syhsj19vspa7",
"legacy_s": "18b7ikp7xy2y071h3ydfh5mq9hw9y303rdqyikvra5ji3n5p96cm",
"legacy32": "1yh2fl3qwpy6wrxavhn75grbjygymnfh746hxbmc60la7y5flrpy",
"legacy32_s": "0j65w2hxgpccg9qsaz14r82qvnvfd0pbl2gyx9fv8d77kxhkc4pw"
},
"0.44.11": {
"linux": "1qizfkxl2k6pn70is4vz94q4k55bc3pm13b2r6yqi6lw1cnna4sf",
"linux32": "11m39lfyrsxlw1g7f269q7fzwichg06l21fxhqzgvlvmzmxsf8q5",
"osx": "073hmcj7bm323m3xqi42605rkvmgmv83bnxz1byymgs8aqyfykkx",
"osx32": "0w5avnj86wprk8q0rb5qm9kxbigzk6dk0akqbw4m76jgg2jdmir7",
"win": "1yxyv1sycn5jc3g1y02d82154xydg3kbghis7l3xi28n3bh8387b",
"win_s": "1xzwl6c362wqgps911y9q8vndp8zyd20fc2p7pkzzmw2hrgfqi6q",
"win32": "16x2rg3gm3lh2akg7n057kkxxigb2ljz0nk685lmn4j0adq8l31p",
"win32_s": "1a2y220111d94mzj5y3jwpy062k8fw25akyp7yn3fwa17vwvn8zq",
"legacy": "0gfjmsfqj21hs4d1hm7fvppbdjspc4r2qnnp6mwcbgh67i5p5rdb",
"legacy_s": "1wr4hpzmhgl8haric3jpfd3kwqv1fi4vkb1gvaax5f7kplvfqfac",
"legacy32": "1cpzckwvqkxqn0c498mmh4papsjdi3mcvcp2vzlvj46kvdl3n0f0",
"legacy32_s": "024vzwfcrx7ms4dip0ccwd0vizzck2pwz2ryyvlz4rpjzhswj5gi"
},
"0.44.12": {
"win32": "0bxrc7zj4vgcgdwc130g6f5jnp13vgx9a2kn2l1jcc958x8a367g",
"linux32": "0fmr8diskmbh12s0bpfn5gky9lmrc7xxj6va5adjm6ahxv9jwr06",
"osx": "1md6r1pimmlhcn5gjqzg0ygbdwc2v125sfjy0f6gbfbykwcm7391",
"osx32": "1dbg7pavxw20r8iqc566fn558avgj5glsycvi6ggbvsh0rpw6n5v",
"win": "0zb5ximqi5j7vyvgjzfz7ycadh5sgb7jlyaa68x0sjlbybdr1min",
"win_s": "1ncf5zr1fggr5knf30l0wh7spp376v1jcc6m9c86zim8azcfx0y7",
"linux": "0ydr5lnysy45nsznqp5r2pysdqn3f0xkrkh9v9l1md111mriabas",
"win32_s": "1mxbjkikf010skrpng51r86jmv4nal51j5n1y9kyhv344bq6chr9",
"legacy": "11a212ynhx18p3k8hvdjx199din14wggxiwz191b4309fznzpprz",
"legacy_s": "05madj529y18ndxrih96mivbzng1vz2zbzicrcnj58i2084zm23f",
"legacy32": "0rapcydiic2nq6idjf7fg53xsxk8dxzyi1vflpz554ghdrnsmwjv",
"legacy32_s": "16fgbd3lx4r270dxqj6gr1g1iqjj8cv389h2hw1l646xx28g8d2m"
}
}

View File

@ -3,47 +3,55 @@
# Our own "unfuck" libs for macOS
, ncurses, fmodex, gcc
, dfVersion, df-hashes
}:
with lib;
let
baseVersion = "44";
patchVersion = "11";
dfVersion = "0.${baseVersion}.${patchVersion}";
libpath = makeLibraryPath [ stdenv.cc.cc stdenv.cc.libc dwarf-fortress-unfuck SDL ];
homepage = http://www.bay12games.com/dwarves/;
# Map Dwarf Fortress platform names to Nixpkgs platform names.
# Other srcs are avilable like 32-bit mac & win, but I have only
# included the ones most likely to be needed by Nixpkgs users.
srcs = {
"x86_64-linux" = fetchurl {
url = "${homepage}df_${baseVersion}_${patchVersion}_linux.tar.bz2";
sha256 = "1qizfkxl2k6pn70is4vz94q4k55bc3pm13b2r6yqi6lw1cnna4sf";
};
"i686-linux" = fetchurl {
url = "${homepage}df_${baseVersion}_${patchVersion}_linux32.tar.bz2";
sha256 = "11m39lfyrsxlw1g7f269q7fzwichg06l21fxhqzgvlvmzmxsf8q5";
};
"x86_64-darwin" = fetchurl {
url = "${homepage}df_${baseVersion}_${patchVersion}_osx.tar.bz2";
sha256 = "073hmcj7bm323m3xqi42605rkvmgmv83bnxz1byymgs8aqyfykkx";
};
platforms = {
"x86_64-linux" = "linux";
"i686-linux" = "linux32";
"x86_64-darwin" = "osx";
"i686-darwin" = "osx32";
"x86_64-cygwin" = "win";
"i686-cygwin" = "win32";
};
dfVersionTriple = splitString "." dfVersion;
baseVersion = elemAt dfVersionTriple 1;
patchVersion = elemAt dfVersionTriple 2;
game = if hasAttr dfVersion df-hashes
then getAttr dfVersion df-hashes
else throw "Unknown Dwarf Fortress version: ${dfVersion}";
dfPlatform = if hasAttr stdenv.system platforms
then getAttr stdenv.system platforms
else throw "Unsupported system: ${stdenv.system}";
sha256 = if hasAttr dfPlatform game
then getAttr dfPlatform game
else throw "Unsupported dfPlatform: ${dfPlatform}";
in
assert dwarf-fortress-unfuck != null ->
dwarf-fortress-unfuck.dfVersion == dfVersion;
stdenv.mkDerivation {
name = "dwarf-fortress-original-${dfVersion}";
name = "dwarf-fortress-${dfVersion}";
src = if builtins.hasAttr stdenv.system srcs
then builtins.getAttr stdenv.system srcs
else throw "Unsupported systems";
src = fetchurl {
url = "${homepage}df_${baseVersion}_${patchVersion}_${dfPlatform}.tar.bz2";
inherit sha256;
};
installPhase = ''
mkdir -p $out
@ -81,13 +89,16 @@ stdenv.mkDerivation {
md5sum $exe | awk '{ print $1 }' > $out/hash.md5
'';
passthru = { inherit baseVersion patchVersion dfVersion; };
passthru = {
inherit baseVersion patchVersion dfVersion;
updateScript = ./update.sh;
};
meta = {
description = "A single-player fantasy game with a randomly generated adventure world";
inherit homepage;
license = licenses.unfreeRedistributable;
platforms = attrNames srcs;
platforms = attrNames platforms;
maintainers = with maintainers; [ a1russell robbinch roconnor the-kenny abbradar numinit ];
};
}

View File

@ -4,18 +4,12 @@ with builtins;
listToAttrs (map (v: {
inherit (v) name;
value = stdenv.mkDerivation {
value = fetchFromGitHub {
name = "${v.name}-${v.version}";
src = fetchFromGitHub {
owner = "DFgraphics";
repo = v.name;
rev = v.version;
sha256 = v.sha256;
};
installPhase = ''
mkdir -p $out
cp -r data raw $out
'';
owner = "DFgraphics";
repo = v.name;
rev = v.version;
sha256 = v.sha256;
meta = with lib; {
platforms = platforms.all;
maintainers = [ maintainers.matthewbauer ];

View File

@ -0,0 +1,42 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p jq nix coreutils curl
# systems to generate hashes for
systems='linux linux32 osx osx32
win win_s win32 win32_s
legacy legacy_s legacy32 legacy32_s'
if [ $# -eq 0 ]; then
versions="$(curl http://www.bay12games.com/dwarves/ \
| grep 'DOWNLOAD DWARF FORTRESS' \
| sed 's/.*DOWNLOAD DWARF FORTRESS \([0-9.]*\) .*/\1/')"
else
versions="$@"
fi
tmp1="$(mktemp)"
tmp2="$(mktemp)"
for version in $versions; do
for system in $systems; do
echo -n $version,$system,
ver=$(echo $version | sed -e s,^0\.,, | tr . _)
if [[ "$system" = *win* ]] || [[ "$system" = *legacy* ]]; then
ext=zip
else
ext=tar.bz2
fi
nix-prefetch-url \
http://www.bay12games.com/dwarves/df_${ver}_${system}.${ext}
done
done | jq --slurp --raw-input \
'split("\n") | .[:-1] | map(split(",")) |
map({ "version": .[0], "platform": .[1], "sha256": .[2] }) |
group_by(.version) |
map(map({"version": .version, (.platform): .sha256}) | add |
{(.version): .} | map_values(del(.version))) | add' \
> "$tmp1"
# Append $tmp1 to game.json. There should be a better way to handle
# this but all other attempts failed for me.
jq -M --argfile a "$tmp1" '. + $a' < "$(dirname "$0")/game.json" > "$tmp2"
cat "$tmp2" > "$(dirname "$0")/game.json"

View File

@ -1,4 +1,4 @@
{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll
{ stdenv, lib, buildEnv, dwarf-fortress, substituteAll
, enableDFHack ? false, dfhack
, enableSoundSense ? false, soundSense, jdk
, enableStoneSense ? false
@ -20,10 +20,10 @@ let
themePkg = lib.optional (theme != null) ptheme;
pkgs = lib.optional enableDFHack dfhack_
++ lib.optional enableSoundSense soundSense
++ [ dwarf-fortress-original ];
++ [ dwarf-fortress ];
env = buildEnv {
name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}";
name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}";
paths = themePkg ++ pkgs;
pathsToLink = [ "/" "/hack" "/hack/scripts" ];
@ -32,16 +32,16 @@ let
postBuild = lib.optionalString enableDFHack ''
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)
--replace $(cat ${dwarf-fortress}/hash.md5.orig) \
$(cat ${dwarf-fortress}/hash.md5)
'';
};
in
stdenv.mkDerivation rec {
name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}";
name = "dwarf-fortress-${dwarf-fortress.dfVersion}";
compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress-original.dfVersion); true) pkgs;
compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress.dfVersion); true) pkgs;
dfInit = substituteAll {
name = "dwarf-fortress-init";
@ -55,6 +55,8 @@ stdenv.mkDerivation rec {
runDFHack = ./dfhack.in;
runSoundSense = ./soundSense.in;
passthru = { inherit dwarf-fortress; };
buildCommand = ''
mkdir -p $out/bin