services: network-manager: Use record for configuration.
* gnu/services/network-manager.scm (<network-manager-configuration>): New record type. (network-manager-shpeherd-service): Change to use the network-manager-configuration record, rather than a package. Generate a simple configuration file from the network-manager-configuration record. (network-manager-service-type): Update extensions to take the network-manager-configuration rather than a package. (network-manager-service): Remove function, the network-manager-service-type can be used instead, and this avoids keeping the function signature and value coresponding to the service type in sync. * doc/guix.texi (Networking Services): Remove documentation for the removed network-manager-service procedure, and add documentation of the network-manager-service-type variable and network-manager-configuration record. Signed-off-by: 宋文武 <iyzsong@member.fsf.org>master
parent
4f98c3c553
commit
b726096bc5
|
@ -8758,11 +8758,41 @@ and @command{wicd-curses} user interfaces.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@cindex NetworkManager
|
@cindex NetworkManager
|
||||||
@deffn {Scheme Procedure} network-manager-service @
|
|
||||||
[#:network-manager @var{network-manager}]
|
@defvr {Scheme Variable} network-manager-service-type
|
||||||
Return a service that runs NetworkManager, a network connection manager
|
This is the service type for the
|
||||||
attempting to keep network connectivity active when available.
|
@uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
|
||||||
@end deffn
|
service. The value for this service type is a
|
||||||
|
@code{network-manager-configuration} record.
|
||||||
|
@end defvr
|
||||||
|
|
||||||
|
@deftp {Data Type} network-manager-configuration
|
||||||
|
Data type representing the configuration of NetworkManager.
|
||||||
|
|
||||||
|
@table @asis
|
||||||
|
@item @code{network-manager} (default: @code{network-manager})
|
||||||
|
The NetworkManager package to use.
|
||||||
|
|
||||||
|
@item @code{dns} (default: @code{"default"})
|
||||||
|
Processing mode for DNS, which affects how NetworkManager uses the
|
||||||
|
@code{resolv.conf} configuration file.
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item default
|
||||||
|
NetworkManager will update @code{resolv.conf} to reflect the nameservers
|
||||||
|
provided by currently active connections.
|
||||||
|
|
||||||
|
@item dnsmasq
|
||||||
|
NetworkManager will run @code{dnsmasq} as a local caching nameserver,
|
||||||
|
using a "split DNS" configuration if you are connected to a VPN, and
|
||||||
|
then update @code{resolv.conf} to point to the local nameserver.
|
||||||
|
|
||||||
|
@item none
|
||||||
|
NetworkManager will not modify @code{resolv.conf}.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@end table
|
||||||
|
@end deftp
|
||||||
|
|
||||||
@cindex Connman
|
@cindex Connman
|
||||||
@deffn {Scheme Procedure} connman-service @
|
@deffn {Scheme Procedure} connman-service @
|
||||||
|
|
|
@ -64,7 +64,12 @@
|
||||||
|
|
||||||
wicd-service-type
|
wicd-service-type
|
||||||
wicd-service
|
wicd-service
|
||||||
network-manager-service
|
|
||||||
|
network-manager-configuration
|
||||||
|
network-manager-configuration?
|
||||||
|
network-manager-configuration-dns
|
||||||
|
network-manager-service-type
|
||||||
|
|
||||||
connman-service
|
connman-service
|
||||||
wpa-supplicant-service-type))
|
wpa-supplicant-service-type))
|
||||||
|
|
||||||
|
@ -679,40 +684,58 @@ and @command{wicd-curses} user interfaces."
|
||||||
;;; NetworkManager
|
;;; NetworkManager
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
(define-record-type* <network-manager-configuration>
|
||||||
|
network-manager-configuration make-network-manager-configuration
|
||||||
|
network-manager-configuration?
|
||||||
|
(network-manager network-manager-configuration-network-manager
|
||||||
|
(default network-manager))
|
||||||
|
(dns network-manager-configuration-dns
|
||||||
|
(default "default")))
|
||||||
|
|
||||||
(define %network-manager-activation
|
(define %network-manager-activation
|
||||||
;; Activation gexp for NetworkManager.
|
;; Activation gexp for NetworkManager.
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules (guix build utils))
|
(use-modules (guix build utils))
|
||||||
(mkdir-p "/etc/NetworkManager/system-connections")))
|
(mkdir-p "/etc/NetworkManager/system-connections")))
|
||||||
|
|
||||||
(define (network-manager-shepherd-service network-manager)
|
(define network-manager-shepherd-service
|
||||||
"Return a shepherd service for NETWORK-MANAGER."
|
(match-lambda
|
||||||
(list (shepherd-service
|
(($ <network-manager-configuration> network-manager dns)
|
||||||
(documentation "Run the NetworkManager.")
|
(let
|
||||||
(provision '(networking))
|
((conf (plain-file "NetworkManager.conf"
|
||||||
(requirement '(user-processes dbus-system wpa-supplicant loopback))
|
(string-append "
|
||||||
(start #~(make-forkexec-constructor
|
[main]
|
||||||
(list (string-append #$network-manager
|
dns=" dns "
|
||||||
"/sbin/NetworkManager")
|
"))))
|
||||||
"--no-daemon")))
|
(list (shepherd-service
|
||||||
(stop #~(make-kill-destructor)))))
|
(documentation "Run the NetworkManager.")
|
||||||
|
(provision '(networking))
|
||||||
|
(requirement '(user-processes dbus-system wpa-supplicant loopback))
|
||||||
|
(start #~(make-forkexec-constructor
|
||||||
|
(list (string-append #$network-manager
|
||||||
|
"/sbin/NetworkManager")
|
||||||
|
(string-append "--config=" #$conf)
|
||||||
|
"--no-daemon")))
|
||||||
|
(stop #~(make-kill-destructor))))))))
|
||||||
|
|
||||||
(define network-manager-service-type
|
(define network-manager-service-type
|
||||||
(service-type (name 'network-manager)
|
(let
|
||||||
(extensions
|
((config->package
|
||||||
(list (service-extension shepherd-root-service-type
|
(match-lambda
|
||||||
network-manager-shepherd-service)
|
(($ <network-manager-configuration> network-manager)
|
||||||
(service-extension dbus-root-service-type list)
|
(list network-manager)))))
|
||||||
(service-extension polkit-service-type list)
|
|
||||||
(service-extension activation-service-type
|
|
||||||
(const %network-manager-activation))
|
|
||||||
;; Add network-manager to the system profile.
|
|
||||||
(service-extension profile-service-type list)))))
|
|
||||||
|
|
||||||
(define* (network-manager-service #:key (network-manager network-manager))
|
(service-type
|
||||||
"Return a service that runs NetworkManager, a network connection manager
|
(name 'network-manager)
|
||||||
that attempting to keep active network connectivity when available."
|
(extensions
|
||||||
(service network-manager-service-type network-manager))
|
(list (service-extension shepherd-root-service-type
|
||||||
|
network-manager-shepherd-service)
|
||||||
|
(service-extension dbus-root-service-type config->package)
|
||||||
|
(service-extension polkit-service-type config->package)
|
||||||
|
(service-extension activation-service-type
|
||||||
|
(const %network-manager-activation))
|
||||||
|
;; Add network-manager to the system profile.
|
||||||
|
(service-extension profile-service-type config->package))))))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
Reference in New Issue