Hi!

Alexis Simon <[email protected]> writes:

> Hi Guix,
>
> I am wondering how I could easily make a script to build all packages that are
> defined in my local channel.
>
> This would be an easy way to make a local "CI" to test changes without setting
> up a full fledged CI server.
>
> I don't know where to start, any pointers or examples of small scripts doing
> that?

I had no idea how to do this, but it sounds interesting, so I took some
time to experiment.  Under the condition that all packages in your
channel are under some directory path (which would typically be the
case), it seems you can use something like this:

guix build -L /home/alexis/my/channel -e '
  (use-modules (gnu packages) (guix))
  (fold-packages (lambda (pkg lst)
                   (if (string-prefix? "/home/alexis/my/channel"
                                       (location-file (package-location pkg)))
                       (cons pkg lst)
                       lst))
                 (quote ()))'

This seems to find all packages under some directory and then build
them.

Two key pieces of information are that just importing (gnu packages)
causes a scan of all .scm files in load path for defined packages, and
after that fold-packages allows you to fold over the set of all packages
known to Guix.

Hope this helps,
Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

Reply via email to