From b0c7245ee5ea9a93b9bdd2896c90fe822edb0596 Mon Sep 17 00:00:00 2001 From: Svein Ove Aas Date: Thu, 5 Jul 2018 20:09:03 +0100 Subject: [PATCH] dwarf-fortress: Add "lazy pack", config flags and some comments. --- pkgs/games/dwarf-fortress/default.nix | 27 ++++++++++++-- pkgs/games/dwarf-fortress/lazy-pack.nix | 36 +++++++++++++++++++ pkgs/games/dwarf-fortress/twbt/default.nix | 6 ++-- pkgs/games/dwarf-fortress/wrapper/default.nix | 19 +++++++++- 4 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 pkgs/games/dwarf-fortress/lazy-pack.nix diff --git a/pkgs/games/dwarf-fortress/default.nix b/pkgs/games/dwarf-fortress/default.nix index f0dd7f08020..bfb22aa3a3d 100644 --- a/pkgs/games/dwarf-fortress/default.nix +++ b/pkgs/games/dwarf-fortress/default.nix @@ -1,9 +1,32 @@ -{ pkgs, stdenv, stdenvNoCC, gccStdenv }: +{ pkgs, stdenv, stdenvNoCC, buildEnv, gccStdenv }: + +# 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.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. +# +# 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. let callPackage = pkgs.newScope self; self = rec { + + dwarf-fortress-full = callPackage ./lazy-pack.nix { }; + dwarf-fortress-original = callPackage ./game.nix { }; dfhack = callPackage ./dfhack { @@ -13,7 +36,7 @@ let soundSense = callPackage ./soundsense.nix { }; - # unfuck is linux-only right now, we will just use it there + # unfuck is linux-only right now, we will only use it there. dwarf-fortress-unfuck = if stdenv.isLinux then callPackage ./unfuck.nix { } else null; diff --git a/pkgs/games/dwarf-fortress/lazy-pack.nix b/pkgs/games/dwarf-fortress/lazy-pack.nix new file mode 100644 index 00000000000..3aa9e573f61 --- /dev/null +++ b/pkgs/games/dwarf-fortress/lazy-pack.nix @@ -0,0 +1,36 @@ +{ stdenvNoCC, lib, buildEnv, callPackage +, dwarf-fortress, themes + # 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. +, enableDFHack ? stdenvNoCC.isLinux +, enableTWBT ? enableDFHack +, enableSoundSense ? true +, enableStoneSense ? false # StoneSense is currently broken. +, enableDwarfTherapist ? true, dwarf-therapist +, enableLegendsBrowser ? true, legends-browser +, theme ? themes.phoebus +# General config options: +, enableIntro ? true +, enableTruetype ? true +, enableFPS ? false +}: + +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 ]; + license = licenses.mit; + platforms = platforms.all; + homepage = https://github.com/NixOS/nixpkgs/; + }; +} diff --git a/pkgs/games/dwarf-fortress/twbt/default.nix b/pkgs/games/dwarf-fortress/twbt/default.nix index c262ae6572f..b56170e5229 100644 --- a/pkgs/games/dwarf-fortress/twbt/default.nix +++ b/pkgs/games/dwarf-fortress/twbt/default.nix @@ -3,12 +3,12 @@ stdenvNoCC.mkDerivation rec { name = "twbt-${version}"; - version = "6.46"; - dfVersion = "0.44.10"; + version = "6.49"; + dfVersion = "0.44.11"; src = fetchurl { url = "https://github.com/mifki/df-twbt/releases/download/v${version}/twbt-${version}-linux.zip"; - sha256 = "1a4k26z5n547k5j3ij2kx834963rc8vwgwcmbmzmhi893bryb1k6"; + sha256 = "1qjkc7k33qhxj2g18njzasccjqsis5y8zrw5vl90h4rs3i8ld9xz"; }; sourceRoot = "."; diff --git a/pkgs/games/dwarf-fortress/wrapper/default.nix b/pkgs/games/dwarf-fortress/wrapper/default.nix index 0db6ac61963..e5816948498 100644 --- a/pkgs/games/dwarf-fortress/wrapper/default.nix +++ b/pkgs/games/dwarf-fortress/wrapper/default.nix @@ -5,6 +5,10 @@ , enableTWBT ? false, twbt , themes ? {} , theme ? null +# General config options: +, enableIntro ? true +, enableTruetype ? true +, enableFPS ? false }: let @@ -36,11 +40,24 @@ let pathsToLink = [ "/" "/hack" "/hack/scripts" ]; ignoreCollisions = true; - postBuild = lib.optionalString enableDFHack '' + postBuild = '' + # De-symlink init.txt + cp $out/data/init/init.txt init.txt + rm $out/data/init/init.txt + mv init.txt $out/data/init/init.txt + '' + lib.optionalString enableDFHack '' rm $out/hack/symbols.xml substitute ${dfhack_}/hack/symbols.xml $out/hack/symbols.xml \ --replace $(cat ${dwarf-fortress-original}/hash.md5.orig) \ $(cat ${dwarf-fortress-original}/hash.md5) + '' + 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}]' ''; }; in