GNU Guix: A Planet for Guix
I am pleased to announce the availability of Planet
Guix, an Atom and RSS aggregator covering all
things Guix. You can browse posts on the website or use your favourite feed
reader to subscribe to the aggregate feed.
Planet Guix already has subscriptions to 19 blogs from around the community;
if you write about Guix (no matter how infrequently) and would like your blog to
be included, or if you would like to suggest another blog I missed, please
create a pull request against the repository in
Codeberg — you'll see that the
subscriptions are simply configured as association lists in planet/config.scm.
Background
Back in September, Sébastien Gendre asked on the help-guix mailing
list if
there were any plans to create a Planet website for Guix. The discussion drifted
into how this might be implemented in Guile, and I thought it sounded like an
interesting project for the dark autumn evenings.
The original Planet aggregator was written in Python and many Planet websites
are still using its successor, Venus. The Venus
code base has not seen much activity in the last decade and still uses Python 2,
which was sunset in 2020. This was all the incentive I needed to implement a new
Planet aggregator and static site generator in Guile.
Implementation
We already know from the likes of
Haunt that Guile has all the tools
needed to generate a static web site. Both Atom and RSS are XML formats, and
Guile also has great support for working with XML. The Guile Planet
implementation uses the following built-in modules:
(web client)
to fetch the feeds.(sxml simple)
for reading the Atom/RSS feeds and writing the aggregate Atom feed.(sxml xpath)for
searching the feeds to extract the data of interest.(sxml transform)
for sanitizing HTML in the entry summaries.
Many feeds include HTML content in the entry summary, which we need to parse.
This is where htmlprag
from guile-lib comes in. I used this both
to parse HTML embedded in feeds and to generate the static content from an
SXML data
structure.
With these libraries to hand the code for the planet aggregator almost wrote itself!
I was trying to keep dependencies to a minimum, but
guile-filesystem
is too useful to do without and, later in the development process, I pulled in
guile-srfi-235 which
provides some useful combinators. At the moment I'm only using apply-chain to
build a function for post-processing one of the feeds, but why re-invent the
wheel?
Deployment
I initially deployed the Planet to a test site running on one of my servers, but
the idea was received enthusiastically by the Guix maintainers and I was happy
that they wanted to host it on their infrastructure.
Of course they are using Guix to manage their virtual machines in Hetzner cloud!
While they could have picked up the Planet code and run with it, instead they
pointed me at the server configuration
and invited me to make a pull request against hydra/guix-hetzner-2.scm.
They suggested I base the configuration on their existing
static-web-site-configuration so I started reading the code which proved very
educational (I admit that I had to sleep on it for a week before coming up
with a plan!)
The static-web-site-configuration did almost everything needed to build the
Planet aggregator, only the build step runs like a Guix package build in an
isolated environment with no network - so we cannot fetch the feeds in this
build step.
Luckily, I had already implemented functionality in the Planet code base to
build the static site from feeds cached on disk. So it was simply a case of
adding support for a pre-build script to the static-web-site-configuration
and using this step to download the feeds.
The pull request was merged after some short discussion, and a few days later the
site was live in its new home.
Community
This was my second time contributing to the Guix project and I'm pleased to
report that it was a smooth experience both times. When it came to the
deployment, I was glad that I was encouraged to add the service configuration
myself instead of being spoon-fed: working with computers, you learn best by
doing.
I'd like to give a shout-out to @civodul, @cbaines, and @apteryx for their help
with the deployment, and to the several people who sent merge requests to add
their blogs before I even got around to writing this announcement.
I think the Planet site is already a great place to discover people writing
about Guix, and I hope it grows and becomes an asset to the community. Happy reading!
Source: Planet GNU