services: avahi: Deprecate the 'avahi-service' procedure.

* gnu/services/avahi.scm (<avahi-configuration>): Export getters.  Add
default values.
(avahi-service-type)[default-value]: New field.
(avahi-service): Mark as deprecated.
* gnu/services/desktop.scm (%desktop-services): Use the 'service' form
instead of calling 'avahi-service'.
* gnu/tests/base.scm (%avahi-os): Likewise.
* doc/guix.texi (Base Services): Adjust example accordingly.
(Networking Services): Update accordingly.
This commit is contained in:
Ludovic Courtès 2019-01-16 11:18:34 +01:00
parent 39ad752cf9
commit 2e04ab7147
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
4 changed files with 86 additions and 40 deletions

View File

@ -10848,7 +10848,9 @@ system, you will want to append services to @var{%base-services}, like
this: this:
@example @example
(cons* (avahi-service) (lsh-service) %base-services) (cons* (service avahi-service-type)
(service openssh-service-type)
%base-services)
@end example @end example
@end defvr @end defvr
@ -12709,31 +12711,54 @@ browsers, from accessing Facebook.
The @code{(gnu services avahi)} provides the following definition. The @code{(gnu services avahi)} provides the following definition.
@deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @ @defvr {Scheme Variable} avahi-service-type
[#:host-name #f] [#:publish? #t] [#:ipv4? #t] @ This is the service that runs @command{avahi-daemon}, a system-wide
[#:ipv6? #t] [#:wide-area? #f] @
[#:domains-to-browse '()] [#:debug? #f]
Return a service that runs @command{avahi-daemon}, a system-wide
mDNS/DNS-SD responder that allows for service discovery and mDNS/DNS-SD responder that allows for service discovery and
"zero-configuration" host name lookups (see @uref{http://avahi.org/}), and ``zero-configuration'' host name lookups (see @uref{http://avahi.org/}).
extends the name service cache daemon (nscd) so that it can resolve Its value must be a @code{zero-configuration} record---see below.
@code{.local} host names using
@uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally,
add the @var{avahi} package to the system profile so that commands such as
@command{avahi-browse} are directly usable.
If @var{host-name} is different from @code{#f}, use that as the host name to This service extends the name service cache daemon (nscd) so that it can
resolve @code{.local} host names using
@uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
Service Switch}, for information on host name resolution.
Additionally, add the @var{avahi} package to the system profile so that
commands such as @command{avahi-browse} are directly usable.
@end defvr
@deftp {Data Type} avahi-configuration
Data type representation the configuration for Avahi.
@table @asis
@item @code{host-name} (default: @code{#f})
If different from @code{#f}, use that as the host name to
publish for this machine; otherwise, use the machine's actual host name. publish for this machine; otherwise, use the machine's actual host name.
When @var{publish?} is true, publishing of host names and services is allowed; @item @code{publish?} (default: @code{#t})
in particular, avahi-daemon will publish the machine's host name and IP When true, allow host names and services to be published (broadcast) over the
address via mDNS on the local network. network.
When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled. @item @code{publish-workstation?} (default: @code{#t})
When true, @command{avahi-daemon} publishes the machine's host name and IP
address via mDNS on the local network. To view the host names published on
your local network, you can run:
Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6 @example
sockets. avahi-browse _workstation._tcp
@end deffn @end example
@item @code{wide-area?} (default: @code{#f})
When true, DNS-SD over unicast DNS is enabled.
@item @code{ipv4?} (default: @code{#t})
@itemx @code{ipv6?} (default: @code{#t})
These fields determine whether to use IPv4/IPv6 sockets.
@item @code{domains-to-browse} (default: @code{'()})
This is a list of domains to browse.
@end table
@end deftp
@deffn {Scheme Variable} openvswitch-service-type @deffn {Scheme Variable} openvswitch-service-type
This is the type of the @uref{http://www.openvswitch.org, Open vSwitch} This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
@ -22303,8 +22328,8 @@ want is to have @code{.local} host lookup working.
Note that, in this case, in addition to setting the Note that, in this case, in addition to setting the
@code{name-service-switch} of the @code{operating-system} declaration, @code{name-service-switch} of the @code{operating-system} declaration,
you also need to use @code{avahi-service} (@pxref{Networking Services, you also need to use @code{avahi-service-type} (@pxref{Networking Services,
@code{avahi-service}}), or @var{%desktop-services}, which includes it @code{avahi-service-type}}), or @var{%desktop-services}, which includes it
(@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
to the name service cache daemon (@pxref{Base Services, to the name service cache daemon (@pxref{Base Services,
@code{nscd-service}}). @code{nscd-service}}).

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -24,9 +24,22 @@
#:use-module (gnu system shadow) #:use-module (gnu system shadow)
#:use-module (gnu packages avahi) #:use-module (gnu packages avahi)
#:use-module (gnu packages admin) #:use-module (gnu packages admin)
#:use-module (guix deprecation)
#:use-module (guix records) #:use-module (guix records)
#:use-module (guix gexp) #:use-module (guix gexp)
#:export (avahi-configuration #:export (avahi-configuration
avahi-configuration?
avahi-configuration-avahi
avahi-configuration-debug?
avahi-configuration-host-name
avahi-configuration-publish?
avahi-configuration-publish-workstation?
avahi-configuration-ipv4?
avahi-configuration-ipv6?
avahi-configuration-wide-area?
avahi-configuration-domains-to-browse
avahi-service avahi-service
avahi-service-type)) avahi-service-type))
@ -37,7 +50,6 @@
;;; ;;;
;;; Code: ;;; Code:
;; TODO: Export.
(define-record-type* <avahi-configuration> (define-record-type* <avahi-configuration>
avahi-configuration make-avahi-configuration avahi-configuration make-avahi-configuration
avahi-configuration? avahi-configuration?
@ -45,18 +57,24 @@
(default avahi)) (default avahi))
(debug? avahi-configuration-debug? ;Boolean (debug? avahi-configuration-debug? ;Boolean
(default #f)) (default #f))
(host-name avahi-configuration-host-name) ;string (host-name avahi-configuration-host-name ;string | #f
(publish? avahi-configuration-publish?) ;Boolean (default #f))
(publish? avahi-configuration-publish? ;boolean
(default #t))
;; The default for this was #t in Avahi 0.6.31 and became #f in 0.7. For ;; The default for this was #t in Avahi 0.6.31 and became #f in 0.7. For
;; now we stick to the old default. ;; now we stick to the old default.
(publish-workstation? avahi-configuration-publish-workstation? ;Boolean (publish-workstation? avahi-configuration-publish-workstation? ;Boolean
(default #t)) (default #t))
(ipv4? avahi-configuration-ipv4?) ;Boolean (ipv4? avahi-configuration-ipv4? ;Boolean
(ipv6? avahi-configuration-ipv6?) ;Boolean (default #t))
(wide-area? avahi-configuration-wide-area?) ;Boolean (ipv6? avahi-configuration-ipv6? ;Boolean
(domains-to-browse avahi-configuration-domains-to-browse)) ;list of strings (default #t))
(wide-area? avahi-configuration-wide-area? ;Boolean
(default #f))
(domains-to-browse avahi-configuration-domains-to-browse ;list of strings
(default '())))
(define* (configuration-file config) (define* (configuration-file config)
"Return an avahi-daemon configuration file based on CONFIG, an "Return an avahi-daemon configuration file based on CONFIG, an
@ -145,14 +163,16 @@ service switch (NSS) with support for @code{.local} host name resolution.")
;; Provide 'avahi-browse', 'avahi-resolve', etc. in ;; Provide 'avahi-browse', 'avahi-resolve', etc. in
;; the system profile. ;; the system profile.
(service-extension profile-service-type (service-extension profile-service-type
avahi-package)))))) avahi-package)))
(default-value (avahi-configuration)))))
(define* (avahi-service #:key (avahi avahi) debug? (define-deprecated (avahi-service #:key (avahi avahi) debug?
host-name host-name
(publish? #t) (publish? #t)
(ipv4? #t) (ipv6? #t) (ipv4? #t) (ipv6? #t)
wide-area? wide-area?
(domains-to-browse '())) (domains-to-browse '()))
avahi-service-type
"Return a service that runs @command{avahi-daemon}, a system-wide "Return a service that runs @command{avahi-daemon}, a system-wide
mDNS/DNS-SD responder that allows for service discovery and mDNS/DNS-SD responder that allows for service discovery and
\"zero-configuration\" host name lookups (see @uref{http://avahi.org/}), and \"zero-configuration\" host name lookups (see @uref{http://avahi.org/}), and

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Andy Wingo <wingo@igalia.com> ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com> ;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
@ -986,7 +986,7 @@ as expected.")))
;; The D-Bus clique. ;; The D-Bus clique.
(service network-manager-service-type) (service network-manager-service-type)
(service wpa-supplicant-service-type) ;needed by NetworkManager (service wpa-supplicant-service-type) ;needed by NetworkManager
(avahi-service) (service avahi-service-type)
(udisks-service) (udisks-service)
(upower-service) (upower-service)
(accountsservice-service) (accountsservice-service)

View File

@ -706,7 +706,8 @@ non-ASCII names from /tmp.")
(operating-system (operating-system
(inherit %simple-os) (inherit %simple-os)
(name-service-switch %mdns-host-lookup-nss) (name-service-switch %mdns-host-lookup-nss)
(services (cons* (avahi-service #:debug? #t) (services (cons* (service avahi-service-type
(avahi-configuration (debug? #t)))
(dbus-service) (dbus-service)
(service dhcp-client-service-type) ;needed for multicast (service dhcp-client-service-type) ;needed for multicast