unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* guix-pack on package record
@ 2022-08-17 20:38 Olivier Dion via
  2022-08-17 20:59 ` Olivier Dion via
  0 siblings, 1 reply; 4+ messages in thread
From: Olivier Dion via @ 2022-08-17 20:38 UTC (permalink / raw)
  To: help-guix

Hi Guixer,

I would like to use `guix pack` but at the scheme level.  I have package
records that I generate dynamically and would like to pack them
individually in the same way.  Is there an easy way for that?

-- 
Olivier Dion
oldiob.dev



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

* Re: guix-pack on package record
  2022-08-17 20:38 guix-pack on package record Olivier Dion via
@ 2022-08-17 20:59 ` Olivier Dion via
  2022-08-22 15:08   ` zimoun
  0 siblings, 1 reply; 4+ messages in thread
From: Olivier Dion via @ 2022-08-17 20:59 UTC (permalink / raw)
  To: help-guix

On Wed, 17 Aug 2022, Olivier Dion via <help-guix@gnu.org> wrote:
> I would like to use `guix pack` but at the scheme level.  I have package
> records that I generate dynamically and would like to pack them
> individually in the same way.  Is there an easy way for that?

Here's a solution that I've scratch quickly:
--8<---------------cut here---------------start------------->8---

(use-modules
  (guix derivations)
  (guix monads)
  (guix profiles)
  (guix scripts pack)
  (guix store))

(define* (bundle-package package . rest)

  (define manifest (packages->manifest (list package)))
  (define profile (profile (content manifest)))

  (run-with-store (open-connection)
    (mlet %store-monad ((drv (apply self-contained-tarbar
                                    (package-name package)
                                    profile
                                    rest)))
      (mbegin %store-monad
        (built-derivations (list drv))
        (return (derivation->output-path drv))))))
--8<---------------cut here---------------end--------------->8---

It seems to work okay.  Though?

-- 
Olivier Dion
oldiob.dev


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

* Re: guix-pack on package record
  2022-08-17 20:59 ` Olivier Dion via
@ 2022-08-22 15:08   ` zimoun
  2022-08-25  4:24     ` Olivier Dion via
  0 siblings, 1 reply; 4+ messages in thread
From: zimoun @ 2022-08-22 15:08 UTC (permalink / raw)
  To: Olivier Dion, help-guix

Hi Olivier,

On mer., 17 août 2022 at 16:59, Olivier Dion via <help-guix@gnu.org> wrote:

> (define* (bundle-package package . rest)
>
>   (define manifest (packages->manifest (list package)))
>   (define profile (profile (content manifest)))
            –^       –^ 

Well, I do not think the compiler likes that.  From “guix repl”, it
raises the message:

;;; <unknown-location>: warning: possibly unbound variable `content'

and then ’bundle-package’ fails with:

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
error: content: unbound variable


>
>   (run-with-store (open-connection)
>     (mlet %store-monad ((drv (apply self-contained-tarbar
                                                         –^
                                                     typo

It is ’self-contained-tarball’ from (guix scripts pack), I guess.


Otherwise, it does the same thing as “guix pack foo”.

--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,use(gnu packages base)
scheme@(guix-user)> (bundle-package hello)
$1 = "/gnu/store/riyxydg95yyczl6w4dv9j1rd9m1jbq1h-hello.tar.gz"
scheme@(guix-user)> ,q

$ guix pack hello
/gnu/store/0s6z9w6giwjh80ks4f3hwbhb1g9nhh8c-hello-tarball-pack.tar.gz

$ shasum                                                     \
    /gnu/store/riyxydg95yyczl6w4dv9j1rd9m1jbq1h-hello.tar.gz \
    /gnu/store/0s6z9w6giwjh80ks4f3hwbhb1g9nhh8c-hello-tarball-pack.tar.gz 
d326ee555dde564e357e3aa4d66a4497306fc12e  /gnu/store/riyxydg95yyczl6w4dv9j1rd9m1jbq1h-hello.tar.gz
d326ee555dde564e357e3aa4d66a4497306fc12e  /gnu/store/0s6z9w6giwjh80ks4f3hwbhb1g9nhh8c-hello-tarball-pack.tar.gz
--8<---------------cut here---------------end--------------->8---

And “guix package foo” can be done from the REPL using ’guix-pack’ from
(guix scripts pack):

--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,use(guix scripts pack)
scheme@(guix-user)> (guix-pack "hello")
/gnu/store/0s6z9w6giwjh80ks4f3hwbhb1g9nhh8c-hello-tarball-pack.tar.gz
$1 = #t
--8<---------------cut here---------------end--------------->8---

Somehow, bundle-package is a simplified version without all the
“options“.  But hey, it is always cool to unwrap things and have a
better control. :-)  That’s why Guix is so cool! ;-)


Cheers,
simon


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

* Re: guix-pack on package record
  2022-08-22 15:08   ` zimoun
@ 2022-08-25  4:24     ` Olivier Dion via
  0 siblings, 0 replies; 4+ messages in thread
From: Olivier Dion via @ 2022-08-25  4:24 UTC (permalink / raw)
  To: zimoun, help-guix

On Mon, 22 Aug 2022, zimoun <zimon.toutoune@gmail.com> wrote:
> Hi Olivier,
> and then ’bundle-package’ fails with:
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> error: content: unbound variable
>
>
>>
>>   (run-with-store (open-connection)
>>     (mlet %store-monad ((drv (apply self-contained-tarbar
>                                                          –^
>                                                      typo
>
> It is ’self-contained-tarball’ from (guix scripts pack), I guess.

Right my mistake! 

> Somehow, bundle-package is a simplified version without all the
> “options“.  But hey, it is always cool to unwrap things and have a
> better control. :-)  That’s why Guix is so cool! ;-)

Yes!  I'm very happy with the result!  Guix/Guile are very empowering!

-- 
Olivier Dion
oldiob.dev


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

end of thread, other threads:[~2022-08-25  4:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-17 20:38 guix-pack on package record Olivier Dion via
2022-08-17 20:59 ` Olivier Dion via
2022-08-22 15:08   ` zimoun
2022-08-25  4:24     ` Olivier Dion via

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).