services: networking: Add shepherd-requirement for dhcpcd.

* gnu/services/networking.scm (dhcpcd-configuration): Add
shepherd-requirement field.
(dhcpcd-shepherd-service): Use it.
* doc/guix.texi (Networking Setup): Regenerate dhcpcd-configuration
documentation.
(File Systems): Fix typo.

Change-Id: Id347e2bed2569237685a47be82dbf686640db25b
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Sergey Trofimov 2025-05-22 08:03:16 +02:00 committed by Ludovic Courtès
parent 38756ac03d
commit 2ec1469104
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 31 additions and 19 deletions

View file

@ -18332,7 +18332,7 @@ As an example, an NFS file system would typically have a requirement for
might not be sufficient as @code{networking} being marked as started might not be sufficient as @code{networking} being marked as started
does @emph{not} imply the network has already been configured and in does @emph{not} imply the network has already been configured and in
working order (for example, when using working order (for example, when using
@code{dhcpcd-client-service-type}). For such cases, adding a @code{dhcp-client-service-type}). For such cases, adding a
requirement on a custom @code{network-online} service may be necessary. requirement on a custom @code{network-online} service may be necessary.
A sample @code{network-online} one-shot Shepherd service implementation A sample @code{network-online} one-shot Shepherd service implementation
is provided below: is provided below:
@ -21980,12 +21980,13 @@ Host name to send via DHCP, defaults to the current system host name.
@item @code{duid} (default: @code{""}) (type: maybe-string) @item @code{duid} (default: @code{""}) (type: maybe-string)
DHCPv4 clients require a unique client identifier, this option uses the DHCPv4 clients require a unique client identifier, this option uses the
DHCPv6 Unique Identifier as a DHCPv4 client identifier as well. For DHCPv6 Unique Identifier as a DHCPv4 client identifier as well. For
more information, refer to @uref{https://www.rfc-editor.org/rfc/rfc4361, RFC 4361} more information, refer to
and @code{dhcpcd.conf(5)}. @uref{https://www.rfc-editor.org/rfc/rfc4361,RFC 4361} and
@code{dhcpcd.conf(5)}.
@item @code{persistent?} (default: @code{#t}) (type: boolean) @item @code{persistent?} (default: @code{#t}) (type: boolean)
When true, automatically de-configure the interface when @command{dhcpcd} When true, automatically de-configure the interface when
exits. @command{dhcpcd} exits.
@item @code{option} (default: @code{("rapid_commit" "domain_name_servers" "domain_name" "domain_search" "host_name" "classless_static_routes" "interface_mtu")}) (type: list-of-strings) @item @code{option} (default: @code{("rapid_commit" "domain_name_servers" "domain_name" "domain_search" "host_name" "classless_static_routes" "interface_mtu")}) (type: list-of-strings)
List of options to request from the server. List of options to request from the server.
@ -22019,9 +22020,13 @@ identifier, this is matually exclusive with the @code{duid} option.
@item @code{extra-content} (type: maybe-string) @item @code{extra-content} (type: maybe-string)
Extra content to append to the configuration as-is. Extra content to append to the configuration as-is.
@end table @item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
@end deftp This is a list of symbols naming Shepherd services that this service
will depend on.
@end table
@end deftp
@cindex NetworkManager @cindex NetworkManager

View file

@ -127,6 +127,7 @@
dhcpcd-configuration-vendor-class-id dhcpcd-configuration-vendor-class-id
dhcpcd-configuration-client-id dhcpcd-configuration-client-id
dhcpcd-configuration-extra-content dhcpcd-configuration-extra-content
dhcpcd-configuration-shepherd-requirement
ntp-configuration ntp-configuration
ntp-configuration? ntp-configuration?
@ -611,6 +612,12 @@ this is matually exclusive with the @code{duid} option.")
maybe-string maybe-string
"Extra content to append to the configuration as-is.") "Extra content to append to the configuration as-is.")
(shepherd-requirement
(list-of-symbols '())
"This is a list of symbols naming Shepherd services that this service
will depend on."
empty-serializer)
(prefix dhcpcd-)) (prefix dhcpcd-))
(define (dhcpcd-config-file config) (define (dhcpcd-config-file config)
@ -630,19 +637,19 @@ this is matually exclusive with the @code{duid} option.")
(shell (file-append shadow "/sbin/nologin"))))) (shell (file-append shadow "/sbin/nologin")))))
(define (dhcpcd-shepherd-service config) (define (dhcpcd-shepherd-service config)
(let* ((config-file (dhcpcd-config-file config)) (match-record config <dhcpcd-configuration>
(command-args (dhcpcd-configuration-command-arguments config)) (command-arguments interfaces shepherd-requirement)
(ifaces (dhcpcd-configuration-interfaces config))) (let ((config-file (dhcpcd-config-file config)))
(list (shepherd-service (list (shepherd-service
(documentation "dhcpcd daemon.") (documentation "dhcpcd daemon.")
(provision '(networking)) (provision '(networking))
(requirement '(user-processes udev)) (requirement `(user-processes udev ,@shepherd-requirement))
(actions (list (shepherd-configuration-action config-file))) (actions (list (shepherd-configuration-action config-file)))
(start (start
#~(make-forkexec-constructor #~(make-forkexec-constructor
(list (string-append #$dhcpcd "/sbin/dhcpcd") (list (string-append #$dhcpcd "/sbin/dhcpcd")
#$@command-args "-B" "-f" #$config-file #$@ifaces))) #$@command-arguments "-B" "-f" #$config-file #$@interfaces)))
(stop #~(make-kill-destructor)))))) (stop #~(make-kill-destructor)))))))
(define dhcpcd-service-type (define dhcpcd-service-type
(service-type (name 'dhcpcd) (service-type (name 'dhcpcd)