about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2020-05-08T03·48-0400
committerGriffin Smith <root@gws.fyi>2020-05-08T03·48-0400
commit7266a417076eb7e69c8f4f235c640608ed8c624d (patch)
tree6d879f9e37bbf80e0f2abe62d8ea0b044233e3ac
parent2e03eba922649afc57561d952c83b5182693a793 (diff)
Properly configured dwarf fortress
The dwarf fortress packages built into nixpkgs are a little silly and a
lot overbearing - do a bunch of hacky substitution to pound them into
submission so that I can actually configure stuff like SHOW_FLOW_AMOUNTS
and AUTOSAVE, which I feel like I need.
-rw-r--r--home/home.nix8
-rw-r--r--home/modules/games.nix46
-rw-r--r--home/modules/games/dwarf-fortress.nix39
3 files changed, 86 insertions, 7 deletions
diff --git a/home/home.nix b/home/home.nix
index 95096425653c..213560b095f8 100644
--- a/home/home.nix
+++ b/home/home.nix
@@ -9,6 +9,7 @@ let machine = ./machines/chupacabra.nix; in
     ./modules/emacs.nix
     ./modules/email.nix
     ./modules/firefox.nix
+    ./modules/games.nix
     ./modules/i3.nix
     ./modules/shell.nix
     ./modules/tarsnap.nix
@@ -77,13 +78,6 @@ let machine = ./machines/chupacabra.nix; in
     spotify
     playerctl
 
-    # games
-    crawl
-    (dwarf-fortress-packages.dwarf-fortress-full.override {
-      enableIntro = false;
-      enableFPS = true;
-    })
-
     # Nix things
     nix-prefetch-github
   ];
diff --git a/home/modules/games.nix b/home/modules/games.nix
new file mode 100644
index 000000000000..14b2d1b4b325
--- /dev/null
+++ b/home/modules/games.nix
@@ -0,0 +1,46 @@
+{ config, lib, pkgs, ... }:
+
+with pkgs;
+
+let
+
+  df-orig = dwarf-fortress-packages.dwarf-fortress-original;
+
+  df-full = (dwarf-fortress-packages.dwarf-fortress-full.override {
+    theme = null;
+    enableIntro = false;
+    enableFPS = true;
+  });
+
+  init = runCommand "init.txt" {} ''
+    substitute "${df-orig}/data/init/init.txt" $out \
+      --replace "[INTRO:YES]" "[INTRO:NO]" \
+      --replace "[VOLUME:255]" "[VOLUME:0]" \
+      --replace "[FPS:NO]" "[FPS:YES]"
+  '';
+
+  d_init = runCommand "d_init.txt" {} ''
+    substitute "${df-orig}/data/init/d_init.txt" $out \
+      --replace "[AUTOSAVE:NONE]" "[AUTOSAVE:SEASONAL]" \
+      --replace "[AUTOSAVE_PAUSE:NO]" "[AUTOSAVE_PAUSE:YES]" \
+      --replace "[INITIAL_SAVE:NO]" "[INITIAL_SAVE:YES]" \
+      --replace "[EMBARK_WARNING_ALWAYS:NO]" "[EMBARK_WARNING_ALWAYS:YES]" \
+      --replace "[VARIED_GROUND_TILES:YES]" "[VARIED_GROUND_TILES:NO]" \
+      --replace "[SHOW_FLOW_AMOUNTS:NO]" "[SHOW_FLOW_AMOUNTS:YES]"
+  '';
+
+  df = runCommand "dwarf-fortress" {} ''
+     mkdir -p $out/bin
+     sed \
+       -e '4icp -f ${init} "$DF_DIR/data/init/init.txt"' \
+       -e '4icp -f ${d_init} "$DF_DIR/data/init/d_init.txt"' \
+       < "${df-full}/bin/dwarf-fortress" >"$out/bin/dwarf-fortress"
+     chmod +x $out/bin/dwarf-fortress
+  '';
+
+in {
+  home.packages = [
+    crawl
+    df
+  ];
+}
diff --git a/home/modules/games/dwarf-fortress.nix b/home/modules/games/dwarf-fortress.nix
new file mode 100644
index 000000000000..8db61456605a
--- /dev/null
+++ b/home/modules/games/dwarf-fortress.nix
@@ -0,0 +1,39 @@
+{ pkgs ? import <nixpkgs> {}, ... }:
+
+with pkgs;
+
+rec {
+  df-orig = dwarf-fortress-packages.dwarf-fortress-original;
+
+  df-full = (dwarf-fortress-packages.dwarf-fortress-full.override {
+    theme = null;
+    enableIntro = false;
+    enableFPS = true;
+  });
+
+  init = runCommand "init.txt" {} ''
+    substitute "${df-orig}/data/init/init.txt" $out \
+      --replace "[INTRO:YES]" "[INTRO:NO]" \
+      --replace "[VOLUME:255]" "[VOLUME:0]" \
+      --replace "[FPS:NO]" "[FPS:YES]"
+  '';
+
+  d_init = runCommand "d_init.txt" {} ''
+    substitute "${df-orig}/data/init/d_init.txt" $out \
+      --replace "[AUTOSAVE:NONE]" "[AUTOSAVE:SEASONAL]" \
+      --replace "[AUTOSAVE_PAUSE:NO]" "[AUTOSAVE_PAUSE:YES]" \
+      --replace "[INITIAL_SAVE:NO]" "[INITIAL_SAVE:YES]" \
+      --replace "[EMBARK_WARNING_ALWAYS:NO]" "[EMBARK_WARNING_ALWAYS:YES]" \
+      --replace "[VARIED_GROUND_TILES:YES]" "[VARIED_GROUND_TILES:NO]" \
+      --replace "[SHOW_FLOW_AMOUNTS:NO]" "[SHOW_FLOW_AMOUNTS:YES]"
+  '';
+
+  df = runCommand "dwarf-fortress" {} ''
+     mkdir -p $out/bin
+     sed \
+       -e '2icp -f ${init} "$DF_DIR/data/init/init.txt"' \
+       -e '3icp -f ${d_init} "$DF_DIR/data/init/d_init.txt"' \
+       < "${df-full}/bin/dwarf-fortress" >"$out/bin/dwarf-fortress"
+  '';
+
+}