aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-21 06:05:12 +0100
committerMx Kookie <kookie@spacekookie.de>2020-12-21 06:05:12 +0100
commitf107be784e6d5da5f90735765a68fdff96acfbb4 (patch)
tree145573a598009fb6adbd5ef7fbce0a850681f5f0 /infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress
parent2e04b35e5ac3a9123cafffbc84494fa4d389cca0 (diff)
parente9158eca70ae59e73fae23be5d13d3fa0cfc78b4 (diff)
Add 'infra/libkookie/nixpkgs/' from commit 'e9158eca70ae59e73fae23be5d13d3fa0cfc78b4'
git-subtree-dir: infra/libkookie/nixpkgs git-subtree-mainline: 2e04b35e5ac3a9123cafffbc84494fa4d389cca0 git-subtree-split: e9158eca70ae59e73fae23be5d13d3fa0cfc78b4
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/default.nix122
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/df_permission40
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dfhack/default.nix167
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch23
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix30
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in26
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix50
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/game.json125
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/game.nix101
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/lazy-pack.nix48
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/legends-browser/default.nix36
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/soundsense.nix35
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/default.nix19
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/themes.json87
-rwxr-xr-xinfra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/update.sh8
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/twbt/default.nix90
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/unfuck.nix96
-rwxr-xr-xinfra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/update.sh42
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/default.nix123
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dfhack.in11
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in44
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in9
-rw-r--r--infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/soundSense.in10
23 files changed, 1342 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/default.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/default.nix
new file mode 100644
index 000000000000..2a4df9bf7cf7
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/default.nix
@@ -0,0 +1,122 @@
+{ 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.47.04";
+
+ # Converts a version to a package name.
+ versionToName = version: "dwarf-fortress_${lib.replaceStrings ["."] ["_"] version}";
+
+ dwarf-therapist-original = pkgs.qt5.callPackage ./dwarf-therapist {
+ texlive = pkgs.texlive.combine {
+ inherit (pkgs.texlive) scheme-basic float caption wrapfig adjmulticol sidecap preprint enumitem;
+ };
+ };
+
+ # 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 = dwarf-therapist-original;
+ };
+ in
+ callPackage ./wrapper {
+ inherit (self) themes;
+
+ dwarf-fortress = dwarf-fortress;
+ twbt = twbt;
+ dfhack = dfhack;
+ dwarf-therapist = dwarf-therapist;
+
+ jdk = pkgs.jdk8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
+ };
+ }) (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;
+ inherit dwarf-therapist-original;
+ 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 {
+ jre = pkgs.jre8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
+ };
+
+ themes = recurseIntoAttrs (callPackage ./themes {
+ stdenv = stdenvNoCC;
+ });
+
+ # Theme aliases
+ phoebus-theme = themes.phoebus;
+ cla-theme = themes.cla;
+ };
+
+in self // df-games
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/df_permission b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/df_permission
new file mode 100644
index 000000000000..dc1c0c151e0b
--- /dev/null
+++ b/infra/libkookie/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
+> <https://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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dfhack/default.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dfhack/default.nix
new file mode 100644
index 000000000000..11c21b82c29c
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dfhack/default.nix
@@ -0,0 +1,167 @@
+{ stdenv, buildEnv, lib, fetchFromGitHub, cmake, writeScriptBin
+, perl, XMLLibXML, XMLLibXSLT, zlib, ruby
+, enableStoneSense ? false, allegro5, libGLU, libGL
+, 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;
+ };
+ "0.47.02" = {
+ dfHackRelease = "0.47.02-alpha0";
+ sha256 = "19lgykgqm0si9vd9hx4zw8b5m9188gg8r1a6h25np2m2ziqwbjj9";
+ xmlRev = "23500e4e9bd1885365d0a2ef1746c321c1dd509a";
+ prerelease = true;
+ };
+ "0.47.04" = {
+ dfHackRelease = "0.47.04-r2";
+ sha256 = "18ppn1dqaxi6ahjzsvb9kw70rvca106a1hibhzc4rxmraypnqb89";
+ xmlRev = "036b662a1bbc96b4911f3cbe74dfa1243b6459bc";
+ prerelease = false;
+ };
+ };
+
+ release = if hasAttr dfVersion dfhack-releases
+ then getAttr dfVersion dfhack-releases
+ else throw "[DFHack] Unsupported Dwarf Fortress version: ${dfVersion}";
+
+ version = release.dfHackRelease;
+
+ # 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 {
+ pname = "dfhack-base";
+ inherit version;
+
+ # Beware of submodules
+ src = fetchFromGitHub {
+ owner = "DFHack";
+ repo = "dfhack";
+ rev = release.dfHackRelease;
+ sha256 = release.sha256;
+ fetchSubmodules = true;
+ };
+
+ patches = [ ./fix-stonesense.patch ];
+
+ # As of
+ # https://github.com/DFHack/dfhack/commit/56e43a0dde023c5a4595a22b29d800153b31e3c4,
+ # dfhack gets its goodies from the directory above the Dwarf_Fortress
+ # executable, which leads to stock Dwarf Fortress and not the built
+ # environment where all the dfhack resources are symlinked to (typically
+ # ~/.local/share/df_linux). This causes errors like `tweak is not a
+ # recognized command` to be reported and dfhack to lose some of its
+ # functionality.
+ postPatch = ''
+ sed -i 's@cached_path = path_string.*@cached_path = getenv("DF_DIR");@' library/Process-linux.cpp
+ '';
+
+ 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 libGL ];
+
+ 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:+:}$LD_LIBRARY_PATH"
+ '';
+
+ cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" "-DDOWNLOAD_RUBY=OFF" ]
+ ++ lib.optionals enableStoneSense [ "-DBUILD_STONESENSE=ON" "-DSTONESENSE_INTERNAL_SO=OFF" ];
+
+ # dfhack expects an unversioned libruby.so to be present in the hack
+ # subdirectory for ruby plugins to function.
+ postInstall = ''
+ ln -s ${ruby}/lib/libruby-*.so $out/hack/libruby.so
+ '';
+
+ 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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dfhack/fix-stonesense.patch
new file mode 100644
index 000000000000..da860cd55624
--- /dev/null
+++ b/infra/libkookie/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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix
new file mode 100644
index 000000000000..f5c093e1f16c
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, qtbase
+, qtdeclarative, cmake, texlive, ninja }:
+
+stdenv.mkDerivation rec {
+ pname = "dwarf-therapist";
+ version = "41.1.5";
+
+ src = fetchFromGitHub {
+ owner = "Dwarf-Therapist";
+ repo = "Dwarf-Therapist";
+ rev = "v${version}";
+ sha256 = "0w1mwwf49vdmvmdfvlkn4m0hzvlj111rpl8hv4rw6v8nv6yfb2y4";
+ };
+
+ nativeBuildInputs = [ texlive cmake ninja ];
+ buildInputs = [ qtbase qtdeclarative ];
+
+ 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; [ abbradar bendlas numinit jonringer ];
+ license = licenses.mit;
+ platforms = platforms.unix;
+ homepage = "https://github.com/Dwarf-Therapist/Dwarf-Therapist";
+ };
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/dwarf-therapist.in
new file mode 100644
index 000000000000..77936c430e2b
--- /dev/null
+++ b/infra/libkookie/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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix
new file mode 100644
index 000000000000..6871a611784c
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/dwarf-therapist/wrapper.nix
@@ -0,0 +1,50 @@
+{ pkgs, stdenv, 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 {
+ 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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/game.json b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/game.json
new file mode 100644
index 000000000000..f5f1f389904f
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/game.json
@@ -0,0 +1,125 @@
+{
+ "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"
+ },
+ "0.47.01": {
+ "linux": "1wbybkfpgvpd2yliy8mfgddnz806ac4rv4j0lhlsqwpk8jj0mx81",
+ "linux32": "1fnz1mydqgybcm8kzranvjzc2x9g6bcalxv3fsjngvpv13x6izzv",
+ "osx": "18wdffidasbrsbhqjwds08ckbrjhcw0759aynz7zggyy5is9q8iw",
+ "osx32": "1b4kf3vg0zd5w5s0rdhzfz0rswkl6sq0j1f8qmimnw7qd09h43wx",
+ "win": "1v3v2z7g67d6926h9lxakznvbddyxyr85i1ym34y2wywnc886z7r",
+ "win_s": "0yahynimhz4nvdi5qp5a612vf7ikg87w2aj2r8s1lhdw6xwdkpyc",
+ "win32": "07mqhm64c1ddjc3vpyhf9qf14lp19xwz3pgg4c2pvcwy4yyrys22",
+ "win32_s": "07acbxai8g04yxg7n68nyx4jwcqqkgjn7n96q2lzxdvc988kiivz",
+ "legacy32_s": "1gxmc3rsl9glai3wb4wzsda3qyhdimd8s5kbr5m753n8lmzasafx"
+ },
+ "0.47.02": {
+ "linux": "1zbsygbfiqxxs767qxkxjp3ayywi5q0d8xlrqlbd0l8a3ccg5avw",
+ "linux32": "1ddc9s4n408j8gidgign51bgv2wgy5z4cy74jzx00pvnhsfp2mpy",
+ "osx": "1mwy88yxip1wys1kxpfsbg7wlvfrkc4lg04gqw0d266a88dj7a30",
+ "osx32": "08ssnzl52gqqgcqhl0ynyikbxz76825kpcg1d6yx8g7ifjndf19n",
+ "win": "08g7fy18y8q32l0158314bny0qg57xz37qj9fri9r4xbhci67ldk",
+ "win_s": "0x56s1md62yk661aqcdgnz8k0zir0zr8qwan5vrqc0q9yh069yl1",
+ "win32": "0ww64mymbilb235n93d7w4c9axq3ww2mxa0f7bl4x8yrxwc8k942",
+ "win32_s": "0r801vip807v88icf47i3s82v7lshx67q4ilzfjirqfslh1x00bs",
+ "legacy": "14f4d6r7swfjnlaalg4l5916ihj6wvhlsgjp7cygamzp4c2wgng8",
+ "legacy_s": "1jxf52kaijf4crwxj30a4f6z7rzs6xa91y6vn5s8jr0cvbr5pz64",
+ "legacy32": "0j7shqdv3gimacj03cil2y0fmr0j0fp57cwmdjwnxwx3m96k3xwm",
+ "legacy32_s": "1wc7pcp9dwz0q1na3i5pbqknya595qdkmr7hsmgh2kk8rsp3g9g2"
+ },
+ "0.47.04": {
+ "linux": "1ri82c5hja6n0wv538srf2nbcyb8ip49w4l201m90cmcycmqgr8x",
+ "linux32": "00yz8gl75sbx15d7vl22ij0a5qd325kpc9mgm1lh5g7i065vgzn8",
+ "osx": "0c1g655bn5n4pbzxw3v83gmy54va5y87m7ksi6iryfal0m9lshhv",
+ "osx32": "1knfgqbwa7v9va1w6i8yzz6xp3dj633dbs50izx6ldszm0ra42pg",
+ "win": "0j7ixr3rf9900zzfw3nd3vg97kdkspm530cmf9dkwhf6klmpks7s",
+ "win_s": "11amw5gjhi753mvf17wifcjiyikjx0qwa16787gfhj9jfp0yw764",
+ "win32": "1xw9f49n85c31kbzkm5zh81kccjx9msjyy3xwr0klak5w398a59l",
+ "win32_s": "0s26hrgfk2b5wg4dvg90wgw1mvrrvbyjhmsys9f5fl7zn1pjbxxr",
+ "legacy": "103bcnn8gxi2rkpjmjfgv5a5kxmh1zd7vagrsscv55sppd7fcl7n",
+ "legacy_s": "19ai7lvxx0y3iha9qrbl5krric547rzs6vm4ibk8x61vv97jrbd8",
+ "legacy32": "0lli6s1g7yj3p3h26ajgq3h619n88qn6s7amyz6z8w7hyzfi7wij",
+ "legacy32_s": "1wzxbzgln9pmsk2nchrl94d2yd09xdgynmjl4qwcaqzkrnf3sfqc"
+ }
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/game.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/game.nix
new file mode 100644
index 000000000000..9200d01aa985
--- /dev/null
+++ b/infra/libkookie/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 = splitVersion 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 abbradar numinit shazow ];
+ };
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/lazy-pack.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/lazy-pack.nix
new file mode 100644
index 000000000000..03aa5d54304f
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/lazy-pack.nix
@@ -0,0 +1,48 @@
+{ stdenvNoCC, lib, buildEnv
+, 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
+, enableTextMode ? false
+, enableSound ? true
+}:
+
+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 enableTextMode enableSound;
+ })]
+ ++ 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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/legends-browser/default.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/legends-browser/default.nix
new file mode 100644
index 000000000000..b11060025151
--- /dev/null
+++ b/infra/libkookie/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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/soundsense.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/soundsense.nix
new file mode 100644
index 000000000000..a59c87306903
--- /dev/null
+++ b/infra/libkookie/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;
+ pname = "soundsense";
+ 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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/default.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/default.nix
new file mode 100644
index 000000000000..6241df7590d9
--- /dev/null
+++ b/infra/libkookie/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 maintainers.shazow ];
+ license = licenses.free;
+ };
+ };
+}) (fromJSON (readFile ./themes.json)))
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/themes.json b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/themes.json
new file mode 100644
index 000000000000..8b0b9127d5b1
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/themes.json
@@ -0,0 +1,87 @@
+[
+ {
+ "name": "afro-graphics",
+ "version": "47.04",
+ "sha256": "1x1ir0qi3g8wgzwm1pnrkrqb6lhnjq87vs30l8kva6y5wr4sz7q0"
+ },
+ {
+ "name": "autoreiv",
+ "version": "47.01",
+ "sha256": "1c2xchlfq7ajpcq8qgrzkw5yfgm0k3fiwq6n7l4724dlbim3rjp2"
+ },
+ {
+ "name": "cla",
+ "version": "0.47.xx-v26.3",
+ "sha256": "0ca81r3821jja4pqib75qxcsgg3s0wxzyq1jb4jc0495cvzxw7qa"
+ },
+ {
+ "name": "dfgraphics",
+ "version": "42.05",
+ "sha256": "18xyqn458hh8l2qgbvrvz17nbp6yk91d7rqlxlp1g5wr9qfq28rp"
+ },
+ {
+ "name": "gemset",
+ "version": "47.04",
+ "sha256": "015nkkdnpykhz6a1n8qi3wgap19a4wavz4n2xbvfa4g770lcjd92"
+ },
+ {
+ "name": "ironhand",
+ "version": "47.04",
+ "sha256": "0x3hi1isgc2cv7c3qz87rm7ik0kbd748djpnghvjdqpj3a0n1ih2"
+ },
+ {
+ "name": "jolly-bastion",
+ "version": "47.04",
+ "sha256": "0799ad90g62nvpdcl6zq3vr2nvfc62lprm4br9n2hbs8wgrra6rq"
+ },
+ {
+ "name": "mayday",
+ "version": "47.04a",
+ "sha256": "1hpj40762n81grsddg3nc5jxc0bqmy2xamxvsgxzb2bx0b7akz0w"
+ },
+ {
+ "name": "meph",
+ "version": "47.04_v5.5.0_V1.1.2",
+ "sha256": "0q8hfm66rag61qd2hab7lsr4nyg52bn1hvy6bl7z6kv4yj5cra50"
+ },
+ {
+ "name": "obsidian",
+ "version": "47.04a",
+ "sha256": "0y5kmj362i9y8w1n5d1nx80yq88c0xqps9i02gvnls6r421a4nms"
+ },
+ {
+ "name": "phoebus",
+ "version": "47.04a",
+ "sha256": "1ihbqs5a3b8pydbcynblvgw2bxkgr9hhpmgjlji7a7zvz8m6h6pw"
+ },
+ {
+ "name": "rally-ho",
+ "version": "47.04",
+ "sha256": "0pmvpfbj07ll674lw7mjgkb4kgjk4mxr82fjq4ppvwrnzx6vi2g0"
+ },
+ {
+ "name": "spacefox",
+ "version": "47.04",
+ "sha256": "0sk3k5bcpfl2xind4vfrgzbcqqbw0mg47pm3d3h44vi6hl3bdaqj"
+ },
+ {
+ "name": "taffer",
+ "version": "47.04",
+ "sha256": "1ly2sc0pb2kybb8grj19zx372whblmd0bj8p64akpi2rrywi13sy"
+ },
+ {
+ "name": "tergel",
+ "version": "47.01",
+ "sha256": "142sd1i11vvirn68rp4gqzl67ww597df1lc57ycnpnz0n3q39kxy"
+ },
+ {
+ "name": "vettlingr",
+ "version": "1.4a",
+ "sha256": "1p4y0dm52rb49dnmcnivddlsd94m4gr1pxn04fpjbrvck22klgpj"
+ },
+ {
+ "name": "wanderlust",
+ "version": "47.04",
+ "sha256": "1z56m8zplq5d18sbkwg5lwcy8iwfa5hbxixsm3hdxm04qyld1z89"
+ }
+]
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/update.sh b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/update.sh
new file mode 100755
index 000000000000..1b652bf49943
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/themes/update.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash -p jq nix coreutils curl nix-prefetch-git
+
+curl "https://api.github.com/users/dfgraphics/repos" | jq -r '.[].name | ascii_downcase' | while read repo; do
+ version="$(curl "https://api.github.com/repos/DFgraphics/${repo}/releases/latest" | jq -r .tag_name)"
+ sha256="$(nix-prefetch-git "https://github.com/DFgraphics/${repo}" "${version}" | jq -r ".sha256")"
+ echo "{}" | jq ".name=\"${repo}\" | .version=\"${version}\" | .sha256=\"${sha256}\""
+done | jq -s . > themes.json
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/twbt/default.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/twbt/default.nix
new file mode 100644
index 000000000000..a0990e04f93a
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/twbt/default.nix
@@ -0,0 +1,90 @@
+{ 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;
+ };
+ "0.47.02" = {
+ twbtRelease = "6.61";
+ sha256 = "07bqy9rkd64h033sxdpigp5zq4xrr0xd36wdr1b21g649mv8j6yw";
+ prerelease = false;
+ };
+ "0.47.04" = {
+ twbtRelease = "6.xx";
+ dfhackRelease = "0.47.04-r2";
+ sha256 = "092dgp8fh1j4nqr9wbzn89ib1nhscclr8m91lfxsvg0mgn7j8xlv";
+ prerelease = true;
+ };
+ };
+
+ release = if hasAttr dfVersion twbt-releases
+ then getAttr dfVersion twbt-releases
+ else throw "[TWBT] Unsupported Dwarf Fortress version: ${dfVersion}";
+in
+
+stdenvNoCC.mkDerivation rec {
+ pname = "twbt";
+ version = release.twbtRelease;
+
+ src = fetchurl {
+ url =
+ if version == "6.xx" then
+ "https://github.com/thurin/df-twbt/releases/download/${release.dfhackRelease}/twbt-${version}-linux64-${release.dfhackRelease}.zip"
+ else
+ "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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/unfuck.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/unfuck.nix
new file mode 100644
index 000000000000..533649131f5a
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/unfuck.nix
@@ -0,0 +1,96 @@
+{ stdenv, lib, fetchFromGitHub, cmake
+, libGL, libSM, SDL, SDL_image, SDL_ttf, glew, openalSoft
+, ncurses, glib, gtk2, libsndfile, zlib
+, dfVersion, pkg-config
+}:
+
+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";
+ };
+ "0.47.01" = {
+ unfuckRelease = "0.47.01";
+ sha256 = "11xvb3qh4crdf59pwfwpi73rzm3ysd1r1xp2k1jp7527jmqapk4k";
+ };
+ "0.47.02" = {
+ unfuckRelease = "0.47.01";
+ sha256 = "11xvb3qh4crdf59pwfwpi73rzm3ysd1r1xp2k1jp7527jmqapk4k";
+ };
+ "0.47.04" = {
+ unfuckRelease = "0.47.04";
+ sha256 = "1wa990xbsyiiz7abq153xmafvvk1dmgz33rp907d005kzl1z86i9";
+ };
+ };
+
+ 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 pkg-config ];
+ 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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/update.sh b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/update.sh
new file mode 100755
index 000000000000..e36badc4199e
--- /dev/null
+++ b/infra/libkookie/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 'DWARF FORTRESS CLASSIC ' \
+ | sed 's/.*DWARF FORTRESS CLASSIC \([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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/default.nix b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/default.nix
new file mode 100644
index 000000000000..79b63e3ce9ee
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/default.nix
@@ -0,0 +1,123 @@
+{ stdenv, lib, buildEnv, substituteAll, runCommand
+, dwarf-fortress
+, 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
+, enableTextMode ? false
+, enableSound ? true
+}:
+
+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]'
+ '' +
+ 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}]'
+ ''));
+
+ env = buildEnv {
+ name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}";
+
+ paths = fixup ++ themePkg ++ pkgs;
+ pathsToLink = [ "/" "/hack" "/hack/scripts" ];
+
+ ignoreCollisions = true;
+ };
+in
+
+stdenv.mkDerivation {
+ 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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dfhack.in b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dfhack.in
new file mode 100644
index 000000000000..026b33ab87bf
--- /dev/null
+++ b/infra/libkookie/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_LIBRARY_PATH" \
+ LD_PRELOAD="$env_dir/hack/libdfhack.so:$LD_PRELOAD" exec $env_dir/libs/Dwarf_Fortress "$@"
diff --git a/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in
new file mode 100644
index 000000000000..b041067d89e4
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in
@@ -0,0 +1,44 @@
+shopt -s extglob
+
+[ -z "$DF_DIR" ] && export 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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in
new file mode 100644
index 000000000000..4448bd05fda5
--- /dev/null
+++ b/infra/libkookie/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/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/soundSense.in b/infra/libkookie/nixpkgs/pkgs/games/dwarf-fortress/wrapper/soundSense.in
new file mode 100644
index 000000000000..28357ed7579f
--- /dev/null
+++ b/infra/libkookie/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