all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Anonymous <mcrfan96@cock.li>
Cc: 32162@debbugs.gnu.org
Subject: [bug#32162] [PATCH] gnu: Add nethack
Date: Tue, 17 Jul 2018 14:45:31 +0200	[thread overview]
Message-ID: <87tvoy81zo.fsf@gnu.org> (raw)
In-Reply-To: <b3cae3b3-45a6-a3c4-d3a3-fb14f47ae022@cock.li> (Anonymous's message of "Sat, 14 Jul 2018 22:42:05 -0700")

Hello,

Anonymous <mcrfan96@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@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’.

  reply	other threads:[~2018-07-17 12:46 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 [this message]
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
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=87tvoy81zo.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=32162@debbugs.gnu.org \
    --cc=mcrfan96@cock.li \
    /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.