GNU bug report logs -
#32162
[PATCH] gnu: Add nethack
Previous Next
Reported by: Anonymous <mcrfan96 <at> cock.li>
Date: Sun, 15 Jul 2018 05:43:02 UTC
Severity: normal
Tags: patch
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32162 in the body.
You can then email your comments to 32162 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#32162
; Package
guix-patches
.
(Sun, 15 Jul 2018 05:43:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Anonymous <mcrfan96 <at> cock.li>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Sun, 15 Jul 2018 05:43:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I've created a package for nethack by basically copying the package from
NixOS.
This is my first time writing a guix package, so feel free to make
corrections.
[add-nethack.patch (text/plain, attachment)]
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32162
; Package
guix-patches
.
(Tue, 17 Jul 2018 12:46:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 32162 <at> debbugs.gnu.org (full text, mbox):
Hello,
Anonymous <mcrfan96 <at> cock.li> skribis:
> I've created a package for nethack by basically copying the package
> from NixOS.
>
> This is my first time writing a guix package, so feel free to make
> corrections.
That’s a very good start, thanks for your patch and welcome!
I have a few comments below, but the package looks pretty good to me.
As a general comment: note that Nixpkgs uses Bash for the “build-side”
code (actions performed when building the derivation), whereas Guix uses
Scheme. There’s a bunch of utility functions in the (guix build utils)
modules that usually allow us to not resort to Bash scripting. Most of
my comments below are about using the Scheme equivalent to the Bash
script.
> + (replace 'configure
> + (lambda _
> + (let ((bash (string-append
> + (assoc-ref %build-inputs "bash")
> + "/bin/bash")))
> + (chdir "sys/unix")
> + (substitute* "setup.sh" (("/bin/sh") bash))
> + (invoke bash "setup.sh" "hints/linux")
> + (chdir "../..")
I recommend writing it like this:
(with-directory-excursion "sys/unix"
(substitute* …)
(invoke …))
It takes care of chdir’ing back and it’s somewhat easier to read IMO.
> + (map
> + (lambda (i)
> + (invoke "mv"
> + (string-append output "/games/lib/nethackdir/" i)
> + (string-append output "/games/lib/nethackuserdir")))
> + '("xlogfile" "logfile" "perm" "record" "save"))
Rather:
(for-each (lambda (file)
(install-file file
(string-append … "/games/lib/nethackuserdir")))
'(…))
> + (let ((outfile (open-file nethack-script "w"))
> + (user-dir "~/.config/nethack"))
> + (map
> + (lambda (line)
> + (display (string-append line "\n") outfile))
> + `(,(string-append "#!" (assoc-ref %build-inputs "bash")
> + "/bin/bash")
> + ,(string-append
> + "PATH="
> + (list->search-path-as-string
> + (list (string-append
> + (assoc-ref %build-inputs "coreutils")
> + "/bin")
> + (string-append
> + (assoc-ref %build-inputs "less")
> + "/bin"))
> + ":"))
> + ,(string-append "if [ ! -d " user-dir " ]; then")
> + ,(string-append " mkdir -p " user-dir)
> + ,(string-append " cp -r " output
> + "/games/lib/nethackuserdir/* " user-dir)
> + ,(string-append " chmod -R +w " user-dir)
> + "fi"
> + "RUNDIR=$(mktemp -d)"
> + "cleanup() {"
> + " rm -rf $RUNDIR"
> + "}"
> + "trap cleanup EXIT"
> + "cd $RUNDIR"
> + ,(string-append "for i in " user-dir "/*; do")
> + " ln -s $i $(basename $i)"
> + "done"
> + ,(string-append "for i in " output
> + "/games/lib/nethackdir/*; do")
> + " ln -s $i $(basename $i)"
> + "done"
> + ,(string-append output "/games/nethack"))))
For improved readability, how about:
(call-with-output-file nethack-script
(lambda (port)
(format port "#!~a/bin/sh
first line
second line
…\n"
(assoc-ref inputs "bash"))))
?
Could you send an updated patch? If that’s fine with you, please use:
git format-patch master
in your branch to produce the patch, and then:
git send-email --to=32162 <at> debbugs.gnu.org 000*.patch
to send the patch. That way the commit will get proper attribution.
See <https://www.gnu.org/software/guix/manual/en/html_node/Submitting-Patches.html>.
Let me know if you have any questions.
Thank you!
Ludo’.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32162
; Package
guix-patches
.
(Tue, 17 Jul 2018 18:09:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 32162 <at> debbugs.gnu.org (full text, mbox):
From: Anonymous <mcrfan96 <at> 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32162
; Package
guix-patches
.
(Tue, 17 Jul 2018 18:14:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 32162 <at> debbugs.gnu.org (full text, mbox):
> Rather:
>
> (for-each (lambda (file)
> (install-file file
> (string-append … "/games/lib/nethackuserdir")))
> '(…))
I wasn't able to use install-file, since I want the file to be moved, not
copied. Let me know if there's a guile way to move a file (I couldn't find
one). The other changes are incorporated into the patch which I think I just
send with git send-email.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32162
; Package
guix-patches
.
(Tue, 17 Jul 2018 21:01:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 32162 <at> debbugs.gnu.org (full text, mbox):
Anonymous <mcrfan96 <at> cock.li> skribis:
>> Rather:
>>
>> (for-each (lambda (file)
>> (install-file file
>> (string-append … "/games/lib/nethackuserdir")))
>> '(…))
>
> I wasn't able to use install-file, since I want the file to be moved, not
> copied. Let me know if there's a guile way to move a file (I couldn't find
> one).
You could use ‘rename-file’, which works like rename(2) in C.
> The other changes are incorporated into the patch which I think I just
> send with git send-email.
Alright, thanks!
Ludo’.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32162
; Package
guix-patches
.
(Tue, 17 Jul 2018 21:09:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 32162 <at> debbugs.gnu.org (full text, mbox):
On 7/17/18, 2:07 PM, "Anonymous" <mcrfan96 <at> cock.li> wrote:
On 7/17/18, 2:00 PM, "Ludovic Court=C3=A8s" <ludo <at> gnu.org> wrote:
Anonymous <mcrfan96 <at> cock.li> skribis:
>> Rather:
>>
>> (for-each (lambda (file)
>> (install-file file
>> (string-append … "/games/lib/nethackuserdir")))
>> '(…))
>
> I wasn't able to use install-file, since I want the file to be moved, not
> copied. Let me know if there's a guile way to move a file (I couldn't find
> one).
You could use ‘rename-file’, which works like rename(2) in C.
Unfortunately, rename-file doesn't appear to work on directories, and at
least "save" is a directory. Is it worth trying to address this, or is using "mv" ok?
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32162
; Package
guix-patches
.
(Tue, 17 Jul 2018 21:09:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 32162 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, Jul 17, 2018 at 11:12:47AM -0700, Anonymous wrote:
> > Rather:
> >
> > (for-each (lambda (file)
> > (install-file file
> > (string-append … "/games/lib/nethackuserdir")))
> > '(…))
>
> I wasn't able to use install-file, since I want the file to be moved, not
> copied. Let me know if there's a guile way to move a file (I couldn't find
> one). The other changes are incorporated into the patch which I think I just
> send with git send-email.
You can use rename-file (similar to the `mv` command).
[signature.asc (application/pgp-signature, inline)]
Reply sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
You have taken responsibility.
(Tue, 17 Jul 2018 22:12:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Anonymous <mcrfan96 <at> cock.li>
:
bug acknowledged by developer.
(Tue, 17 Jul 2018 22:12:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 32162-done <at> debbugs.gnu.org (full text, mbox):
mcrfan96 <at> cock.li skribis:
> From: Anonymous <mcrfan96 <at> cock.li>
>
> * gnu/packages/games.scm (nethack): New variable.
Applied with the ‘rename-file’ change.
In a separate commit I enabled reproducible builds: “guix build nethack
--rounds=2 -K” showed that a timestamp was embedded.
Thanks!
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 15 Aug 2018 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 311 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.