git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitd3b642ce9ad056b60d8cfa576dd3fa800ec57ba4 authorNikolay Amiantov <ab@fmap.me> dateWed 20 Jan 2016, 00:44 (11 years ago) parent7fe01a7
5 files changed+61−44
pkgs/games/dwarf-fortress/default.nix+6−2 pkgs/games/dwarf-fortress/wrapper/default.nix+41−20 pkgs/games/dwarf-fortress/wrapper/dfhack.in+4−10 pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in+9−11 pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in+1−1
pkgs/games/dwarf-fortress/default.nix+6−2
@@ -4,7 +4,7 @@ let
44 callPackage = pkgs.newScope self;
55 callPackage_i686 = pkgsi686Linux.newScope self;
66
7− self = {
7+ self = rec {
88 dwarf-fortress-original = callPackage_i686 ./game.nix { };
99
1010 dfhack = callPackage_i686 ./dfhack {
@@ -13,7 +13,11 @@ let
1313
1414 dwarf-fortress-unfuck = callPackage_i686 ./unfuck.nix { };
1515
16− dwarf-fortress = callPackage ./wrapper { };
16+ dwarf-fortress = callPackage ./wrapper {
17+ themes = {
18+ "phoebus" = phoebus-theme;
19+ };
20+ };
1721
1822 dwarf-therapist-original = callPackage ./dwarf-therapist {
1923 texlive = pkgs.texlive.combine {
pkgs/games/dwarf-fortress/wrapper/default.nix+41−20
@@ -1,21 +1,54 @@
1−{ stdenv, lib, dwarf-fortress-original, substituteAll
1+{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll
22, enableDFHack ? false, dfhack
3+, themes ? {}
4+, theme ? null
35}:
46
5−assert enableDFHack -> (dfhack.dfVersion == dwarf-fortress-original.dfVersion);
7+let
8+ ptheme =
9+ if builtins.isString theme
10+ then builtins.getAttr theme themes
11+ else theme;
12+
13+ # These are in inverse order for first packages to override the next ones.
14+ pkgs = lib.optional (theme != null) ptheme
15+ ++ lib.optional enableDFHack dfhack
16+ ++ [ dwarf-fortress-original ];
17+
18+ env = buildEnv {
19+ name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}";
20+ paths = pkgs;
21+ ignoreCollisions = true;
22+ postBuild = lib.optionalString enableDFHack ''
23+ # #4621
24+ if [ -L "$out/hack" ]; then
25+ rm $out/hack
26+ mkdir $out/hack
27+ for i in ${dfhack}/hack/*; do
28+ ln -s $i $out/hack
29+ done
30+ fi
31+ rm $out/hack/symbols.xml
32+ substitute ${dfhack}/hack/symbols.xml $out/hack/symbols.xml \
33+ --replace $(cat ${dwarf-fortress-original}/full-hash-orig.md5) \
34+ $(cat ${dwarf-fortress-original}/full-hash-patched.md5)
35+ '';
36+ };
37+in
38+
39+assert lib.all (x: x.dfVersion == dwarf-fortress-original.dfVersion) pkgs;
640
741stdenv.mkDerivation rec {
842 name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}";
943
10− runDF = ./dwarf-fortress.in;
11− runDFHack = ./dfhack.in;
1244 dfInit = substituteAll {
1345 name = "dwarf-fortress-init";
1446 src = ./dwarf-fortress-init.in;
15− dwarfFortress = dwarf-fortress-original;
47+ inherit env;
1648 };
17− inherit dfhack;
18− df = dwarf-fortress-original;
49+
50+ runDF = ./dwarf-fortress.in;
51+ runDFHack = ./dfhack.in;
1952
2053 buildCommand = ''
2154 mkdir -p $out/bin
@@ -25,23 +58,11 @@ stdenv.mkDerivation rec {
2558 --subst-var dfInit
2659 chmod 755 $out/bin/dwarf-fortress
2760 '' + lib.optionalString enableDFHack ''
28− mkdir -p $out/hack
29− substitute $dfhack/hack/symbols.xml $out/hack/symbols.xml \
30− --replace $(cat $df/full-hash-orig.md5) $(cat $df/full-hash-patched.md5)
31−
3261 substitute $runDFHack $out/bin/dfhack \
3362 --subst-var-by stdenv_shell ${stdenv.shell} \
34− --subst-var dfInit \
35− --subst-var dfhack \
36− --subst-var-by dfhackWrapper $out
63+ --subst-var dfInit
3764 chmod 755 $out/bin/dfhack
3865 '';
3966
4067 preferLocalBuild = true;
41−
42− meta = {
43− description = "A single-player fantasy game with a randomly generated adventure world";
44− homepage = http://www.bay12games.com/dwarves;
45− maintainers = with lib.maintainers; [ a1russell robbinch roconnor the-kenny ];
46− };
4768}
pkgs/games/dwarf-fortress/wrapper/dfhack.in+4−10
@@ -1,17 +1,11 @@
11#!@stdenv_shell@ -e
22
3−hack_dir="@dfhack@"
4−hack_wrap_dir="@dfhackWrapper@"
5−
63source @dfInit@
74
8−cd "$hack_dir"
9−for i in dfhack.init-example dfhack-config/default hack/!(symbols.xml|*.so|dfhack-run|binpatch); do
10− update_path "$hack_dir" "$i"
5+for i in dfhack.init-example dfhack-config/default hack/*; do
6+ update_path "$i"
117done
128
13−update_path "$hack_wrap_dir" "hack/symbols.xml"
14−
159cd "$DF_DIR"
16−LD_LIBRARY_PATH="$hack_dir/hack/libs:$hack_dir/hack:$LD_LIBRARY_PATH" \
17− LD_PRELOAD=$hack_dir/hack/libdfhack.so exec $game_dir/libs/Dwarf_Fortress "$@"
10+LD_LIBRARY_PATH="$env_dir/hack/libs:$env_dir/hack:$LD_LIBRARY_PATH" \
11+ LD_PRELOAD=$env_dir/hack/libdfhack.so exec $env_dir/libs/Dwarf_Fortress "$@"
pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in+9−11
@@ -1,27 +1,25 @@
11shopt -s extglob
22
33[ -z "$DF_DIR" ] && DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
4−game_dir="@dwarfFortress@"
4+env_dir="@env@"
55
66update_path() {
7− local pkg_dir="$1"
8− local path="$2"
7+ local path="$1"
98
109 mkdir -p "$DF_DIR/$(dirname "$path")"
1110 # If user has replaced these data directories, let them stay.
1211 if [ ! -e "$DF_DIR/$path" ] || [ -L "$DF_DIR/$path" ]; then
1312 rm -f "$DF_DIR/$path"
14− ln -s "$pkg_dir/$path" "$DF_DIR/$path"
13+ ln -s "$env_dir/$path" "$DF_DIR/$path"
1514 fi
1615}
1716
1817forcecopy_path() {
19− local pkg_dir="$1"
20− local path="$2"
18+ local path="$1"
2119
2220 mkdir -p "$DF_DIR/$(dirname "$path")"
2321 rm -rf "$DF_DIR/$path"
24− cp -rL --no-preserve=all "$pkg_dir/$path" "$DF_DIR/$path"
22+ cp -rL --no-preserve=all "$env_dir/$path" "$DF_DIR/$path"
2523}
2624
2725mkdir -p "$DF_DIR"
@@ -33,11 +31,11 @@ We try to detect changes based on data directories being symbolic links -- keep
3331
3432EOF
3533
36−cd "$game_dir"
34+cd "$env_dir"
3735for i in data/init/* data/!(init|index|announcement) raw; do
38− update_path "$game_dir" "$i"
36+ update_path "$i"
3937done
4038
41−forcecopy_path "$game_dir" data/index
39+forcecopy_path data/index
4240# For some reason, it's needed to be writable...
43−forcecopy_path "$game_dir" data/announcement
41+forcecopy_path data/announcement
pkgs/games/dwarf-fortress/wrapper/dwarf-fortress.in+1−1
@@ -3,4 +3,4 @@
33source @dfInit@
44
55cd "$DF_DIR"
6−exec $game_dir/libs/Dwarf_Fortress "$@"
6+exec "$env_dir/libs/Dwarf_Fortress" "$@"