Re: Building packages in REPL

2021-03-20 Thread Xinglu Chen
On Fri, Jul 24 2020, Ludovic Courtès wrote:

> (guix scripts) has a high-level ‘build-package’ procedure (initially
> written for Emacs-Guix) that can be used like this:
>
> --8<---cut here---start->8---
> $ guix repl
> GNU Guile 3.0.4
> Copyright (C) 1995-2020 Free Software Foundation, Inc.
>
> Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
> This program is free software, and you are welcome to redistribute it
> under certain conditions; type `,show c' for details.
>
> Enter `,help' for help.
> scheme@(guix-user)> ,use(guix)
> scheme@(guix-user)> ,use(guix scripts)
> scheme@(guix-user)> ,use(gnu packages base)
> scheme@(guix-user)> (build-package coreutils)
> $1 = #
> scheme@(guix-user)> ,run-in-store (build-package coreutils)
> /gnu/store/yvsd53rkbvy9q8ak6681hai62nm6rf31-coreutils-8.32-debug
> /gnu/store/n8awazyldv9hbzb7pjcw76hiifmvrpvd-coreutils-8.32
> $2 = #t
> --8<---cut here---end--->8---
>
> HTH!

This is great, but if the build fails I just get an error message, there
is not output regarding where and why it failed.

--8<---cut here---start->8---
scheme@(guile-user)> ,run-in-store (build-package prot-common)
The following derivations will be built:
   /gnu/store/scjj4z453cwh88nlrkbxhllvkdyr90h0-prot-common-0.drv
   /gnu/store/px4b6c5sc819pjdpn53sh12p3ahyja9n-prot-common.el.drv
While executing meta-command:
ERROR:
  1. :
  message: "build of 
