mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-15 06:07:57 +00:00
dwarf-fortress.dfhack: make overridable
Currently, it is quite hard to override anything about dfhack (for example, to add plugins at build time), because 1. it is not exposed anywhere, so you have to do something like `dwarf-fortress.override (oldArgs: { dfhack = oldArgs.dfhack.override...; })` 2. the final `dfhack` derivation is a `buildEnv`, so `overrideAttrs` doesn't work as expected. This fixes 1 by adding `dfhack` to the wrapper's `passthru`, and 2 by moving `twbt.lib` (which is the only reason for the dfhack `buildEnv`) into the wrapper. Also adds an `extraPackages` argument to the wrapper, and copies `*.init` files from the env to the DF directory so that we can easily add a `dfhack.init`. With these changes, I was able to build dfhack with the dfplex plugin.
This commit is contained in:
parent
c91f68c3d8
commit
839fdd101c
@ -69,7 +69,7 @@ let
|
||||
|
||||
dfhack = callPackage ./dfhack {
|
||||
inherit (perlPackages) XMLLibXML XMLLibXSLT;
|
||||
inherit dfVersion twbt;
|
||||
inherit dfVersion;
|
||||
stdenv = gccStdenv;
|
||||
};
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
, allegro5
|
||||
, libGLU
|
||||
, libGL
|
||||
, enableTWBT ? true
|
||||
, twbt
|
||||
, SDL
|
||||
, dfVersion
|
||||
}:
|
||||
@ -115,9 +113,9 @@ let
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
dfhack = stdenv.mkDerivation {
|
||||
pname = "dfhack-base";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "dfhack";
|
||||
inherit version;
|
||||
|
||||
# Beware of submodules
|
||||
@ -166,21 +164,13 @@ let
|
||||
ln -s ${ruby}/lib/libruby-*.so $out/hack/libruby.so
|
||||
'';
|
||||
|
||||
};
|
||||
in
|
||||
passthru = { inherit dfVersion; };
|
||||
|
||||
buildEnv {
|
||||
name = "dfhack-${version}";
|
||||
|
||||
passthru = { inherit version dfVersion; };
|
||||
|
||||
paths = [ dfhack ] ++ lib.optionals enableTWBT [ twbt.lib ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Memory hacking library for Dwarf Fortress and a set of tools that use it";
|
||||
homepage = "https://github.com/DFHack/dfhack/";
|
||||
license = licenses.zlib;
|
||||
platforms = [ "x86_64-linux" "i686-linux" ];
|
||||
maintainers = with maintainers; [ robbinch a1russell abbradar numinit ];
|
||||
};
|
||||
}
|
||||
meta = with lib; {
|
||||
description = "Memory hacking library for Dwarf Fortress and a set of tools that use it";
|
||||
homepage = "https://github.com/DFHack/dfhack/";
|
||||
license = licenses.zlib;
|
||||
platforms = [ "x86_64-linux" "i686-linux" ];
|
||||
maintainers = with maintainers; [ robbinch a1russell abbradar numinit ];
|
||||
};
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
, twbt
|
||||
, themes ? { }
|
||||
, theme ? null
|
||||
, extraPackages ? [ ]
|
||||
# General config options:
|
||||
, enableIntro ? true
|
||||
, enableTruetype ? true
|
||||
@ -27,7 +28,6 @@
|
||||
let
|
||||
dfhack_ = dfhack.override {
|
||||
inherit enableStoneSense;
|
||||
inherit enableTWBT;
|
||||
};
|
||||
|
||||
ptheme =
|
||||
@ -38,16 +38,16 @@ let
|
||||
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;
|
||||
themePkgs = lib.optional (theme != null) ptheme;
|
||||
pkgs = lib.optional enableDFHack dfhack_
|
||||
++ lib.optional enableSoundSense soundSense
|
||||
++ lib.optional enableTWBT twbt.art
|
||||
++ lib.optionals enableTWBT [ twbt.lib twbt.art ]
|
||||
++ [ dwarf-fortress ];
|
||||
|
||||
fixup = lib.singleton (runCommand "fixup" { } (''
|
||||
config = runCommand "dwarf-fortress-config" { } (''
|
||||
mkdir -p $out/data/init
|
||||
'' + (if (theme != null) then ''
|
||||
cp ${lib.head themePkg}/data/init/init.txt $out/data/init/init.txt
|
||||
cp ${ptheme}/data/init/init.txt $out/data/init/init.txt
|
||||
'' else ''
|
||||
cp ${dwarf-fortress}/data/init/init.txt $out/data/init/init.txt
|
||||
'') + lib.optionalString enableDFHack ''
|
||||
@ -76,21 +76,24 @@ let
|
||||
'' + ''
|
||||
substituteInPlace $out/data/init/init.txt \
|
||||
--replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \
|
||||
--replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \
|
||||
--replace '[TRUETYPE:24]' '[TRUETYPE:${unBool enableTruetype}]' \
|
||||
--replace '[FPS:NO]' '[FPS:${unBool enableFPS}]' \
|
||||
--replace '[SOUND:YES]' '[SOUND:${unBool enableSound}]'
|
||||
''));
|
||||
'');
|
||||
|
||||
env = buildEnv {
|
||||
name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}";
|
||||
|
||||
paths = fixup ++ themePkg ++ pkgs;
|
||||
pathsToLink = [ "/" "/hack" "/hack/scripts" ];
|
||||
paths = extraPackages ++ [ config ] ++ themePkgs ++ pkgs;
|
||||
|
||||
ignoreCollisions = true;
|
||||
};
|
||||
in
|
||||
|
||||
lib.throwIf (enableTWBT && !enableDFHack) "dwarf-fortress: TWBT requires DFHack to be enabled"
|
||||
lib.throwIf (enableStoneSense && !enableDFHack) "dwarf-fortress: StoneSense requires DFHack to be enabled"
|
||||
lib.throwIf (enableTextMode && enableTWBT) "dwarf-fortress: text mode and TWBT are mutually exclusive"
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "dwarf-fortress";
|
||||
version = dwarf-fortress.dfVersion;
|
||||
@ -114,7 +117,10 @@ stdenv.mkDerivation {
|
||||
runDFHack = ./dfhack.in;
|
||||
runSoundSense = ./soundSense.in;
|
||||
|
||||
passthru = { inherit dwarf-fortress dwarf-therapist; };
|
||||
passthru = {
|
||||
inherit dwarf-fortress dwarf-therapist twbt;
|
||||
dfhack = dfhack_;
|
||||
};
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
|
4
pkgs/games/dwarf-fortress/wrapper/dfhack.in
Normal file → Executable file
4
pkgs/games/dwarf-fortress/wrapper/dfhack.in
Normal file → Executable file
@ -2,8 +2,8 @@
|
||||
|
||||
source @dfInit@
|
||||
|
||||
for i in dfhack.init-example dfhack-config/default hack/* stonesense/*; do
|
||||
update_path "$i"
|
||||
for i in *.init *.init-example dfhack-config/default dfhack-config/init hack/* stonesense/*; do
|
||||
if [ -e "$i" ]; then update_path "$i"; fi
|
||||
done
|
||||
|
||||
cd "$DF_DIR"
|
||||
|
Loading…
Reference in New Issue
Block a user