about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorMorgan Jones <me@numin.it>2018-07-15 05:38:30 +0000
committerMorgan Jones <me@numin.it>2018-09-09 06:59:58 +0000
commit7a5521537a1715ac7f7f5e420cef865304383b82 (patch)
treefec3baaf58fc5a31626a6ea6c3f5f5b487c9baf6 /pkgs
parentf14d3b4795c173f5ff353031b8d32afab7090ab9 (diff)
downloadnixlib-7a5521537a1715ac7f7f5e420cef865304383b82.tar
nixlib-7a5521537a1715ac7f7f5e420cef865304383b82.tar.gz
nixlib-7a5521537a1715ac7f7f5e420cef865304383b82.tar.bz2
nixlib-7a5521537a1715ac7f7f5e420cef865304383b82.tar.lz
nixlib-7a5521537a1715ac7f7f5e420cef865304383b82.tar.xz
nixlib-7a5521537a1715ac7f7f5e420cef865304383b82.tar.zst
nixlib-7a5521537a1715ac7f7f5e420cef865304383b82.zip
Let the user override dfVersion in dwarf-fortress-full
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/games/dwarf-fortress/default.nix47
-rw-r--r--pkgs/games/dwarf-fortress/lazy-pack.nix17
2 files changed, 50 insertions, 14 deletions
diff --git a/pkgs/games/dwarf-fortress/default.nix b/pkgs/games/dwarf-fortress/default.nix
index 87bcc44b8156..1ee33fb27f36 100644
--- a/pkgs/games/dwarf-fortress/default.nix
+++ b/pkgs/games/dwarf-fortress/default.nix
@@ -6,26 +6,48 @@
 #
 # 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 ];`
+#
+# 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. Take a look at lazy-pack.nix to get an idea of
-# how.
+# 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.
-#
-# Although both dfhack and dwarf therapist are included in the lazy pack, you
-# can only use one at a time. DFHack does have therapist-like features, so this
-# may or may not be a problem.
+
+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 = "dwarf-fortress_${lib.replaceStrings ["."] ["_"] dfVersion}"; 
+    name = versionToName dfVersion;
     value =
       let
         # I can't believe this syntax works. Spikes of Nix code indeed...
@@ -59,9 +81,14 @@ let
 
   self = rec {
     df-hashes = builtins.fromJSON (builtins.readFile ./game.json);
-    dwarf-fortress = df-games.dwarf-fortress_0_44_12;
+    
+    dwarf-fortress = getAttr (versionToName latestVersion) df-games;
 
-    dwarf-fortress-full = callPackage ./lazy-pack.nix { };
+    dwarf-fortress-full = callPackage ./lazy-pack.nix {
+      inherit versionToName;
+      inherit latestVersion;
+      inherit df-games;
+    };
 
     soundSense = callPackage ./soundsense.nix { };
 
diff --git a/pkgs/games/dwarf-fortress/lazy-pack.nix b/pkgs/games/dwarf-fortress/lazy-pack.nix
index ca7ae4024289..a05ea49ce814 100644
--- a/pkgs/games/dwarf-fortress/lazy-pack.nix
+++ b/pkgs/games/dwarf-fortress/lazy-pack.nix
@@ -1,8 +1,9 @@
-{ stdenvNoCC, lib, buildEnv
-, dwarf-fortress, themes
+{ 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.
+  # should contain every utility available unless you disable them.
 , enableDFHack ? stdenvNoCC.isLinux
 , enableTWBT ? enableDFHack
 , enableSoundSense ? true
@@ -16,6 +17,14 @@
 , 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}";
+in
 buildEnv {
   name = "dwarf-fortress-full";
   paths = [
@@ -28,7 +37,7 @@ buildEnv {
 
   meta = with stdenvNoCC.lib; {
     description = "An opinionated wrapper for Dwarf Fortress";
-    maintainers = with maintainers; [ Baughn ];
+    maintainers = with maintainers; [ Baughn numinit ];
     license = licenses.mit;
     platforms = platforms.all;
     homepage = https://github.com/NixOS/nixpkgs/;