unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Julien Lepiller <julien@lepiller.eu>
To: help-guix@gnu.org,divoplade <d@divoplade.fr>
Subject: Re: Newbie tries to add a snippet to an origin
Date: Sat, 01 Aug 2020 11:50:50 -0400	[thread overview]
Message-ID: <3ED58746-B570-4AE0-B387-606A10300EA3@lepiller.eu> (raw)
In-Reply-To: <9c55ce7f472fe3c84c84a31073f10dce6f7fae92.camel@divoplade.fr>

I don't think this is how you are supposed to use snippet :). It's code executed from the root of the sources that changes it. Then guix repacks the modified sources and the result is the source for tge package. Look at the code in guix for more examples. Here's what I suggest:

(source (origin
  …
  (modules '((guix build utils)))
  (snipet
   `(begin
       (with-output-to-file ".tarball-version"
         (lambda _
           (format #t "~a~%" ,version)))
       #t))))

Of course version needs to be defined in this context (usually as a field in the package definition, but I'm not sure what dist-package is). You can use any other name or the result of any scheme function, like (package-version pomdappi) if you prefer.

HTH!

Le 1 août 2020 11:17:36 GMT-04:00, divoplade <d@divoplade.fr> a écrit :
>Hello,
>
>I am trying to add a file named ".tarball-version" containing a fixed
>string at the root of my source.
>
>I tried several things, the most promising (I think) being this:
>
>(define-public pomdappi-dist
>  (dist-package
>   pomdappi
>   (origin
>     (method git-fetch)
>     (uri (git-reference
>           (url "@REPO@")
>           (commit "@COMMIT@")))
>     (sha256
>      (base32
>       "@COMMIT_BASE32@"))
>     (snippet
>      #~(symlink #$(plain-file ".tarball-version" "@VERSION@")
>                 ".tarball-version")))))
>
>However, I get "guix build: error: invalid name: `.tarball-version'"
>when running guix build.
>
>My idea was to create a file in the store containing the fixed string
>@VERSION@, and then symlink it withing the source as ".tarball-
>version".
>
>Could someone help me?
>
>divoplade

  parent reply	other threads:[~2020-08-01 15:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01 15:17 Newbie tries to add a snippet to an origin divoplade
2020-08-01 15:26 ` John Soo
2020-08-01 15:44   ` divoplade
2020-08-01 15:50 ` Julien Lepiller [this message]
2020-08-01 16:00   ` John Soo
2020-08-01 16:23     ` divoplade
2020-08-01 16:27       ` John Soo

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=3ED58746-B570-4AE0-B387-606A10300EA3@lepiller.eu \
    --to=julien@lepiller.eu \
    --cc=d@divoplade.fr \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).