all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: mcrfan96@cock.li
To: 32162@debbugs.gnu.org
Subject: [bug#32162] [PATCH] gnu: Add nethack.
Date: Tue, 17 Jul 2018 11:07:58 -0700	[thread overview]
Message-ID: <20180717180758.17538-1-mcrfan96@cock.li> (raw)
In-Reply-To: <b3cae3b3-45a6-a3c4-d3a3-fb14f47ae022@cock.li>

From: Anonymous <mcrfan96@cock.li>

* gnu/packages/games.scm (nethack): New variable.
---
 gnu/packages/games.scm | 118 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index a3c770a0b..bc12e07b7 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -87,6 +87,7 @@
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages imagemagick)
+  #:use-module (gnu packages less)
   #:use-module (gnu packages libcanberra)
   #:use-module (gnu packages libedit)
   #:use-module (gnu packages libunwind)
@@ -665,6 +666,123 @@ removed lines to all opponents.  There is also a Demo mode in which you can
 watch your CPU playing while enjoying a cup of tea!")
     (license license:gpl2+)))
 
+(define-public nethack
+  (package
+    (name "nethack")
+    (version "3.6.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+               "https://www.nethack.org/download/"
+               version "/" name "-361-src.tgz"))
+        (sha256
+          (base32 "1dha0ijvxhx7c9hr0452h93x81iiqsll8bc9msdnp7xdqcfbz32b"))))
+    (inputs
+      `(("ncurses" ,ncurses)
+        ("bison" ,bison)
+        ("flex" ,flex)
+        ("less" ,less)))
+    (build-system gnu-build-system)
+    (arguments
+      '(#:make-flags
+        `(,(string-append "PREFIX=" (assoc-ref %outputs "out")))
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'configure 'patch-paths
+            (lambda _
+              (substitute* "sys/unix/nethack.sh"
+                (("^ *cd .*$") ""))
+              (substitute* "sys/unix/Makefile.utl"
+                (("^YACC *=.*$") "YACC = bison -y\n")
+                (("^LEX *=.*$") "LEX = flex\n")
+                (("^# CC = gcc") "CC = gcc"))
+              (substitute* "sys/unix/hints/linux"
+                (("/bin/gzip") (string-append
+                                 (assoc-ref %build-inputs "gzip")
+                                 "/bin/gzip"))
+                (("^WINTTYLIB=.*") "WINTTYLIB=-lncurses"))
+              (substitute* "include/config.h"
+                (("^.*define CHDIR.*$") ""))
+              (substitute* "sys/unix/Makefile.src"
+                 (("^# CC = gcc") "CC = gcc"))
+              #t))
+          (replace 'configure
+            (lambda _
+              (let ((bash (string-append
+                            (assoc-ref %build-inputs "bash")
+                            "/bin/bash")))
+                (with-directory-excursion "sys/unix"
+                  (substitute* "setup.sh" (("/bin/sh") bash))
+                  (invoke bash "setup.sh" "hints/linux"))
+                #t)))
+          (add-after 'install 'fixup-paths
+            (lambda _
+              (let* ((output (assoc-ref %outputs "out"))
+                     (nethack-script (string-append output "/bin/nethack")))
+                (mkdir-p (string-append output "/games/lib/nethackuserdir"))
+                (for-each
+                  (lambda (file)
+                    (invoke "mv"
+                      (string-append output "/games/lib/nethackdir/" file)
+                      (string-append output "/games/lib/nethackuserdir")))
+                  '("xlogfile" "logfile" "perm" "record" "save"))
+                (mkdir-p (string-append output "/bin"))
+                (call-with-output-file nethack-script
+                  (lambda (port)
+                    (format port "#!~a/bin/sh
+PATH=~a:$PATH
+if [ ! -d ~~/.config/nethack ]; then
+  mkdir -p ~~/.config/nethack
+  cp -r ~a/games/lib/nethackuserdir/* ~~/.config/nethack
+  chmod -R +w ~~/.config/nethack
+fi
+
+RUNDIR=$(mktemp -d)
+
+cleanup() {
+  rm -rf $RUNDIR
+}
+trap cleanup EXIT
+
+cd $RUNDIR
+for i in ~~/.config/nethack/*; do
+  ln -s $i $(basename $i)
+done
+for i in ~a/games/lib/nethackdir/*; do
+  ln -s $i $(basename $i)
+done
+~a/games/nethack"
+                      (assoc-ref %build-inputs "bash")
+                      (list->search-path-as-string
+                        (list
+                          (string-append
+                            (assoc-ref %build-inputs "coreutils") "/bin")
+                          (string-append
+                            (assoc-ref %build-inputs "less") "/bin"))
+                        ":")
+                      output
+                      output
+                      output)))
+                (chmod nethack-script #o555)
+                #t)))
+          (delete 'check))))
+    (home-page "https://nethack.org")
+    (synopsis "Classic dungeon crawl game")
+    (description "NetHack is a single player dungeon exploration game that runs
+on a wide variety of computer systems, with a variety of graphical and text
+interfaces all using the same game engine.  Unlike many other Dungeons &
+Dragons-inspired games, the emphasis in NetHack is on discovering the detail of
+the dungeon and not simply killing everything in sight - in fact, killing
+everything in sight is a good way to die quickly.  Each game presents a
+different landscape - the random number generator provides an essentially
+unlimited number of variations of the dungeon and its denizens to be discovered
+by the player in one of a number of characters: you can pick your race, your
+role, and your gender.")
+    (license
+      (license:fsdg-compatible
+        "https://nethack.org/common/license.html"))))
+
 (define-public prboom-plus
   (package
    (name "prboom-plus")
-- 
2.18.0

  parent reply	other threads:[~2018-07-17 18:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-15  5:42 [bug#32162] [PATCH] gnu: Add nethack Anonymous
2018-07-17 12:45 ` Ludovic Courtès
2018-07-17 18:12   ` Anonymous
2018-07-17 21:00     ` Ludovic Courtès
     [not found]       ` <B8BAA1C7-89C3-4229-869C-498CF2CC80DB@cock.li>
2018-07-17 21:08         ` [bug#32162] FW: " Anonymous
2018-07-17 21:08     ` Leo Famulari
2018-07-17 18:07 ` mcrfan96 [this message]
2018-07-17 22:11   ` bug#32162: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180717180758.17538-1-mcrfan96@cock.li \
    --to=mcrfan96@cock.li \
    --cc=32162@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.