Subject: [bug#44800] [PATCH v2 2/3] publish: Add avahi support.

From: Ludovic Courtès <[email-masked]>
Date: Fri, 27 Nov 2020 18:12:25 +0100

Hi,

Mathieu Othacehe <[email-masked]> skribis:

> * guix/scripts/publish.scm (%options): Add "--enable-avahi" option.
> (show-help): Document it.
> (service-name): New procedure,
> (publish-service-type): new variable.
> (run-publish-server): Add "avahi?" and "port" parameters. Use them to publish
> the server using Avahi.
> (guix-publish): Pass the "avahi?" option to "run-publish-server".
> * gnu/services/base.scm (<guix-publish-configuration>): Add "enable-avahi?"
> field.
> (guix-publish-shepherd-service): Honor it.

Neat!

> +When the @option{--enable-avahi} option is passed, the publish server is
> +advertised on the local network as an Avahi service, using Guile-Avahi
> +bindings.

s/bindings/(@pxref{Top,,, guile-avahi, Using Avahi in Guile Scheme Programs}/

As discussed on IRC, I would avoid using the name Avahi on the CLI and
to some extent in the API as well.  The command-line option could be
“--advertise”.

The documentation would be something like:

  … the server advertises its availability on the local network using
  multicast DNS (mDNS) and DNS service discovery (DNS-SD), currently
  @i{via} Guile-Avahi …

(I remember that Julien posted a DNS client implementation a few years
ago, we never know what the future will be like…  :-))

> +  (enable-avahi? guix-publish-enable-avahi?       ;boolean
> +                 (default #f))

Same here.

>  (define* (run-publish-server socket store
>                               #:key
> +                             avahi? port
>                               (compressions (list %no-compression))
>                               (nar-path "nar") narinfo-ttl
>                               cache pool)
> +  (when avahi?
> +    (avahi-publish-service-thread (service-name)
> +                                  #:type publish-service-type
> +                                  #:port port))

Maybe add (info (_ "advertising …")) here.  Ideally, you’d need a
callback because you can’t tell what the actual advertised name is since
Avahi can pick one to avoid name clashes.

Thanks,
Ludo’.