mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-26 23:20:18 +02:00
commit
2bb4088f51
|
@ -1,4 +1,24 @@
|
|||
{ pkgs, stdenv, stdenvNoCC, gccStdenv, lib, recurseIntoAttrs }:
|
||||
{ pkgs, stdenv, stdenvNoCC, buildEnv, 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.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;
|
||||
|
@ -15,6 +35,8 @@ let
|
|||
df-hashes = builtins.fromJSON (builtins.readFile ./game.json);
|
||||
dwarf-fortress = df-games.dwarf-fortress_0_44_11;
|
||||
|
||||
dwarf-fortress-full = callPackage ./lazy-pack.nix { };
|
||||
|
||||
dfhack = callPackage ./dfhack {
|
||||
inherit (pkgs.perlPackages) XMLLibXML XMLLibXSLT;
|
||||
stdenv = gccStdenv;
|
||||
|
@ -22,7 +44,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;
|
||||
|
||||
|
@ -37,6 +59,7 @@ let
|
|||
|
||||
legends-browser = callPackage ./legends-browser {};
|
||||
|
||||
twbt = callPackage ./twbt {};
|
||||
themes = recurseIntoAttrs (callPackage ./themes {
|
||||
stdenv = stdenvNoCC;
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{ stdenv, hostPlatform, lib, fetchFromGitHub, cmake, writeScriptBin, callPackage
|
||||
{ stdenv, buildEnv, hostPlatform, lib, fetchurl, fetchFromGitHub, cmake, writeScriptBin, callPackage
|
||||
, perl, XMLLibXML, XMLLibXSLT, zlib
|
||||
, enableStoneSense ? false, allegro5, libGLU_combined
|
||||
, enableTWBT ? true, twbt
|
||||
, SDL
|
||||
}:
|
||||
|
||||
|
@ -33,40 +34,47 @@ let
|
|||
fi
|
||||
'';
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
dfhack = stdenv.mkDerivation rec {
|
||||
name = "dfhack-base-${version}";
|
||||
|
||||
# Beware of submodules
|
||||
src = fetchFromGitHub {
|
||||
owner = "DFHack";
|
||||
repo = "dfhack";
|
||||
sha256 = "1vzrpdw0pn18calayf9dwqpyg37cb7wkzkvskxjx9nak5ilxzywm";
|
||||
rev = version;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
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_combined ];
|
||||
|
||||
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"
|
||||
'';
|
||||
|
||||
cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" "-DDOWNLOAD_RUBY=OFF" ]
|
||||
++ lib.optionals enableStoneSense [ "-DBUILD_STONESENSE=ON" "-DSTONESENSE_INTERNAL_SO=OFF" ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
};
|
||||
in
|
||||
|
||||
buildEnv {
|
||||
name = "dfhack-${version}";
|
||||
|
||||
# Beware of submodules
|
||||
src = fetchFromGitHub {
|
||||
owner = "DFHack";
|
||||
repo = "dfhack";
|
||||
sha256 = "1vzrpdw0pn18calayf9dwqpyg37cb7wkzkvskxjx9nak5ilxzywm";
|
||||
rev = version;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
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_combined ];
|
||||
|
||||
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"
|
||||
'';
|
||||
|
||||
cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" "-DDOWNLOAD_RUBY=OFF" ]
|
||||
++ lib.optionals enableStoneSense [ "-DBUILD_STONESENSE=ON" "-DSTONESENSE_INTERNAL_SO=OFF" ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
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/;
|
||||
|
|
36
pkgs/games/dwarf-fortress/lazy-pack.nix
Normal file
36
pkgs/games/dwarf-fortress/lazy-pack.nix
Normal file
|
@ -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/;
|
||||
};
|
||||
}
|
35
pkgs/games/dwarf-fortress/twbt/default.nix
Normal file
35
pkgs/games/dwarf-fortress/twbt/default.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ stdenvNoCC, fetchurl, unzip }:
|
||||
|
||||
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
name = "twbt-${version}";
|
||||
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 = "1qjkc7k33qhxj2g18njzasccjqsis5y8zrw5vl90h4rs3i8ld9xz";
|
||||
};
|
||||
|
||||
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 ];
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux;
|
||||
homepage = https://github.com/mifki/df-twbt;
|
||||
};
|
||||
}
|
|
@ -2,13 +2,19 @@
|
|||
, 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,10 +22,15 @@ 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.
|
||||
themePkg = lib.optional (theme != null) ptheme;
|
||||
pkgs = lib.optional enableDFHack dfhack_
|
||||
++ lib.optional enableSoundSense soundSense
|
||||
++ lib.optional enableTWBT twbt.art
|
||||
++ [ dwarf-fortress ];
|
||||
|
||||
env = buildEnv {
|
||||
|
@ -29,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}/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
|
||||
|
|
Loading…
Reference in a new issue