@@ -1,217 +1,33 @@
1−{ stdenv, fetchgit, fetchurl, cmake, glew, ncurses
2−, SDL, SDL_image, SDL_ttf, gtk2, glib
3−, mesa, openal, pango, atk, gdk_pixbuf, glibc, libsndfile
4−# begin dfhack-only parameters
5−, XMLLibXML
6−, XMLLibXSLT
7−, perl
8−, zlib
9−# end dfhack-only parameters
10−, enableDFHack ? false
11−}:
1+{ pkgs, pkgsi686Linux }:
122
133let
14− baseVersion = "40";
15− patchVersion = "24";
16− srcs = {
17− df_unfuck = fetchgit {
18− url = "https://github.com/svenstaro/dwarf_fortress_unfuck";
19− rev = "39742d64d2886fb594d79e7cc4b98fb917f26811";
20− sha256 = "19vwx6kpv1sf93bx5v8x47f7x2cgxsqk82v6j1a72sa3q7m5cpc7";
21− };
4+ callPackage = pkgs.newScope self;
5+ callPackage_i686 = pkgsi686Linux.newScope self;
226
23− dfhack = fetchgit {
24− url = "https://github.com/DFHack/dfhack.git";
25− rev = "0849099f2083e100cae6f64940b4eff4c28ce2eb";
26− sha256 = "0lnqrayi8hwfivkrxb7fw8lb6v95i04pskny1px7084n7nzvyv8b";
27− };
7+ self = rec {
8+ dwarf-fortress-original = callPackage_i686 ./game.nix { };
289
29− df = fetchurl {
30− url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_linux.tar.bz2";
31− sha256 = "0d4jrs45qj89vq9mjg7fxxhis7zivvb0vzjpmkk274b778kccdys";
10+ dfhack = callPackage_i686 ./dfhack {
11+ inherit (pkgsi686Linux.perlPackages) XMLLibXML XMLLibXSLT;
3212 };
33− };
34−
35− dfHackWorksWithCurrentVersion = true;
36− dfHackEnabled = dfHackWorksWithCurrentVersion && enableDFHack;
37−
38−in
39−
40−assert stdenv.system == "i686-linux";
41−
42−stdenv.mkDerivation rec {
43− name = "dwarf-fortress-0.${baseVersion}.${patchVersion}";
44−
45− inherit baseVersion patchVersion;
46−
47− buildInputs = [
48− SDL
49− SDL_image
50− SDL_ttf
51− gtk2
52− glib
53− glew
54− mesa
55− ncurses
56− openal
57− glibc
58− libsndfile
59− pango
60− atk
61− cmake
62− gdk_pixbuf
63− XMLLibXML
64− XMLLibXSLT
65− perl
66− zlib
67− ];
68− src = "${srcs.df_unfuck} ${srcs.df}" + stdenv.lib.optionalString dfHackEnabled " ${srcs.dfhack}";
69−
70− sourceRoot = srcs.df_unfuck.name;
71− dfHackSourceRoot = srcs.dfhack.name;
72−
73− cmakeFlags = [
74− "-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib}/lib/glib-2.0/include"
75− "-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2}/lib/gtk-2.0/include"
76− ];
77−
78− permission = ./df_permission;
79− dfHackTemplate = ./dwarf-fortress-hacked.in;
80− dfHackRunTemplate = ./dfhack-run.in;
81− dwarfFortressTemplate = ./dwarf-fortress.in;
82− installDfDataToHome = ./install-df-data-to-home.sh;
83− installDfhackDataToHome = ./install-dfhack-data-to-home.sh;
84− installDfDataContentToHome = ./install-df-data-content-to-home.sh;
85− exportLibsTemplate = ./export-libs.sh.in;
86− exportWorkaround = ./export-workaround.sh;
87−
88− postUnpack = stdenv.lib.optionalString dfHackEnabled ''
89− if [ "$dontMakeSourcesWritable" != 1 ]; then
90− chmod -R u+w "$dfHackSourceRoot"
91− fi
92− '';
93−
94− preConfigure = stdenv.lib.optionalString dfHackEnabled ''
95− export cmakeFlags="-DCMAKE_INSTALL_PREFIX=$out/share/df_linux $cmakeFlags"
96− export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/build/depends/protobuf
97− '';
98−
99− postConfigure = stdenv.lib.optionalString dfHackEnabled ''
100− if [ -z "$originalSourceRoot" ]; then
101−
102− originalSourceRoot=$sourceRoot
103− export sourceRoot=$dfHackSourceRoot
104−
105− pushd ../../$sourceRoot
106−
107− eval "''${configurePhase:-configurePhase}"
108−
109− popd
110−
111− export sourceRoot=$originalSourceRoot
112− unset originalSourceRoot
113− fi
114− '';
115−
116− installPhase = ''
117− set -x
118− mkdir -p $out/bin
119− mkdir -p $out/share/df_linux
120− pushd ../../
121− cp -r ./df_linux/* $out/share/df_linux
122− rm $out/share/df_linux/libs/lib*
12313
124− # Store the original hash
125− orig_hash=$(md5sum $out/share/df_linux/libs/Dwarf_Fortress | awk '{ print $1 }')
126− echo $orig_hash | cut -c1-8 > $out/share/df_linux/hash.md5.orig # for dwarf-therapist
127− echo $orig_hash > $out/share/df_linux/full-hash-orig.md5 # for dfhack
14+ dwarf-fortress-unfuck = callPackage_i686 ./unfuck.nix { };
12815
129− cp -f ./${srcs.df_unfuck.name}/build/libgraphics.so $out/share/df_linux/libs/libgraphics.so
130−
131− cp $permission $out/share/df_linux/nix_permission
132−
133− # Placeholder files for hashes of patched binary
134− touch $out/share/df_linux/hash.md5.patched
135− touch $out/share/df_linux/full-hash-patched.md5
136−
137− mkdir -p $out/share/df_linux/shell
138− cp $installDfDataToHome $out/share/df_linux/shell/install-df-data-to-home.sh
139− cp $installDfhackDataToHome $out/share/df_linux/shell/install-dfhack-data-to-home.sh
140− cp $installDfDataContentToHome $out/share/df_linux/shell/install-df-data-content-to-home.sh
141− cp $exportWorkaround $out/share/df_linux/shell/export-workaround.sh
142− substitute $exportLibsTemplate $out/share/df_linux/shell/export-libs.sh \
143− --subst-var-by stdenv_cc ${stdenv.cc} \
144− --subst-var-by SDL ${SDL} \
145− --subst-var-by SDL_image ${SDL_image} \
146− --subst-var-by SDL_ttf ${SDL_ttf} \
147− --subst-var-by gtk2 ${gtk2} \
148− --subst-var-by glib ${glib} \
149− --subst-var-by libsndfile ${libsndfile} \
150− --subst-var-by mesa ${mesa} \
151− --subst-var-by openal ${openal} \
152− --subst-var-by zlib ${zlib} \
153−
154− substitute $dwarfFortressTemplate $out/bin/dwarf-fortress \
155− --subst-var-by stdenv_shell ${stdenv.shell} \
156− --subst-var prefix
157−
158− chmod 755 $out/bin/dwarf-fortress
159−
160− popd
161− '' + stdenv.lib.optionalString dfHackEnabled ''
162−
163− originalSourceRoot=$sourceRoot
164− export sourceRoot=$dfHackSourceRoot
165−
166− pushd ../../$sourceRoot/build
167−
168− mkdir -p $out/dfhack
169−
170− make install
171−
172− cp ../package/linux/dfhack $out/dfhack/
173−
174− mkdir -p $out/bin
175−
176− substitute $dfHackTemplate $out/bin/dfhack \
177− --subst-var-by stdenv_shell ${stdenv.shell} \
178− --subst-var prefix
179− chmod 755 $out/bin/dfhack
180−
181− substitute $dfHackRunTemplate $out/bin/dfhack-run \
182− --subst-var-by stdenv_shell ${stdenv.shell} \
183− --subst-var prefix
184− chmod 755 $out/bin/dfhack-run
185−
186− popd
187−
188− export sourceRoot=$originalSourceRoot
189− unset originalSourceRoot
190− '';
191−
192− fixupPhase = ''
193− # Fix rpath
194− patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ stdenv.cc.cc stdenv.glibc ]}:$out/share/df_linux/libs" $out/share/df_linux/libs/Dwarf_Fortress
195−
196− patchelf --set-interpreter ${glibc}/lib/ld-linux.so.2 $out/share/df_linux/libs/Dwarf_Fortress
16+ dwarf-fortress = callPackage ./wrapper {
17+ themes = {
18+ "phoebus" = phoebus-theme;
19+ };
20+ };
19721
198− # Store new hash
199− patched_hash=$(md5sum $out/share/df_linux/libs/Dwarf_Fortress | awk '{ print $1 }')
200− echo $patched_hash | cut -c1-8 > $out/share/df_linux/hash.md5.patched # for dwarf-therapist
201− echo $patched_hash > $out/share/df_linux/full-hash-patched.md5 # for dfhack
202− '' + stdenv.lib.optionalString dfHackEnabled ''
203− find $out/share/df_linux/hack \( \
204− \( -type f -a -name "*.so*" \) -o \
205− \( -type f -a -perm +0100 \) \
206− \) -print -exec patchelf --shrink-rpath {} \;
22+ dwarf-therapist-original = callPackage ./dwarf-therapist {
23+ texlive = pkgs.texlive.combine {
24+ inherit (pkgs.texlive) scheme-basic float caption wrapfig adjmulticol sidecap preprint enumitem;
25+ };
26+ };
20727
208− sed -i "s/$(cat $out/share/df_linux/full-hash-orig.md5)/$(cat $out/share/df_linux/full-hash-patched.md5)/" $out/share/df_linux/hack/symbols.xml
209− '';
28+ dwarf-therapist = callPackage ./dwarf-therapist/wrapper.nix { };
21029
211− meta = {
212− description = "A single-player fantasy game with a randomly generated adventure world";
213− homepage = http://www.bay12games.com/dwarves;
214− license = stdenv.lib.licenses.unfreeRedistributable;
215− maintainers = with stdenv.lib.maintainers; [ a1russell robbinch roconnor the-kenny ];
30+ phoebus-theme = callPackage ./themes/phoebus.nix { };
21631 };
217−}
32+
33+in self