all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tobias Geerinckx-Rice <me@tobias.gr>
To: help-guix@gnu.org, Brian Woodcox <bw@inskydata.com>
Subject: Re: Newbie Packaging Question
Date: Sat, 11 May 2019 02:40:33 +0200	[thread overview]
Message-ID: <874l61zuv2.fsf@nckx> (raw)
In-Reply-To: <EA1C726A-90C3-4C9A-A179-3346DD88D37C@inskydata.com>

[-- Attachment #1: Type: text/plain, Size: 2391 bytes --]

Brian,

Brian Woodcox wrote:
> I have a question regarding packaging.
>
> Say I have the following in my sample.scm file:
>
> (define commit "a1ee2ebf087768b5fbffa07f50a294ad9c8ee600")
>
> (define version-date “201903271913”)
>
> and then
>
> (define-public test-me
>   (package
>   (name “test-me”)
>   (version commit)
>   (source …
>                .
>                .
>                . etc...
>
>
> In my modify-phases %standard-phases,  I am trying to use 
> substitute* to patch some files with the version-date define 
> outside my package.
>
> Is this not possible, I always get an unbound variable error.

You've omitted one of the interesting parts (the one where the 
error happens), but I suspect it's something roughly like this:

  (arguments
   '(#:phases
     (modify-phases %standard-phases
      (add-after 'unpack 'uh-oh
       (lambda _
        (substitute* "foo.bar"
         (("198309270000") version-date))
        #t))))) ;          ^^^^^^^^^^^^

(If not: forgive & ignore the basic Scheme lecture below and 
please paste your full package expression :-)

What's happening here is that the value of ARGUMENTS is being 
*quoted* (by the ‘'’ just after ARGUMENTS), meaning that is is not 
immediately evaluated, but passed to the ‘build stage’ as-is.  And 
since VERSION-DATE isn't bound (defined) in the build stage's 
environment, the builder will return the error you're seeing.

Luckily, this is easily fixed:

  (arguments
   `(#:phases
     (modify-phases %standard-phases
      (add-after 'unpack 'uh-oh
       (lambda _
        (substitute* "foo.bar"
         (("198309270000") ,version-date))
        #t))))) ;          ^

Two subtle changes here:

- The ‘'’ (quote) has been changed into a ‘`’ *quasiquote*, which 
  is identical to quote except that it allows *unquoting* inside 
  the quoted expression.

- This unquoting is done by adding ‘,’ to VERSION-DATE.  Any book 
  on Scheme will explain it much better than I can, but here it 
  basically says that you want to send the currently bound *value* 
  of VERSION-DATE to the builder, not the variable name.

(If you've written your package by copying an existing one, you 
might already be using quasiquote without realising it, and all 
that's missing is an unquote.)

Kind regards,

T G-R

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

  reply	other threads:[~2019-05-11  0:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10 23:04 Newbie Packaging Question Brian Woodcox
2019-05-11  0:40 ` Tobias Geerinckx-Rice [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-05-11  3:06 Brian Woodcox

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=874l61zuv2.fsf@nckx \
    --to=me@tobias.gr \
    --cc=bw@inskydata.com \
    --cc=help-guix@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.