all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Loading Channels from a file
@ 2021-10-16 21:24 Phil Beadling
  2021-10-17 10:39 ` Phil Beadling
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Beadling @ 2021-10-16 21:24 UTC (permalink / raw)
  To: help-guix

Hi,

I have what I fear may be more of Guile question than a Guix question - but
the context is Guix, so here goes!

If I want to do the following - let's say I'm interested in playing around
with Guix programatically, as it existed on the 3rd October.  The following
works perfectly well and can be passed into "guix repl -- my-script.scm".

(define my-inferior
  (inferior-for-channels my-channels))

Obviously I need to provide a channel definition - to do this I cut and
paste my copy of the channels.scm from the 3rd October directly into a
variable my-channels in the same script and use as per above.

(define my-channels
  (list (channel ;; channel describing the snapshot of Guix itself
         (name 'guix)
         (url "https://git.savannah.gnu.org/git/guix.git")
         (commit
          "20bc9ecc204a610a0d5fa8b88c74421f57dbaf3b") ;; 03/10
         (introduction
          (make-channel-introduction
           "9edb3f66fd807b096b48283debdcddccfea34bad"
           (openpgp-fingerprint
            "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA"))))
        (channel
         (name 'guix-science)
         (url "https://github.com/guix-science/guix-science.git")
         (commit
          "b574aa67743cd4f138fd32efb7c116342f360625") ;; 03/10
         (introduction
          (make-channel-introduction
           "b1fe5aaff3ab48e798a4cce02f0212bc91f423dc"
           (openpgp-fingerprint
            "CA4F 8CF4 37D7 478F DA05  5FD4 4213 7701 1A37 8446"))))))

So far no surprises.  I'd like to make this script a bit more generic so I
want to be able to pass in the channel.scm file as a command line
parameter.  So I've come up with this:

(define my-channels2 (call-with-input-file (option-ref options 'channel #f)
read))

The "(option-ref options 'channel #f)" is just returning a command line
option --channel which is a string of the form "/path/to/my/channels.scm" -
this bit of the code I've tested to death (even replacing the a hardcoded
string to be sure) - it's not the problem.

If I (display my-channels2) it looks correct, but I notice that unlike
(display my-channels) it hasn't evaluated each channel into a channel
structure.

my-channels2 looks like this:
(list (channel (name (quote guix)) (url
https://git.savannah.gnu.org/git/guix.git)....

But my-channels looks like this:
(#<<channel> name: guix url: "https://git.savannah.gnu.org/git/guix.git
".....

It will probably come as no surprise that when I try to feed my-channels2
into inferior-for-channels, I'm getting a type mismatch:

In procedure struct-vtable: Wrong type argument in position 1 (expecting
struct): list

I'm clearly missing something trivial to get the channel definition loaded
from a file into a form the same as when it's hardcoded directly into my
Scheme script.

Can anyone point me in the right direction?

Cheers,
Phil.

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

* Re: Loading Channels from a file
  2021-10-16 21:24 Loading Channels from a file Phil Beadling
@ 2021-10-17 10:39 ` Phil Beadling
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Beadling @ 2021-10-17 10:39 UTC (permalink / raw)
  To: help-guix

To answer my own question somewhat see below - although I need to think a
bit more my my original approach wasn't good enough - the problem I think
it my own understanding of Guile!

On Sat, 16 Oct 2021 at 22:24, Phil Beadling <phil@beadling.co.uk> wrote:

> Hi,
>
> (define my-channels2 (call-with-input-file (option-ref options 'channel
> #f) read))
>
>
Instead of calling read on the file there is a function in (guix ui) called
"load*" which will do the heavy lifting for you:

(define my-channels
  (let ((file (option-ref options 'channel #f)))
    (load* file (make-user-module '((guix channels))))))

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

end of thread, other threads:[~2021-10-17 10:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-16 21:24 Loading Channels from a file Phil Beadling
2021-10-17 10:39 ` Phil Beadling

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.