diff options
Diffstat (limited to 'nixpkgs/pkgs/games/dwarf-fortress')
22 files changed, 1213 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/games/dwarf-fortress/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/default.nix new file mode 100644 index 000000000000..88a6d72bc485 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/default.nix @@ -0,0 +1,116 @@ +{ pkgs, stdenv, stdenvNoCC, gccStdenv, lib, recurseIntoAttrs }: + +# To whomever it may concern: +# +# This directory menaces with spikes of Nix code. It is terrifying. +# +# If this is your first time here, you should probably install the dwarf-fortress-full package, +# for instance with: +# +# environment.systemPackages = [ pkgs.dwarf-fortress-packages.dwarf-fortress-full ]; +# +# You can adjust its settings by using override, or compile your own package by +# using the other packages here. +# +# For example, you can enable the FPS indicator, disable the intro, pick a +# theme other than phoebus (the default for dwarf-fortress-full), _and_ use +# an older version with something like: +# +# environment.systemPackages = [ +# (pkgs.dwarf-fortress-packages.dwarf-fortress-full.override { +# dfVersion = "0.44.11"; +# theme = "cla"; +# enableIntro = false; +# enableFPS = true; +# }) +# ] +# +# Take a look at lazy-pack.nix to see all the other options. +# +# You will find the configuration files in ~/.local/share/df_linux/data/init. If +# you un-symlink them and edit, then the scripts will avoid overwriting your +# changes on later launches, but consider extending the wrapper with your +# desired options instead. + +with lib; + +let + callPackage = pkgs.newScope self; + + # The latest Dwarf Fortress version. Maintainers: when a new version comes + # out, ensure that (unfuck|dfhack|twbt) are all up to date before changing + # this. + latestVersion = "0.44.12"; + + # Converts a version to a package name. + versionToName = version: "dwarf-fortress_${lib.replaceStrings ["."] ["_"] version}"; + + # A map of names to each Dwarf Fortress package we know about. + df-games = lib.listToAttrs (map (dfVersion: { + name = versionToName dfVersion; + value = + let + # I can't believe this syntax works. Spikes of Nix code indeed... + dwarf-fortress = callPackage ./game.nix { + inherit dfVersion; + inherit dwarf-fortress-unfuck; + }; + + # unfuck is linux-only right now, we will only use it there. + dwarf-fortress-unfuck = if stdenv.isLinux then callPackage ./unfuck.nix { inherit dfVersion; } + else null; + + twbt = callPackage ./twbt { inherit dfVersion; }; + + dfhack = callPackage ./dfhack { + inherit (pkgs.perlPackages) XMLLibXML XMLLibXSLT; + inherit dfVersion twbt; + stdenv = gccStdenv; + }; + + dwarf-therapist = callPackage ./dwarf-therapist/wrapper.nix { + inherit 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; + }; + }; + }; + in + callPackage ./wrapper { + inherit (self) themes; + + dwarf-fortress = dwarf-fortress; + dwarf-fortress-unfuck = dwarf-fortress-unfuck; + twbt = twbt; + dfhack = dfhack; + dwarf-therapist = dwarf-therapist; + }; + }) (lib.attrNames self.df-hashes)); + + self = rec { + df-hashes = builtins.fromJSON (builtins.readFile ./game.json); + + # Aliases for the latest Dwarf Fortress and the selected Therapist install + dwarf-fortress = getAttr (versionToName latestVersion) df-games; + dwarf-therapist = dwarf-fortress.dwarf-therapist; + dwarf-fortress-original = dwarf-fortress.dwarf-fortress; + + dwarf-fortress-full = callPackage ./lazy-pack.nix { + inherit df-games versionToName latestVersion; + }; + + soundSense = callPackage ./soundsense.nix { }; + + legends-browser = callPackage ./legends-browser {}; + + themes = recurseIntoAttrs (callPackage ./themes { + stdenv = stdenvNoCC; + }); + + # Theme aliases + phoebus-theme = themes.phoebus; + cla-theme = themes.cla; + }; + +in self // df-games diff --git a/nixpkgs/pkgs/games/dwarf-fortress/df_permission b/nixpkgs/pkgs/games/dwarf-fortress/df_permission new file mode 100644 index 000000000000..b0121bb3fa37 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/df_permission @@ -0,0 +1,40 @@ +From tarn.adams@gmail.com Sat Oct 30 00:56:16 2010 +Date: Fri, 29 Oct 2010 16:56:15 -0800 +From: Tarn Adams <tarn.adams@gmail.com> +To: roconnor@theorem.ca +Subject: Re: Dwarf Fortress Redistribution for NixOS + +Sure, that redistribution is fine. I think I've handled the movie +issue for next time now. Thanks for the heads up on that. + +Tarn + +On Fri, Oct 29, 2010 at 6:56 AM, <roconnor@theorem.ca> wrote: +> I'd like to distribute a *slightly* modified version of Dwarf Fortress which +> is needed to run it under the NixOS distribution of Linux (see +> <http://nixos.org/> +> +> Modification: The interpreter location /lib/ld-linux.so.2 in +> lib/Dwarf_Fortress is replaced with the location of ld-linux.so.2 under the +> NixOS distribution (which is currently +> /nix/store/l8x3fdy1r6zf441vnqa87lzsvxrjbdz9-glibc-2.11.1/lib/ld-linux.so.2 +> but might change at a later date to something similar). +> +> I don't need you to recompile Dwarf Fortress. I can patch the binary itself +> using patchelf. I just would like your permission to redistrubute this +> modified binary. +> +> Thanks, I'm looking forward to trying out your game and letting other Nix +> users try it out too. +> +> P.S. the inital_movies are open in read/write mode instead of read-only mode +> which causes some issues under NixOS because the inital_movies are stored +> read-only. I have a workaround, but you may want to consider opening these +> files in read-only mode. +> +> -- +> Russell O'Connor <http://r6.ca/> +> ``All talk about `theft,''' the general counsel of the American Graphophone +> Company wrote, ``is the merest claptrap, for there exists no property in +> ideas musical, literary or artistic, except as defined by statute.'' +> diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dfhack/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/dfhack/default.nix new file mode 100644 index 000000000000..d65bdab84911 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dfhack/default.nix @@ -0,0 +1,138 @@ +{ stdenv, buildEnv, lib, fetchFromGitHub, cmake, writeScriptBin +, perl, XMLLibXML, XMLLibXSLT, zlib +, enableStoneSense ? false, allegro5, libGLU_combined +, enableTWBT ? true, twbt +, SDL +, dfVersion +}: + +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"; + xmlRev = "321bd48b10c4c3f694cc801a7dee6be392c09b7b"; + prerelease = false; + }; + "0.44.11" = { + dfHackRelease = "0.44.11-beta2.1"; + sha256 = "1jgwcqg9m1ybv3szgnklp6zfpiw5mswla464dlj2gfi5v82zqbv2"; + xmlRev = "f27ebae6aa8fb12c46217adec5a812cd49a905c8"; + prerelease = true; + }; + "0.44.12" = { + dfHackRelease = "0.44.12-r1"; + sha256 = "0j03lq6j6w378z6cvm7jspxc7hhrqm8jaszlq0mzfvap0k13fgyy"; + xmlRev = "23500e4e9bd1885365d0a2ef1746c321c1dd5094"; + prerelease = false; + }; + }; + + release = if hasAttr dfVersion dfhack-releases + then getAttr dfVersion dfhack-releases + else throw "[DFHack] Unsupported Dwarf Fortress version: ${dfVersion}"; + + version = release.dfHackRelease; + + warning = if release.prerelease then builtins.trace "[DFHack] Version ${version} is a prerelease. Careful!" + else null; + + # revision of library/xml submodule + xmlRev = release.xmlRev; + + arch = + if stdenv.hostPlatform.system == "x86_64-linux" then "64" + else if stdenv.hostPlatform.system == "i686-linux" then "32" + else throw "Unsupported architecture"; + + fakegit = writeScriptBin "git" '' + #! ${stdenv.shell} + if [ "$*" = "describe --tags --long" ]; then + echo "${version}-unknown" + elif [ "$*" = "describe --tags --abbrev=8 --long" ]; then + echo "${version}-unknown" + elif [ "$*" = "describe --tags --abbrev=8 --exact-match" ]; then + echo "${version}" + elif [ "$*" = "rev-parse HEAD" ]; then + if [ "$(dirname "$(pwd)")" = "xml" ]; then + echo "${xmlRev}" + else + echo "refs/tags/${version}" + fi + elif [ "$*" = "rev-parse HEAD:library/xml" ]; then + echo "${xmlRev}" + else + exit 1 + fi + ''; + + dfhack = stdenv.mkDerivation rec { + name = "dfhack-base-${version}"; + + # Beware of submodules + src = fetchFromGitHub { + owner = "DFHack"; + repo = "dfhack"; + rev = release.dfHackRelease; + sha256 = release.sha256; + fetchSubmodules = true; + }; + + patches = [ ./fix-stonesense.patch ]; + nativeBuildInputs = [ cmake perl XMLLibXML XMLLibXSLT fakegit ]; + # We don't use system libraries because dfhack needs old C++ ABI. + buildInputs = [ zlib SDL ] + ++ lib.optionals enableStoneSense [ allegro5 libGLU_combined ]; + + preConfigure = '' + # Trick build system into believing we have .git + mkdir -p .git/modules/library/xml + touch .git/index .git/modules/library/xml/index + ''; + + preBuild = '' + export LD_LIBRARY_PATH="$PWD/depends/protobuf:$LD_LIBRARY_PATH" + ''; + + cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" "-DDOWNLOAD_RUBY=OFF" ] + ++ lib.optionals enableStoneSense [ "-DBUILD_STONESENSE=ON" "-DSTONESENSE_INTERNAL_SO=OFF" ]; + + enableParallelBuilding = true; + }; +in + +buildEnv { + name = "dfhack-${version}"; + + passthru = { inherit version dfVersion; }; + + paths = [ dfhack ] ++ lib.optionals enableTWBT [ twbt.lib ]; + + 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 = [ "x86_64-linux" "i686-linux" ]; + maintainers = with maintainers; [ robbinch a1russell abbradar numinit ]; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch b/nixpkgs/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch new file mode 100644 index 000000000000..da860cd55624 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch @@ -0,0 +1,23 @@ +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 \ No newline at end of file diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix new file mode 100644 index 000000000000..652e4c184753 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchFromGitHub, qtbase +, qtdeclarative, cmake, texlive, ninja }: + +stdenv.mkDerivation rec { + name = "dwarf-therapist-${version}"; + version = "41.0.2"; + + src = fetchFromGitHub { + owner = "Dwarf-Therapist"; + repo = "Dwarf-Therapist"; + rev = "v${version}"; + sha256 = "0cvnk1dkszh7q7viv3i1v3ifzv1w0xyz69mifa1cbvbi47z2dh0d"; + }; + + buildInputs = [ qtbase qtdeclarative ]; + nativeBuildInputs = [ texlive cmake ninja ]; + + installPhase = if stdenv.isDarwin then '' + mkdir -p $out/Applications + cp -r DwarfTherapist.app $out/Applications + '' else null; + + meta = with stdenv.lib; { + description = "Tool to manage dwarves in a running game of Dwarf Fortress"; + maintainers = with maintainers; [ the-kenny abbradar bendlas numinit ]; + license = licenses.mit; + platforms = platforms.unix; + homepage = https://github.com/Dwarf-Therapist/Dwarf-Therapist; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in new file mode 100644 index 000000000000..77936c430e2b --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in @@ -0,0 +1,26 @@ +#!@stdenv_shell@ -e + +[ -z "$DT_DIR" ] && DT_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/dwarftherapist" + +install_dir="@install@" +therapist_dir="@therapist@" + +cat <<EOF >&2 +Using $DT_DIR as Dwarf Therapist overlay directory. +EOF + +update_path() { + local path="$1" + + mkdir -p "$DT_DIR/$(dirname "$path")" + if [ ! -e "$DT_DIR/$path" ] || [ -L "$DT_DIR/$path" ]; then + rm -f "$DT_DIR/$path" + ln -s "$install_dir/share/dwarftherapist/$path" "$DT_DIR/$path" + fi +} + +cd "$install_dir/share/dwarftherapist" +update_path memory_layouts + +QT_QPA_PLATFORM_PLUGIN_PATH="@qt_plugin_path@" \ + exec "$therapist_dir/bin/dwarftherapist" "$@" diff --git a/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix new file mode 100644 index 000000000000..071ab2af0c5c --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix @@ -0,0 +1,50 @@ +{ pkgs, stdenv, symlinkJoin, lib, dwarf-therapist, dwarf-fortress, makeWrapper }: + +let + platformSlug = if stdenv.targetPlatform.is32bit then + "linux32" else "linux64"; + inifile = "linux/v0.${dwarf-fortress.baseVersion}.${dwarf-fortress.patchVersion}_${platformSlug}.ini"; + +in + +stdenv.mkDerivation rec { + name = "dwarf-therapist-${dwarf-therapist.version}"; + + wrapper = ./dwarf-therapist.in; + + paths = [ dwarf-therapist ]; + + buildInputs = [ makeWrapper ]; + + passthru = { inherit dwarf-fortress dwarf-therapist; }; + + buildCommand = '' + mkdir -p $out/bin + ln -s $out/bin/dwarftherapist $out/bin/DwarfTherapist + substitute $wrapper $out/bin/dwarftherapist \ + --subst-var-by stdenv_shell ${stdenv.shell} \ + --subst-var-by install $out \ + --subst-var-by therapist ${dwarf-therapist} \ + --subst-var-by qt_plugin_path "${pkgs.qt5.qtbase}/lib/qt-${pkgs.qt5.qtbase.qtCompatVersion}/plugins/platforms" + + chmod 755 $out/bin/dwarftherapist + + # Fix up memory layouts + rm -rf $out/share/dwarftherapist/memory_layouts/linux + mkdir -p $out/share/dwarftherapist/memory_layouts/linux + orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8) + patched_md5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8) + input_file="${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile}" + output_file="$out/share/dwarftherapist/memory_layouts/${inifile}" + + echo "[Dwarf Therapist Wrapper] Fixing Dwarf Fortress MD5 prefix:" + echo " Input: $input_file" + echo " Search: $orig_md5" + echo " Output: $output_file" + echo " Replace: $patched_md5" + + substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5" + ''; + + preferLocalBuild = true; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/game.json b/nixpkgs/pkgs/games/dwarf-fortress/game.json new file mode 100644 index 000000000000..05fb0cf50800 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/game.json @@ -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" + } +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/game.nix b/nixpkgs/pkgs/games/dwarf-fortress/game.nix new file mode 100644 index 000000000000..b5c80a0a56dc --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/game.nix @@ -0,0 +1,101 @@ +{ stdenv, lib, fetchurl +, SDL, dwarf-fortress-unfuck + +# Our own "unfuck" libs for macOS +, ncurses, fmodex, gcc + +, dfVersion, df-hashes +}: + +with lib; + +let + 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. + 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.hostPlatform.system platforms + then getAttr stdenv.hostPlatform.system platforms + else throw "Unsupported system: ${stdenv.hostPlatform.system}"; + sha256 = if hasAttr dfPlatform game + then getAttr dfPlatform game + else throw "Unsupported dfPlatform: ${dfPlatform}"; + +in + +stdenv.mkDerivation { + name = "dwarf-fortress-${dfVersion}"; + + src = fetchurl { + url = "${homepage}df_${baseVersion}_${patchVersion}_${dfPlatform}.tar.bz2"; + inherit sha256; + }; + + installPhase = '' + mkdir -p $out + cp -r * $out + rm $out/libs/lib* + + exe=$out/${if stdenv.isLinux then "libs/Dwarf_Fortress" + else "dwarfort.exe"} + + # Store the original hash + md5sum $exe | awk '{ print $1 }' > $out/hash.md5.orig + '' + optionalString stdenv.isLinux '' + patchelf \ + --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \ + --set-rpath "${libpath}" \ + $exe + '' + optionalString stdenv.isDarwin '' + # My custom unfucked dwarfort.exe for macOS. Can't use + # absolute paths because original doesn't have enough + # header space. Someone plz break into Tarn's house & put + # -headerpad_max_install_names into his LDFLAGS. + + ln -s ${getLib ncurses}/lib/libncurses.dylib $out/libs + ln -s ${getLib gcc.cc}/lib/libstdc++.6.dylib $out/libs + ln -s ${getLib fmodex}/lib/libfmodex.dylib $out/libs + + install_name_tool \ + -change /usr/lib/libncurses.5.4.dylib \ + @executable_path/libs/libncurses.dylib \ + -change /usr/local/lib/x86_64/libstdc++.6.dylib \ + @executable_path/libs/libstdc++.6.dylib \ + $exe + '' + '' + # Store the new hash + md5sum $exe | awk '{ print $1 }' > $out/hash.md5 + ''; + + 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 platforms; + maintainers = with maintainers; [ a1russell robbinch roconnor the-kenny abbradar numinit ]; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/lazy-pack.nix b/nixpkgs/pkgs/games/dwarf-fortress/lazy-pack.nix new file mode 100644 index 000000000000..3a81dcc9c931 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/lazy-pack.nix @@ -0,0 +1,46 @@ +{ stdenvNoCC, lib, buildEnv, callPackage +, df-games, themes, latestVersion, versionToName +, dfVersion ? latestVersion + # This package should, at any given time, provide an opinionated "optimal" + # DF experience. It's the equivalent of the Lazy Newbie Pack, that is, and + # should contain every utility available unless you disable them. +, enableDFHack ? stdenvNoCC.isLinux +, enableTWBT ? enableDFHack +, enableSoundSense ? true +, enableStoneSense ? true +, enableDwarfTherapist ? true +, enableLegendsBrowser ? true, legends-browser +, theme ? themes.phoebus +# General config options: +, enableIntro ? true +, enableTruetype ? true +, enableFPS ? false +}: + +with lib; + +let + dfGame = versionToName dfVersion; + dwarf-fortress = if hasAttr dfGame df-games + then getAttr dfGame df-games + else throw "Unknown Dwarf Fortress version: ${dfVersion}"; + dwarf-therapist = dwarf-fortress.dwarf-therapist; +in +buildEnv { + name = "dwarf-fortress-full"; + paths = [ + (dwarf-fortress.override { + inherit enableDFHack enableTWBT enableSoundSense enableStoneSense theme + enableIntro enableTruetype enableFPS; + })] + ++ lib.optional enableDwarfTherapist dwarf-therapist + ++ lib.optional enableLegendsBrowser legends-browser; + + meta = with stdenvNoCC.lib; { + description = "An opinionated wrapper for Dwarf Fortress"; + maintainers = with maintainers; [ Baughn numinit ]; + license = licenses.mit; + platforms = platforms.all; + homepage = https://github.com/NixOS/nixpkgs/; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/legends-browser/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/legends-browser/default.nix new file mode 100644 index 000000000000..3bc4fa9c4bb5 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/legends-browser/default.nix @@ -0,0 +1,36 @@ +{ stdenvNoCC, buildEnv, writeShellScriptBin, fetchurl, jre }: + +let + name = "legends-browser-${version}"; + version = "1.17.1"; + + jar = fetchurl { + url = "https://github.com/robertjanetzko/LegendsBrowser/releases/download/${version}/legendsbrowser-${version}.jar"; + sha256 = "05b4ksbl4481rh3ykfirbp6wvxhppcd5mvclhn9995gsrcaj8gx9"; + }; + + script = writeShellScriptBin "legends-browser" '' + set -eu + BASE="$HOME/.local/share/df_linux/legends-browser/" + mkdir -p "$BASE" + cd "$BASE" + if [[ ! -e legendsbrowser.properties ]]; then + echo 'Creating initial configuration for legends-browser' + echo "last=$(cd ..; pwd)" > legendsbrowser.properties + fi + ${jre}/bin/java -jar ${jar} + ''; +in + +buildEnv { + inherit name; + paths = [ script ]; + + meta = with stdenvNoCC.lib; { + description = "A multi-platform, open source, java-based legends viewer for dwarf fortress"; + maintainers = with maintainers; [ Baughn ]; + license = licenses.mit; + platforms = platforms.all; + homepage = https://github.com/robertjanetzko/LegendsBrowser; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/soundsense.nix b/nixpkgs/pkgs/games/dwarf-fortress/soundsense.nix new file mode 100644 index 000000000000..caa9adeefd06 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/soundsense.nix @@ -0,0 +1,35 @@ +{ stdenv, fetchzip, dos2unix +, soundPack ? stdenv.mkDerivation { + name = "soundsense-soundpack"; + src = fetchzip { + url = "http://df.zweistein.cz/soundsense/soundpack.zip"; + sha256 = "0qz0mjkp7wp0gxk3ws2x760awv8c9lkacj2fn9bz3gqqnq262ffa"; + }; + installPhase = '' + cp -r . $out + ''; +}}: + +stdenv.mkDerivation rec { + version = "2016-1_196"; + dfVersion = "0.44.12"; + inherit soundPack; + name = "soundsense-${version}"; + src = fetchzip { + url = "http://df.zweistein.cz/soundsense/soundSense_${version}.zip"; + sha256 = "1gkrs69l3xsh858yjp204ddp29m668j630akm7arssc9359wxqkk"; + }; + phases = [ "unpackPhase" "buildPhase" "installPhase" ]; + nativeBuildInputs = [ dos2unix ]; + buildPhase = '' + dos2unix soundSense.sh + chmod +x soundSense.sh + ''; + installPhase = '' + mkdir $out + cp -R . $out/soundsense + ln -s $out/soundsense/dfhack $out/hack + ln -s $soundPack $out/soundsense/packs + ''; + passthru = { inherit version dfVersion; }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/themes/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/themes/default.nix new file mode 100644 index 000000000000..feb4782d7c32 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/themes/default.nix @@ -0,0 +1,19 @@ +{lib, fetchFromGitHub, ...}: + +with builtins; + +listToAttrs (map (v: { + inherit (v) name; + value = fetchFromGitHub { + name = "${v.name}-${v.version}"; + owner = "DFgraphics"; + repo = v.name; + rev = v.version; + sha256 = v.sha256; + meta = with lib; { + platforms = platforms.all; + maintainers = [ maintainers.matthewbauer ]; + license = licenses.free; + }; + }; +}) (fromJSON (readFile ./themes.json))) diff --git a/nixpkgs/pkgs/games/dwarf-fortress/themes/themes.json b/nixpkgs/pkgs/games/dwarf-fortress/themes/themes.json new file mode 100644 index 000000000000..f2cc4ed3ac7d --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/themes/themes.json @@ -0,0 +1,72 @@ +[ + { + "name": "taffer", + "version": "44.10a", + "sha256": "0gp8hmv55bp34db0caksdpd3kn2glh7sz03gyxknzdymh1cpy0qv" + }, + { + "name": "spacefox", + "version": "44.10a", + "sha256": "0ngipq1aha8cd34k4hkrfbi238gp36qpymr2f87d3nwbj2vi9hmh" + }, + { + "name": "gemset", + "version": "44.10a", + "sha256": "14q69dyqzhxsfv1a4vh17fx7r7mylfimmjrydz6ygdypblgc9zm6" + }, + { + "name": "wanderlust", + "version": "44.10", + "sha256": "016acv0ab2wj4rn9slhbf626977zas6q4372f7avaf99ihcmwi85" + }, + { + "name": "rally-ho", + "version": "44.10", + "sha256": "1pij5llnc8hfsqgyrwj1ak123wxhhk7yhlpnj033gwbpp0lnqz2x" + }, + { + "name": "phoebus", + "version": "44.10", + "sha256": "1fvl5251wzjns159snhw01p214k53vpdlyj7piv545r23q7wg2ji" + }, + { + "name": "obsidian", + "version": "44.10", + "sha256": "06lixlkprjd829zn10g5zljnxymsh81g31dj86hn2jvlch4dh98q" + }, + { + "name": "mayday", + "version": "44.10", + "sha256": "1g15ha0w93iyj5ni2pavhwrsckhnw80xvwrvw4dbp5zx1y41f3x9" + }, + { + "name": "jolly-bastion", + "version": "44.10", + "sha256": "038qvr08776rinlqa6zwb8qqxyrc75nnyyqjsasr2rf9d2f9yf8j" + }, + { + "name": "ironhand", + "version": "44.10", + "sha256": "14hngixd4gkw0lzqzlkj9ljmrxr8b3wgjk67n6zysgyi3f38f5j2" + }, + { + "name": "afro-graphics", + "version": "44.10", + "sha256": "050mrpy9q6g9y4133al7rdsj6c9hy2wva7jqmc56babvmmcpcc2j" + }, + { + "name": "cla", + "version": "44.xx-v25", + "sha256": "1h8nwa939qzqklbi8vwsq9p2brvv7sc0pbzzrdjnb221lr9p58zk" + }, + { + "name": "tergel", + "version": "44.03", + "sha256": "1kgk0cav5b6v7mca36gm84b2p556ibd8yy4rwbfc4i6i3hlsdw07" + }, + { + "name": "autoreiv", + "version": "44.03", + "sha256": "03w9dp42718p5gnswynw3p9wz85y61gkzz60jf71arw1zhf23wm0" + } +] diff --git a/nixpkgs/pkgs/games/dwarf-fortress/twbt/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/twbt/default.nix new file mode 100644 index 000000000000..7c80c1012462 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/twbt/default.nix @@ -0,0 +1,79 @@ +{ stdenvNoCC, lib, fetchurl, unzip +, dfVersion +}: + +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"; + prerelease = false; + }; + "0.44.11" = { + twbtRelease = "6.51"; + sha256 = "1yclqmarjd97ch054h425a12r8a5ailmflsd7b39cg4qhdr1nii5"; + prerelease = true; + }; + "0.44.12" = { + twbtRelease = "6.54"; + sha256 = "10gfd6vv0vk4v1r5hjbz7vf1zqys06dsad695gysc7fbcik2dakh"; + prerelease = false; + }; + }; + + release = if hasAttr dfVersion twbt-releases + then getAttr dfVersion twbt-releases + else throw "[TWBT] Unsupported Dwarf Fortress version: ${dfVersion}"; + + warning = if release.prerelease then builtins.trace "[TWBT] Version ${version} is a prerelease. Careful!" + else null; + +in + +stdenvNoCC.mkDerivation rec { + name = "twbt-${version}"; + version = release.twbtRelease; + + src = fetchurl { + url = "https://github.com/mifki/df-twbt/releases/download/v${version}/twbt-${version}-linux.zip"; + sha256 = release.sha256; + }; + + sourceRoot = "."; + + outputs = [ "lib" "art" "out" ]; + + buildInputs = [ unzip ]; + + installPhase = '' + mkdir -p $lib/hack/{plugins,lua} $art/data/art + cp -a */twbt.plug.so $lib/hack/plugins/ + cp -a *.lua $lib/hack/lua/ + cp -a *.png $art/data/art/ + ''; + + meta = with stdenvNoCC.lib; { + description = "A plugin for Dwarf Fortress / DFHack that improves various aspects the game interface."; + maintainers = with maintainers; [ Baughn numinit ]; + license = licenses.mit; + platforms = platforms.linux; + homepage = https://github.com/mifki/df-twbt; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/unfuck.nix b/nixpkgs/pkgs/games/dwarf-fortress/unfuck.nix new file mode 100644 index 000000000000..c4d01b3ff392 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/unfuck.nix @@ -0,0 +1,84 @@ +{ stdenv, lib, fetchFromGitHub, cmake +, libGL, libSM, SDL, SDL_image, SDL_ttf, glew, openalSoft +, ncurses, glib, gtk2, libsndfile, zlib +, dfVersion +}: + +with lib; + +let + unfuck-releases = { + "0.43.05" = { + unfuckRelease = "0.43.05"; + sha256 = "173dyrbxlzqvjf1j3n7vpns4gfjkpyvk9z16430xnmd5m6nda8p2"; + }; + "0.44.05" = { + unfuckRelease = "0.44.05"; + sha256 = "00yj4l4gazxg4i6fj9rwri6vm17i6bviy2mpkx0z5c0mvsr7s14b"; + }; + "0.44.09" = { + unfuckRelease = "0.44.09"; + sha256 = "138p0v8z2x47f0fk9k6g75ikw5wb3vxldwv5ggbkf4hhvlw6lvzm"; + }; + "0.44.10" = { + unfuckRelease = "0.44.10"; + sha256 = "0vb19qx2ibc79j4bgbk9lskb883qfb0815zw1dfz9k7rqwal8mzj"; + }; + "0.44.11" = { + unfuckRelease = "0.44.11.1"; + sha256 = "1kszkb1d1vll8p04ja41nangsaxb5lv4p3xh2jhmsmipfixw7nvz"; + }; + "0.44.12" = { + unfuckRelease = "0.44.12"; + sha256 = "1kszkb1d1vll8p04ja41nangsaxb5lv4p3xh2jhmsmipfixw7nvz"; + }; + }; + + release = if hasAttr dfVersion unfuck-releases + then getAttr dfVersion unfuck-releases + else throw "[unfuck] Unknown Dwarf Fortress version: ${dfVersion}"; +in + +stdenv.mkDerivation { + name = "dwarf_fortress_unfuck-${release.unfuckRelease}"; + + src = fetchFromGitHub { + owner = "svenstaro"; + repo = "dwarf_fortress_unfuck"; + rev = release.unfuckRelease; + sha256 = release.sha256; + }; + + cmakeFlags = [ + "-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include" + "-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2.out}/lib/gtk-2.0/include" + ]; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ + libSM SDL SDL_image SDL_ttf glew openalSoft + ncurses gtk2 libsndfile zlib libGL + ]; + + # Don't strip unused symbols; dfhack hooks into some of them. + dontStrip = true; + + installPhase = '' + install -D -m755 ../build/libgraphics.so $out/lib/libgraphics.so + ''; + + enableParallelBuilding = true; + + # Breaks dfhack because of inlining. + hardeningDisable = [ "fortify" ]; + + passthru = { inherit dfVersion; }; + + meta = with stdenv.lib; { + description = "Unfucked multimedia layer for Dwarf Fortress"; + homepage = https://github.com/svenstaro/dwarf_fortress_unfuck; + license = licenses.free; + platforms = platforms.linux; + maintainers = with maintainers; [ abbradar numinit ]; + }; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/update.sh b/nixpkgs/pkgs/games/dwarf-fortress/update.sh new file mode 100755 index 000000000000..3db68122d358 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/update.sh @@ -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" diff --git a/nixpkgs/pkgs/games/dwarf-fortress/wrapper/default.nix b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/default.nix new file mode 100644 index 000000000000..8672de3af84f --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/default.nix @@ -0,0 +1,116 @@ +{ stdenv, lib, buildEnv, substituteAll, runCommand +, dwarf-fortress, dwarf-fortress-unfuck +, dwarf-therapist +, enableDFHack ? false, dfhack +, enableSoundSense ? false, soundSense, jdk +, enableStoneSense ? false +, enableTWBT ? false, twbt +, themes ? {} +, theme ? null +# General config options: +, enableIntro ? true +, enableTruetype ? true +, enableFPS ? false +}: + +let + dfhack_ = dfhack.override { + inherit enableStoneSense; + inherit enableTWBT; + }; + + ptheme = + if builtins.isString theme + then builtins.getAttr theme themes + else theme; + + unBool = b: if b then "YES" else "NO"; + + # 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 ]; + + fixup = lib.singleton (runCommand "fixup" {} ('' + 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 '' + mkdir -p $out/hack + + # Patch the MD5 + orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig") + patched_md5=$(cat "${dwarf-fortress}/hash.md5") + input_file="${dfhack_}/hack/symbols.xml" + output_file="$out/hack/symbols.xml" + + echo "[DFHack Wrapper] Fixing Dwarf Fortress MD5:" + echo " Input: $input_file" + echo " Search: $orig_md5" + echo " Output: $output_file" + 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]' + '' + '' + substituteInPlace $out/data/init/init.txt \ + --replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \ + --replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \ + --replace '[FPS:NO]' '[FPS:${unBool enableFPS}]' + '')); + + env = buildEnv { + name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}"; + + paths = fixup ++ themePkg ++ pkgs; + pathsToLink = [ "/" "/hack" "/hack/scripts" ]; + + ignoreCollisions = true; + }; +in + +stdenv.mkDerivation rec { + name = "dwarf-fortress-${dwarf-fortress.dfVersion}"; + + dfInit = substituteAll { + name = "dwarf-fortress-init"; + src = ./dwarf-fortress-init.in; + inherit env; + exe = if stdenv.isLinux then "libs/Dwarf_Fortress" + else "dwarfort.exe"; + }; + + runDF = ./dwarf-fortress.in; + runDFHack = ./dfhack.in; + runSoundSense = ./soundSense.in; + + passthru = { inherit dwarf-fortress dwarf-therapist; }; + + 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 + '' + lib.optionalString enableSoundSense '' + substitute $runSoundSense $out/bin/soundsense \ + --subst-var-by stdenv_shell ${stdenv.shell} \ + --subst-var-by jre ${jdk.jre} \ + --subst-var dfInit + chmod 755 $out/bin/soundsense + ''; + + preferLocalBuild = true; +} diff --git a/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dfhack.in b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dfhack.in new file mode 100644 index 000000000000..4cf884ebed2c --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dfhack.in @@ -0,0 +1,11 @@ +#!@stdenv_shell@ -e + +source @dfInit@ + +for i in dfhack.init-example dfhack-config/default hack/* stonesense/*; 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:$LD_PRELOAD" exec $env_dir/libs/Dwarf_Fortress "$@" diff --git a/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in new file mode 100644 index 000000000000..054935af012e --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in @@ -0,0 +1,44 @@ +shopt -s extglob + +[ -z "$DF_DIR" ] && DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux" +env_dir="@env@" +exe="$env_dir/@exe@" + +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 +forcecopy_path data/help +forcecopy_path data/dipscript diff --git a/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in new file mode 100644 index 000000000000..4448bd05fda5 --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in @@ -0,0 +1,9 @@ +#!@stdenv_shell@ -e + +source @dfInit@ + +export DYLD_LIBRARY_PATH="$env_dir/libs" +export DYLD_FRAMEWORK_PATH="$env_dir/libs" + +cd "$DF_DIR" +exec "$exe" "$@" diff --git a/nixpkgs/pkgs/games/dwarf-fortress/wrapper/soundSense.in b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/soundSense.in new file mode 100644 index 000000000000..28357ed7579f --- /dev/null +++ b/nixpkgs/pkgs/games/dwarf-fortress/wrapper/soundSense.in @@ -0,0 +1,10 @@ +#!@stdenv_shell@ -e + +source @dfInit@ + +for p in soundsense/*; do + update_path "$p" +done + +cd "$DF_DIR" +PATH=@jre@/bin exec $DF_DIR/soundsense/soundSense.sh |