mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-20 11:05:14 +00:00
dwarf-fortress-wrapper: add themes support
Theme can be specified either as a derivation or as a string, in which case it will be taken by name from a pre-defined set of themes available in nixpkgs.
This commit is contained in:
parent
7fe01a7279
commit
d3b642ce9a
@ -4,7 +4,7 @@ let
|
||||
callPackage = pkgs.newScope self;
|
||||
callPackage_i686 = pkgsi686Linux.newScope self;
|
||||
|
||||
self = {
|
||||
self = rec {
|
||||
dwarf-fortress-original = callPackage_i686 ./game.nix { };
|
||||
|
||||
dfhack = callPackage_i686 ./dfhack {
|
||||
@ -13,7 +13,11 @@ let
|
||||
|
||||
dwarf-fortress-unfuck = callPackage_i686 ./unfuck.nix { };
|
||||
|
||||
dwarf-fortress = callPackage ./wrapper { };
|
||||
dwarf-fortress = callPackage ./wrapper {
|
||||
themes = {
|
||||
"phoebus" = phoebus-theme;
|
||||
};
|
||||
};
|
||||
|
||||
dwarf-therapist-original = callPackage ./dwarf-therapist {
|
||||
texlive = pkgs.texlive.combine {
|
||||
|
@ -1,21 +1,54 @@
|
||||
{ stdenv, lib, dwarf-fortress-original, substituteAll
|
||||
{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll
|
||||
, enableDFHack ? false, dfhack
|
||||
, themes ? {}
|
||||
, theme ? null
|
||||
}:
|
||||
|
||||
assert enableDFHack -> (dfhack.dfVersion == dwarf-fortress-original.dfVersion);
|
||||
let
|
||||
ptheme =
|
||||
if builtins.isString theme
|
||||
then builtins.getAttr theme themes
|
||||
else theme;
|
||||
|
||||
# These are in inverse order for first packages to override the next ones.
|
||||
pkgs = lib.optional (theme != null) ptheme
|
||||
++ lib.optional enableDFHack dfhack
|
||||
++ [ dwarf-fortress-original ];
|
||||
|
||||
env = buildEnv {
|
||||
name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}";
|
||||
paths = pkgs;
|
||||
ignoreCollisions = true;
|
||||
postBuild = lib.optionalString enableDFHack ''
|
||||
# #4621
|
||||
if [ -L "$out/hack" ]; then
|
||||
rm $out/hack
|
||||
mkdir $out/hack
|
||||
for i in ${dfhack}/hack/*; do
|
||||
ln -s $i $out/hack
|
||||
done
|
||||
fi
|
||||
rm $out/hack/symbols.xml
|
||||
substitute ${dfhack}/hack/symbols.xml $out/hack/symbols.xml \
|
||||
--replace $(cat ${dwarf-fortress-original}/full-hash-orig.md5) \
|
||||
$(cat ${dwarf-fortress-original}/full-hash-patched.md5)
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
||||
assert lib.all (x: x.dfVersion == dwarf-fortress-original.dfVersion) pkgs;
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}";
|
||||
|
||||
runDF = ./dwarf-fortress.in;
|
||||
runDFHack = ./dfhack.in;
|
||||
dfInit = substituteAll {
|
||||
name = "dwarf-fortress-init";
|
||||
src = ./dwarf-fortress-init.in;
|
||||
dwarfFortress = dwarf-fortress-original;
|
||||
inherit env;
|
||||
};
|
||||
inherit dfhack;
|
||||
df = dwarf-fortress-original;
|
||||
|
||||
runDF = ./dwarf-fortress.in;
|
||||
runDFHack = ./dfhack.in;
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
@ -25,23 +58,11 @@ stdenv.mkDerivation rec {
|
||||
--subst-var dfInit
|
||||
chmod 755 $out/bin/dwarf-fortress
|
||||
'' + lib.optionalString enableDFHack ''
|
||||
mkdir -p $out/hack
|
||||
substitute $dfhack/hack/symbols.xml $out/hack/symbols.xml \
|
||||
--replace $(cat $df/full-hash-orig.md5) $(cat $df/full-hash-patched.md5)
|
||||
|
||||
substitute $runDFHack $out/bin/dfhack \
|
||||
--subst-var-by stdenv_shell ${stdenv.shell} \
|
||||
--subst-var dfInit \
|
||||
--subst-var dfhack \
|
||||
--subst-var-by dfhackWrapper $out
|
||||
--subst-var dfInit
|
||||
chmod 755 $out/bin/dfhack
|
||||
'';
|
||||
|
||||
preferLocalBuild = true;
|
||||
|
||||
meta = {
|
||||
description = "A single-player fantasy game with a randomly generated adventure world";
|
||||
homepage = http://www.bay12games.com/dwarves;
|
||||
maintainers = with lib.maintainers; [ a1russell robbinch roconnor the-kenny ];
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
#!@stdenv_shell@ -e
|
||||
|
||||
hack_dir="@dfhack@"
|
||||
hack_wrap_dir="@dfhackWrapper@"
|
||||
|
||||
source @dfInit@
|
||||
|
||||
cd "$hack_dir"
|
||||
for i in dfhack.init-example dfhack-config/default hack/!(symbols.xml|*.so|dfhack-run|binpatch); do
|
||||
update_path "$hack_dir" "$i"
|
||||
for i in dfhack.init-example dfhack-config/default hack/*; do
|
||||
update_path "$i"
|
||||
done
|
||||
|
||||
update_path "$hack_wrap_dir" "hack/symbols.xml"
|
||||
|
||||
cd "$DF_DIR"
|
||||
LD_LIBRARY_PATH="$hack_dir/hack/libs:$hack_dir/hack:$LD_LIBRARY_PATH" \
|
||||
LD_PRELOAD=$hack_dir/hack/libdfhack.so exec $game_dir/libs/Dwarf_Fortress "$@"
|
||||
LD_LIBRARY_PATH="$env_dir/hack/libs:$env_dir/hack:$LD_LIBRARY_PATH" \
|
||||
LD_PRELOAD=$env_dir/hack/libdfhack.so exec $env_dir/libs/Dwarf_Fortress "$@"
|
||||
|
@ -1,27 +1,25 @@
|
||||
shopt -s extglob
|
||||
|
||||
[ -z "$DF_DIR" ] && DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
|
||||
game_dir="@dwarfFortress@"
|
||||
env_dir="@env@"
|
||||
|
||||
update_path() {
|
||||
local pkg_dir="$1"
|
||||
local path="$2"
|
||||
local path="$1"
|
||||
|
||||
mkdir -p "$DF_DIR/$(dirname "$path")"
|
||||
# If user has replaced these data directories, let them stay.
|
||||
if [ ! -e "$DF_DIR/$path" ] || [ -L "$DF_DIR/$path" ]; then
|
||||
rm -f "$DF_DIR/$path"
|
||||
ln -s "$pkg_dir/$path" "$DF_DIR/$path"
|
||||
ln -s "$env_dir/$path" "$DF_DIR/$path"
|
||||
fi
|
||||
}
|
||||
|
||||
forcecopy_path() {
|
||||
local pkg_dir="$1"
|
||||
local path="$2"
|
||||
local path="$1"
|
||||
|
||||
mkdir -p "$DF_DIR/$(dirname "$path")"
|
||||
rm -rf "$DF_DIR/$path"
|
||||
cp -rL --no-preserve=all "$pkg_dir/$path" "$DF_DIR/$path"
|
||||
cp -rL --no-preserve=all "$env_dir/$path" "$DF_DIR/$path"
|
||||
}
|
||||
|
||||
mkdir -p "$DF_DIR"
|
||||
@ -33,11 +31,11 @@ We try to detect changes based on data directories being symbolic links -- keep
|
||||
|
||||
EOF
|
||||
|
||||
cd "$game_dir"
|
||||
cd "$env_dir"
|
||||
for i in data/init/* data/!(init|index|announcement) raw; do
|
||||
update_path "$game_dir" "$i"
|
||||
update_path "$i"
|
||||
done
|
||||
|
||||
forcecopy_path "$game_dir" data/index
|
||||
forcecopy_path data/index
|
||||
# For some reason, it's needed to be writable...
|
||||
forcecopy_path "$game_dir" data/announcement
|
||||
forcecopy_path data/announcement
|
||||
|
@ -3,4 +3,4 @@
|
||||
source @dfInit@
|
||||
|
||||
cd "$DF_DIR"
|
||||
exec $game_dir/libs/Dwarf_Fortress "$@"
|
||||
exec "$env_dir/libs/Dwarf_Fortress" "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user