Author: roconnor
Date: Sat Oct 30 06:00:44 2010
New Revision: 24538
URL: https://svn.nixos.org/websvn/nix/?rev=24538&sc=1
Log:
Dwarf Fortress
The wrapper script works by creating an image of the distribution in the users
home directory
(defaulting to $HOME/.config/df_linux). This is done because the program
expects to write
state into it's own distribution.
Better ideas are welcome!
What further is needed is to allow users to configure the init. One way is to
use nix-config
to apply patches to the init.txt file, though this would break sharing of the
package between
different users.
Added:
nixpkgs/trunk/pkgs/games/dwarf-fortress/
nixpkgs/trunk/pkgs/games/dwarf-fortress/default.nix
nixpkgs/trunk/pkgs/games/dwarf-fortress/df_permission
Modified:
nixpkgs/trunk/pkgs/top-level/all-packages.nix
Added: nixpkgs/trunk/pkgs/games/dwarf-fortress/default.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ nixpkgs/trunk/pkgs/games/dwarf-fortress/default.nix Sat Oct 30 06:00:44
2010 (r24538)
@@ -0,0 +1,90 @@
+{stdenv, fetchurl, SDL, SDL_image, SDL_ttf, gnomegtk, glib, mesa, openal,
glibc, libsndfile}:
+
+assert stdenv.system == "i686-linux";
+
+stdenv.mkDerivation rec {
+ name = "dwarf-fortress-0.31.16";
+
+ src = fetchurl {
+ url = "http://www.bay12games.com/dwarves/df_31_16_linux.tar.bz2";
+ sha256 = "04pyxyigrrclbpxdx3wryisgy5xraz0s7rsxr2kp4i136479f2r4";
+ };
+
+ phases = "unpackPhase patchPhase installPhase";
+
+ /* :TODO: Game options should be configurable by patching the default
configuration files */
+
+ permission = ./df_permission;
+
+ installPhase = ''
+ set -x
+ ensureDir $out/bin
+ ensureDir $out/share/df_linux
+ cp -r * $out/share/df_linux
+ cp $permission $out/share/df_linux/nix_permission
+
+ patchelf --set-interpreter ${glibc}/lib/ld-linux.so.2
$out/share/df_linux/libs/Dwarf_Fortress
+ ln -s ${libsndfile}/lib/libsndfile.so $out/share/df_linux/libs/
+
+ cat > $out/bin/dwarf-fortress << EOF
+ #!${stdenv.shell}
+ export DF_DIR="\$HOME/.config/df_linux"
+ if [ -n "\$XDG_DATA_HOME" ]
+ then export DF_DIR="\$XDG_DATA_HOME/df_linux"
+ fi
+
+ # Recreate a directory sturctor reflecting the original distribution in
the user directory
+
+ # Now link in the static data
+ mkdir -p \$DF_DIR
+ ln -sf $out/share/df_linux/libs \$DF_DIR/
+ ln -sf $out/share/df_linux/raw \$DF_DIR/
+ ln -sf $out/share/df_linux/df \$DF_DIR/
+
+ # Delete old data directory
+ rm -rf \$DF_DIR/data
+
+ # Link in the data directory
+ mkdir \$DF_DIR/data
+ for i in $out/share/df_linux/data/*
+ do
+ ln -s \$i \$DF_DIR/data/
+ done
+
+ # index as of 0.31.16 opened in read/write mode
+ # this is a hack to work around this
+ rm \$DF_DIR/data/index
+ cp $out/share/df_linux/data/index \$DF_DIR/data/index
+ chmod u+w \$DF_DIR/data/index
+
+ # initial_movies files are as of 0.31.16 opened in read/write mode instead
of read-only mode
+ # this is a hack to work around this
+ rm \$DF_DIR/data/initial_movies
+ cp -rf $out/share/df_linux/data/initial_movies \$DF_DIR/data/
+ chmod -R u+w \$DF_DIR/data/initial_movies
+
+ # announcement files are as of 0.31.16 opened in read/write mode instead
of read-only mode
+ # this is a hack to work around this
+ rm \$DF_DIR/data/announcement
+ cp -rf $out/share/df_linux/data/announcement \$DF_DIR/data/
+ chmod -R u+w \$DF_DIR/data/announcement
+
+ # link in persistant data
+ mkdir -p \$DF_DIR/save
+ ln -s \$DF_DIR/save \$DF_DIR/data/
+
+ # now run Dwarf Fortress!
+ export
LD_LIBRARY_PATH=\$DF_DIR/df_linux/libs/:${SDL}/lib:${SDL_image}/lib/:${SDL_ttf}/lib/:${gnomegtk}/lib/:${glib}/lib/:${mesa}/lib/:${openal}/lib/
+ \$DF_DIR/df "\$@"
+ EOF
+
+ chmod +x $out/bin/dwarf-fortress
+ '';
+
+ meta = {
+ description = "control a dwarven outpost or an adventurer in a randomly
generated, persistent world";
+ homepage = http://www.bay12games.com/dwarves;
+ license = "unfree-redistributable";
+ maintainers = [stdenv.lib.maintainers.roconnor];
+ };
+}
Added: nixpkgs/trunk/pkgs/games/dwarf-fortress/df_permission
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ nixpkgs/trunk/pkgs/games/dwarf-fortress/df_permission Sat Oct 30
06:00:44 2010 (r24538)
@@ -0,0 +1,40 @@
+From [email protected] Sat Oct 30 00:56:16 2010
+Date: Fri, 29 Oct 2010 16:56:15 -0800
+From: Tarn Adams <[email protected]>
+To: [email protected]
+Subject: Re: Dwarf Fortress Redistribution for NixOS
+
+Sure, that redistribution is fine. I think I've handled the movie
+issue for next time now. Thanks for the heads up on that.
+
+Tarn
+
+On Fri, Oct 29, 2010 at 6:56 AM, <[email protected]> wrote:
+> I'd like to distribute a *slightly* modified version of Dwarf Fortress which
+> is needed to run it under the NixOS distribution of Linux (see
+> <http://nixos.org/>
+>
+> Modification: The interpreter location /lib/ld-linux.so.2 in
+> lib/Dwarf_Fortress is replaced with the location of ld-linux.so.2 under the
+> NixOS distribution (which is currently
+> /nix/store/l8x3fdy1r6zf441vnqa87lzsvxrjbdz9-glibc-2.11.1/lib/ld-linux.so.2
+> but might change at a later date to something similar).
+>
+> I don't need you to recompile Dwarf Fortress. I can patch the binary itself
+> using patchelf. I just would like your permission to redistrubute this
+> modified binary.
+>
+> Thanks, I'm looking forward to trying out your game and letting other Nix
+> users try it out too.
+>
+> P.S. the inital_movies are open in read/write mode instead of read-only mode
+> which causes some issues under NixOS because the inital_movies are stored
+> read-only. I have a workaround, but you may want to consider opening these
+> files in read-only mode.
+>
+> --
+> Russell O'Connor <http://r6.ca/>
+> ``All talk about `theft,''' the general counsel of the American Graphophone
+> Company wrote, ``is the merest claptrap, for there exists no property in
+> ideas musical, literary or artistic, except as defined by statute.''
+>
Modified: nixpkgs/trunk/pkgs/top-level/all-packages.nix
==============================================================================
--- nixpkgs/trunk/pkgs/top-level/all-packages.nix Fri Oct 29 23:45:47
2010 (r24537)
+++ nixpkgs/trunk/pkgs/top-level/all-packages.nix Sat Oct 30 06:00:44
2010 (r24538)
@@ -6518,6 +6518,10 @@
crack_attack = callPackage ../games/crack-attack { };
+ dwarf_fortress = callPackage ../games/dwarf-fortress {
+ gnomegtk = gnome.gtk;
+ };
+
eduke32 = callPackage ../games/eduke32 { };
egoboo = callPackage ../games/egoboo { };
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits