diff options
Diffstat (limited to 'pkgs/games/dwarf-fortress/wrapper/default.nix')
-rw-r--r-- | pkgs/games/dwarf-fortress/wrapper/default.nix | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/pkgs/games/dwarf-fortress/wrapper/default.nix b/pkgs/games/dwarf-fortress/wrapper/default.nix index e82cc2be680d..5eebbf77d2ba 100644 --- a/pkgs/games/dwarf-fortress/wrapper/default.nix +++ b/pkgs/games/dwarf-fortress/wrapper/default.nix @@ -1,14 +1,20 @@ -{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll +{ stdenv, lib, buildEnv, dwarf-fortress, substituteAll , 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 = @@ -16,45 +22,65 @@ let then builtins.getAttr theme themes else theme; + twbtOnlyWithDFHack = assert (enableDFHack || !enableTWBT); true; + + unBool = b: if b then "YES" else "NO"; + # These are in inverse order for first packages to override the next ones. - pkgs = lib.optional (theme != null) ptheme - ++ lib.optional enableDFHack dfhack_ + themePkg = lib.optional (theme != null) ptheme; + pkgs = lib.optional enableDFHack dfhack_ ++ lib.optional enableSoundSense soundSense - ++ [ dwarf-fortress-original ]; + ++ lib.optional enableTWBT twbt.art + ++ [ dwarf-fortress ]; env = buildEnv { - name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}"; + name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}"; - paths = pkgs; + paths = themePkg ++ pkgs; 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) + --replace $(cat ${dwarf-fortress}/hash.md5.orig) \ + $(cat ${dwarf-fortress}/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 stdenv.mkDerivation rec { - name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}"; + name = "dwarf-fortress-${dwarf-fortress.dfVersion}"; - compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress-original.dfVersion); true) pkgs; + compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress.dfVersion); true) pkgs; dfInit = substituteAll { name = "dwarf-fortress-init"; src = ./dwarf-fortress-init.in; inherit env; exe = if stdenv.isLinux then "libs/Dwarf_Fortress" - else "dwarfort.exe"; + else "dwarfort.exe"; }; runDF = ./dwarf-fortress.in; runDFHack = ./dfhack.in; runSoundSense = ./soundSense.in; + passthru = { inherit dwarf-fortress; }; + buildCommand = '' mkdir -p $out/bin |