From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffPMk-0001Y9-Ox for guix-patches@gnu.org; Tue, 17 Jul 2018 08:46:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffPMg-0004aT-AT for guix-patches@gnu.org; Tue, 17 Jul 2018 08:46:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:39547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffPMg-0004Zu-4u for guix-patches@gnu.org; Tue, 17 Jul 2018 08:46:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ffPMf-0003IO-RY for guix-patches@gnu.org; Tue, 17 Jul 2018 08:46:01 -0400 Subject: [bug#32162] [PATCH] gnu: Add nethack Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: Date: Tue, 17 Jul 2018 14:45:31 +0200 In-Reply-To: (Anonymous's message of "Sat, 14 Jul 2018 22:42:05 -0700") Message-ID: <87tvoy81zo.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Anonymous Cc: 32162@debbugs.gnu.org Hello, Anonymous 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=E2=80=99s 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 =E2=80=9Cbuild-si= de=E2=80=9D code (actions performed when building the derivation), whereas Guix uses Scheme. There=E2=80=99s a bunch of utility functions in the (guix build ut= ils) 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* =E2=80=A6) (invoke =E2=80=A6)) It takes care of chdir=E2=80=99ing back and it=E2=80=99s 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 =E2=80=A6 "/games/lib/nethackuse= rdir"))) '(=E2=80=A6)) > + (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 "bas= h") > + "/bin/bash") > + ,(string-append > + "PATH=3D" > + (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/* " use= r-dir) > + ,(string-append " chmod -R +w " user-dir) > + "fi" > + "RUNDIR=3D$(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 =E2=80=A6\n" (assoc-ref inputs "bash")))) ? Could you send an updated patch? If that=E2=80=99s fine with you, please u= se: git format-patch master in your branch to produce the patch, and then: git send-email --to=3D32162@debbugs.gnu.org 000*.patch to send the patch. That way the commit will get proper attribution. See . Let me know if you have any questions. Thank you! Ludo=E2=80=99.