Subject: Channels!

From: [email-masked] (Ludovic Courtès)
Date: Tue, 28 Aug 2018 17:16:29 +0200

Hi Guix!

[email-masked] (Ludovic Courtès) skribis:

>   • Have a “channel” mechanism, similar to ‘nix-channel’, that would
>     allow users to have several Guix variants available in parallel
>     instead of just “latest”.  Could work like this:
>
>       guix channel add latest git://git.sv.gnu.org/guix.git master
>       guix channel add stable git://git.sv.gnu.org/guix.git stable
>       guix channel pull latest
>       guix channel set latest
>       # here i see the latest versions of everything
>       guix channel set stable
>       # and here everything is old but super stable ;-)

The patches that follow implement this last bit, though in a slightly
different way.  Users would now have the option to provide
~/.config/guix/channels.scm along these lines:

  (cons (channel
         (name 'guix-hpc)
         (url "https://gitlab.inria.fr/guix-hpc/guix-hpc.git")
         (branch "origin/master"))
        %default-channels)

‘guix pull’ then pulls both from ‘%default-channels’, a one-element list
containing our Savannah repo, and from that ‘guix-hpc’ repo.  It builds
both Guix itself and the modules in ‘guix-hpc’, with a dependency on the
just-built Guix.  The ~/.config/guix/current profile then contains two
entries:

--8<---------------cut here---------------start------------->8---
$ guix pull -l
[…]
Generacio 18	Aug 27 2018 09:54:40
  guix 1ca5499
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: origin/master
    commit: 1ca54999db34b0197e6c7fa3f0a852fc0d193e70
  10 new packages: avogadro, emacs-git-annex, find-circ, guile-aa-tree, lepton-eda, r-a3,
    r-abcanalysis, r-manipulatewidget, r-miniui, r-slam
  43 packages upgraded: [email-masked], [email-masked], [email-masked], [email-masked], [email-masked],
    [email-masked], [email-masked], [email-masked], [email-masked],
    [email-masked], [email-masked], [email-masked], [email-masked],
    [email-masked], [email-masked], [email-masked], [email-masked], [email-masked],
    [email-masked], [email-masked], [email-masked], [email-masked], [email-masked],
    [email-masked], [email-masked], [email-masked], [email-masked], [email-masked],
    parallel@20180822, [email-masked], [email-masked], [email-masked], [email-masked], [email-masked],
    [email-masked], [email-masked], [email-masked], [email-masked], [email-masked], [email-masked],
    [email-masked], [email-masked], [email-masked]
Generacio 19	Aug 27 2018 16:20:48
  guix d894ab8
    repository URL: file:///home/ludo/src/guix
    branch: origin/wip-channels
    commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  guix-hpc dd3df5e
    repository URL: file:///home/ludo/src/guix-hpc
    branch: origin/wip-channel-test
    commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  11 new packages: chameleon, eztrace, fxt, litl, maphys, pastix, simgrid, starpu, starpu,
    starpu-fxt, starpu-simgrid
  4 packages upgraded: [email-masked], [email-masked],
    [email-masked], [email-masked]
--8<---------------cut here---------------end--------------->8---

GUIX_PACKAGE_PATH is no longer needed (though it’s still supported):
~/.config/guix/current/bin/guix automatically finds packages defined in
the ‘guix-hpc’ channel.

The only missing bit for this patch series is documentation for channels
(including a prominent disclaimer about API compatibility).  I’ll write
it if people agree with the overall approach.

Implementation
~~~~~~~~~~~~~~

(guix channels) implements the “channel” and “channel instance”
abstractions.  It provides tools to get the latest instance of channel
and to build a list of instances.  There must always be a channel called
‘guix’, which all other instances depend on.

(guix scripts pull) now does little more than implementing the CLI,
while (guix channels) does all the heavy lifting.

Limitations
~~~~~~~~~~~

Currently third-party channels are expected to provide nothing but
package modules.  Those package modules should live at the root of the
repository; for example, the modules/ directory at
https://gitlab.inria.fr/guix-hpc/guix-hpc doesn’t work, you have to
“git mv modules/inria .” for things to work.

Both limitations could be lifted by honoring a special meta-data file in
repositories.  But I think that can come later.

Third-party channels currently all implicitly depend on the ‘guix’
channel, but it’s not possible to express dependencies among channels.
It may be useful, but it can probably come later, too.

If a channel fails to build, the user gets a backtrace and it’s up to
them to figure out what to do.  May need to be improved.  :-)

Not really a limitation, but (guix describe) relies on argv[0] to find
channel meta-data.  I’m not a fan of that but it works in practice.
More importantly, it’s the only way I could think of to retrieve
“silent” meta-data (repo URL, commit, etc.) as well as channel
directories where packages should be searched for.

Future work
~~~~~~~~~~~

With (guix channels) we’ll be able to implement things like “open an
inferior corresponding to commit X”.  In turn, that means we can support
commit IDs in manifests, and then “guix package -m manifest.scm” will
open an inferior for the requested commit ID and instantiate the thing.

With (guix describe) we can, of course, implement a ‘guix describe’
command.  We can also improve provenance tracking, for instance by
storing as a manifest entry property the channel instance an installed
package comes from.

Thoughts?  Ricardo?

Thanks in advance for your feedback!

Ludo’.