unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* How do I build a derivation with guix build?
@ 2020-09-05 20:15 divoplade
  2020-09-06  2:40 ` Timothy Sample
  0 siblings, 1 reply; 3+ messages in thread
From: divoplade @ 2020-09-05 20:15 UTC (permalink / raw)
  To: help-guix

Hello,

I am still learning how to use gexps, and I thought that running this
would work:

guix build -f example.scm

with example.scm containing:

(use-modules (gnu packages base))
(use-modules (guix gexp))

(define build-exp
  #~(begin
      (mkdir #$output)
      (chdir #$output)
      (symlink (string-append #$coreutils "/bin/ls")
               "list-files")))

(gexp->derivation "the-thing" build-exp)

This is a copy of what's on the manual for explaining G-expressions.

The guix build -f command should, according to the --help output:
"build the package or derivation that the code within FILE evaluates
to"

However, I get an exception, "Wrong number of arguments to #<procedure
7f775f854f00 at guix/gexp.scm:1064:2 (state)>", after a backtrace that
does not even contains example.scm.

What is going on? How do you build the derivation?

Best regards,

divoplade



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How do I build a derivation with guix build?
  2020-09-05 20:15 How do I build a derivation with guix build? divoplade
@ 2020-09-06  2:40 ` Timothy Sample
  2020-09-06  9:02   ` divoplade
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy Sample @ 2020-09-06  2:40 UTC (permalink / raw)
  To: divoplade; +Cc: help-guix

Hi divoplade,

As I understand it, ‘gexp->derivation’ returns a value in the store
monad.  I’m not sure why ‘guix build’ doesn’t know how to use it
directly, but you can get at the derivation by wrapping it with
‘run-with-store’:

    (run-with-store (open-connection)
      (gexp->derivation "the-thing" build-exp))

Don’t forget to use the ‘(guix store)’ module for this.

But!  There’s a better way!!  :)

You can use the “declarative interface”.  Just replace
‘gexp->derivation’ with ‘computed-file’:

    (computed-file "the-thing" build-exp)

Now there’s no need for ‘(guix store)’.

HTH!


-- Tim

divoplade <d@divoplade.fr> writes:

> Hello,
>
> I am still learning how to use gexps, and I thought that running this
> would work:
>
> guix build -f example.scm
>
> with example.scm containing:
>
> (use-modules (gnu packages base))
> (use-modules (guix gexp))
>
> (define build-exp
>   #~(begin
>       (mkdir #$output)
>       (chdir #$output)
>       (symlink (string-append #$coreutils "/bin/ls")
>                "list-files")))
>
> (gexp->derivation "the-thing" build-exp)
>
> This is a copy of what's on the manual for explaining G-expressions.
>
> The guix build -f command should, according to the --help output:
> "build the package or derivation that the code within FILE evaluates
> to"
>
> However, I get an exception, "Wrong number of arguments to #<procedure
> 7f775f854f00 at guix/gexp.scm:1064:2 (state)>", after a backtrace that
> does not even contains example.scm.
>
> What is going on? How do you build the derivation?
>
> Best regards,
>
> divoplade


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How do I build a derivation with guix build?
  2020-09-06  2:40 ` Timothy Sample
@ 2020-09-06  9:02   ` divoplade
  0 siblings, 0 replies; 3+ messages in thread
From: divoplade @ 2020-09-06  9:02 UTC (permalink / raw)
  To: Timothy Sample; +Cc: help-guix

Hello,

Le samedi 05 septembre 2020 à 22:40 -0400, Timothy Sample a écrit :
> As I understand it, ‘gexp->derivation’ returns a value in the store
> monad.  I’m not sure why ‘guix build’ doesn’t know how to use it
> directly, but you can get at the derivation by wrapping it with
> ‘run-with-store’:
> 
>     (run-with-store (open-connection)
>       (gexp->derivation "the-thing" build-exp))
> 
> Don’t forget to use the ‘(guix store)’ module for this.
OK, I think I understand:

    "you exit a monad like you exit a building on fire: by running"

So, I cannot simply return a monadic value to guix build. It needs a
real value.

> 
> But!  There’s a better way!!  :)
> 
> You can use the “declarative interface”.  Just replace
> ‘gexp->derivation’ with ‘computed-file’:
> 
>     (computed-file "the-thing" build-exp)
> 
> Now there’s no need for ‘(guix store)’.

Thank you, that was exactly what I was looking for!

divoplade



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-06  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05 20:15 How do I build a derivation with guix build? divoplade
2020-09-06  2:40 ` Timothy Sample
2020-09-06  9:02   ` divoplade

unofficial mirror of help-guix@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guix-user/0 guix-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-user guix-user/ https://yhetil.org/guix-user \
		help-guix@gnu.org
	public-inbox-index guix-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.user
	nntp://news.gmane.io/gmane.comp.gnu.guix.user


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git