`/gnu/store/scjj4z453cwh88nlrkbxhllvkdyr90h0-prot-common-0.drv' failed"
  status: 1
--8<---cut here---end--->8---

Is there way to make it ouput the same thing as it would if I ran `guix
build` on the CLI?





Re: Building packages in REPL

2020-07-27 Thread zimoun
Hi Ludo’,

On Fri, 24 Jul 2020 at 16:38, Ludovic Courtès  wrote:

> (guix scripts) has a high-level ‘build-package’ procedure (initially
> written for Emacs-Guix) that can be used like this:
>
> --8<---cut here---start->8---
> $ guix repl

[...]

> scheme@(guix-user)> ,use(guix)
> scheme@(guix-user)> ,use(guix scripts)
> --8<---cut here---end--->8---

Really cool!

Maybe “build-package“ could be imported with ",use(guix)" or moved
elsewhere than (guix scripts) which is maybe not the natural place.

All the best,
simon



Re: Building packages in REPL

2020-07-27 Thread Pierre Neidhardt
Hi!

Thank you Ludovic for sharing these REPL commands.

I cannot build packages this way in Geiser though, because unless a
substitute is available, the Geiser buffer chokes on the very large
output.

Does anyone know how to work around this limitation?

Does anyone build Guix packages from the Geiser REPL?

Cheers!

-- 
Pierre Neidhardt
https://ambrevar.xyz/


signature.asc
Description: PGP signature


Re: Building packages in REPL

2020-07-24 Thread Ludovic Courtès
Hi,

zimoun  skribis:

> On Fri, 26 Jun 2020 at 06:17, Julien Lepiller  wrote:
>
>> One way to do this with the guix API is to get the derivation, then build it:
>>
>> (use-modules (guix derivations) (guix store) (gnu packages bash))
>> (define package bash-minimal)
>> (define store (open-connection))
>> (define der (package-derivation store package))
>> (build-derivations store (list der))
>>
>> Is that what you want?
>
> Yes, but provides something like:
>
> (use-modules
>  (guix store)
>  (guix derivations)
>  (guix packages))
>  
> (define (build-packages packages)
>   (with-store store
> (let ((builds (map (lambda (package)
>  (package-derivation store package))
>packages)))
>   (build-derivations store builds
>
> (define (build-package package)
>   (build-packages (list package)))

(guix scripts) has a high-level ‘build-package’ procedure (initially
written for Emacs-Guix) that can be used like this:

--8<---cut here---start->8---
$ guix repl
GNU Guile 3.0.4
Copyright (C) 1995-2020 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use(guix)
scheme@(guix-user)> ,use(guix scripts)
scheme@(guix-user)> ,use(gnu packages base)
scheme@(guix-user)> (build-package coreutils)
$1 = #
scheme@(guix-user)> ,run-in-store (build-package coreutils)
/gnu/store/yvsd53rkbvy9q8ak6681hai62nm6rf31-coreutils-8.32-debug
/gnu/store/n8awazyldv9hbzb7pjcw76hiifmvrpvd-coreutils-8.32
$2 = #t
--8<---cut here---end--->8---

HTH!

Ludo’.



Re: Building packages in REPL

2020-06-30 Thread Anthony Quizon
Cool thanks. I'll try these out

On Saturday, June 27, 2020, Efraim Flashner  wrote:

> On Fri, Jun 26, 2020 at 12:00:17PM +0200, zimoun wrote:
> > Dear,
> >
> > On Fri, 26 Jun 2020 at 09:25, Konrad Hinsen 
> wrote:
> > > Anthony Quizon  writes:
> > >
> > >> Is there a way that I can build a package via the repl?
> >
> > Well, it is not what you are asking I guess, but it is possible:
> >
> > --8<---cut here---start->8---
> > $ guix repl
> > scheme@(guix-user)> (use-modules (guix scripts build))
> > scheme@(guix-user)> (guix-build "-L" "." "bonjour")
> > /gnu/store/m658csbnly6zywfl5nax9glya3rzhbdy-bonjour-2.10
> > --8<---cut here---end--->8---
> >
>
> As a side note, the various guix-foo commands from guix/scripts/* have
> an undefined return value so you can't check for #t or anything to see
> if a package built.
>
> --
> Efraim Flashner  אפרים פלשנר
> GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
> Confidentiality cannot be guaranteed on emails sent or received unencrypted
>


Re: Building packages in REPL

2020-06-26 Thread Efraim Flashner
On Fri, Jun 26, 2020 at 12:00:17PM +0200, zimoun wrote:
> Dear,
> 
> On Fri, 26 Jun 2020 at 09:25, Konrad Hinsen  
> wrote:
> > Anthony Quizon  writes:
> >
> >> Is there a way that I can build a package via the repl?
> 
> Well, it is not what you are asking I guess, but it is possible:
> 
> --8<---cut here---start->8---
> $ guix repl
> scheme@(guix-user)> (use-modules (guix scripts build))
> scheme@(guix-user)> (guix-build "-L" "." "bonjour")
> /gnu/store/m658csbnly6zywfl5nax9glya3rzhbdy-bonjour-2.10
> --8<---cut here---end--->8---
> 

As a side note, the various guix-foo commands from guix/scripts/* have
an undefined return value so you can't check for #t or anything to see
if a package built.

-- 
Efraim Flashner  אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted


signature.asc
Description: PGP signature


Re: Building packages in REPL

2020-06-26 Thread zimoun
Hi Julien,

On Fri, 26 Jun 2020 at 06:17, Julien Lepiller  wrote:

> One way to do this with the guix API is to get the derivation, then build it:
>
> (use-modules (guix derivations) (guix store) (gnu packages bash))
> (define package bash-minimal)
> (define store (open-connection))
> (define der (package-derivation store package))
> (build-derivations store (list der))
>
> Is that what you want?

Yes, but provides something like:

--8<---cut here---start->8---
(use-modules
 (guix store)
 (guix derivations)
 (guix packages))
 
(define (build-packages packages)
  (with-store store
(let ((builds (map (lambda (package)
 (package-derivation store package))
   packages)))
  (build-derivations store builds

(define (build-package package)
  (build-packages (list package)))
--8<---cut here---end--->8---

Because otherwise, you need to know "package-derivation" and
"build-derivation" and where they are (I run 'ag' or 'git-grep'
to find them which is not handy).  And for example, I knew it was
possible but it was not "obvious". :-)

Cheers,
simon






Re: Building packages in REPL

2020-06-26 Thread Julien Lepiller
Le 26 juin 2020 06:00:17 GMT-04:00, zimoun  a écrit :
>Dear,
>
>On Fri, 26 Jun 2020 at 09:25, Konrad Hinsen
> wrote:
>> Anthony Quizon  writes:
>>
>>> Is there a way that I can build a package via the repl?
>
>Well, it is not what you are asking I guess, but it is possible:
>
>--8<---cut here---start->8---
>$ guix repl
>scheme@(guix-user)> (use-modules (guix scripts build))
>scheme@(guix-user)> (guix-build "-L" "." "bonjour")
>/gnu/store/m658csbnly6zywfl5nax9glya3rzhbdy-bonjour-2.10
>--8<---cut here---end--->8---
>
>And there is no '~' expansion so "-L" "~/somewhere" does not work.
>
>> As far as I know, no. I have been looking for this as well,
>> in order to make package development more interactive.
>
>Well, I do not know enough the API but it should be added and exposed
>if
>it does not exist yet.  And the question is which level of granularity?
>
>
>>> For example,
>>> If I had a channel with a custom package in it, can I do:
>>>
>>> `$ guix repl -L .`
>>> `> ,use (my-channel packages base) `
>>> `> (build-package my-package) ;; this is the example imaginary
>command `
>
>The entry point is "(guix scripts build)".
>
>> I'd even want more: access to the individual build steps.
>
>Do you mean the "phases"?
>
>
>All the best,
>simon

One way to do this with the guix API is to get the derivation, then build it:

(use-modules (guix derivations) (guix store) (gnu packages bash))
(define package bash-minimal)
(define store (open-connection))
(define der (package-derivation store package))
(build-derivations store (list der))

Is that what you want?



Re: Building packages in REPL

2020-06-26 Thread zimoun
Dear,

On Fri, 26 Jun 2020 at 09:25, Konrad Hinsen  wrote:
> Anthony Quizon  writes:
>
>> Is there a way that I can build a package via the repl?

Well, it is not what you are asking I guess, but it is possible:

--8<---cut here---start->8---
$ guix repl
scheme@(guix-user)> (use-modules (guix scripts build))
scheme@(guix-user)> (guix-build "-L" "." "bonjour")
/gnu/store/m658csbnly6zywfl5nax9glya3rzhbdy-bonjour-2.10
--8<---cut here---end--->8---

And there is no '~' expansion so "-L" "~/somewhere" does not work.

> As far as I know, no. I have been looking for this as well,
> in order to make package development more interactive.

Well, I do not know enough the API but it should be added and exposed if
it does not exist yet.  And the question is which level of granularity?


>> For example,
>> If I had a channel with a custom package in it, can I do:
>>
>> `$ guix repl -L .`
>> `> ,use (my-channel packages base) `
>> `> (build-package my-package) ;; this is the example imaginary command `

The entry point is "(guix scripts build)".

> I'd even want more: access to the individual build steps.

Do you mean the "phases"?


All the best,
simon



Re: Building packages in REPL

2020-06-26 Thread Konrad Hinsen
Anthony Quizon  writes:

> Is there a way that I can build a package via the repl?

As far as I know, no. I have been looking for this as well,
in order to make package development more interactive.

> For example,
> If I had a channel with a custom package in it, can I do:
>
> `$ guix repl -L .`
> `> ,use (my-channel packages base) `
> `> (build-package my-package) ;; this is the example imaginary command `

I'd even want more: access to the individual build steps.

Konrad