services: connman: Rework service.

* gnu/services/networking.scm (connman-service): Remove.
(<connman-configuration>): New record specifying the package
to be used (connman) and whether vpn plugin shall be
disabled (disable-vpn?).
(connman-configuration): New exported variable.
(connman-configuration?): New exported variable.
(connman-service-type): Export it.

* doc/guix.texi (Networking Services): Adjust accordingly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Mathieu Othacehe 2017-02-20 16:25:44 +01:00 committed by Ludovic Courtès
parent d938a58bee
commit 34d60c49cb
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 73 additions and 43 deletions

View file

@ -9263,16 +9263,34 @@ NetworkManager will not modify @code{resolv.conf}.
@end deftp @end deftp
@cindex Connman @cindex Connman
@deffn {Scheme Procedure} connman-service @ @deffn {Scheme Variable} connman-service-type
[#:connman @var{connman}] This is the service type to run @url{https://01.org/connman,Connman},
Return a service that runs @url{https://01.org/connman,Connman}, a network a network connection manager.
connection manager.
This service adds the @var{connman} package to the global profile, providing Its value must be an
several the @command{connmanctl} command to interact with the daemon and @code{connman-configuration} record as in this example:
configure networking."
@example
(service connman-service-type
(connman-configuration
(disable-vpn? #t)))
@end example
See below for details about @code{connman-configuration}.
@end deffn @end deffn
@deftp {Data Type} connman-configuration
Data Type representing the configuration of connman.
@table @asis
@item @code{connman} (default: @var{connman})
The connman package to use.
@item @code{disable-vpn?} (default: @code{#f})
When true, enable connman's vpn plugin.
@end table
@end deftp
@cindex WPA Supplicant @cindex WPA Supplicant
@defvr {Scheme Variable} wpa-supplicant-service-type @defvr {Scheme Variable} wpa-supplicant-service-type
This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA

View file

@ -80,7 +80,10 @@ (define-module (gnu services networking)
network-manager-configuration-dns network-manager-configuration-dns
network-manager-service-type network-manager-service-type
connman-service connman-configuration
connman-configuration?
connman-service-type
wpa-supplicant-service-type wpa-supplicant-service-type
openvswitch-service-type openvswitch-service-type
@ -822,45 +825,54 @@ (define network-manager-service-type
;;; Connman ;;; Connman
;;; ;;;
(define %connman-activation (define-record-type* <connman-configuration>
;; Activation gexp for Connman. connman-configuration make-connman-configuration
#~(begin connman-configuration?
(use-modules (guix build utils)) (connman connman-configuration-connman
(mkdir-p "/var/lib/connman/") (default connman))
(mkdir-p "/var/lib/connman-vpn/"))) (disable-vpn? connman-configuration-disable-vpn?
(default #f)))
(define (connman-shepherd-service connman) (define (connman-activation config)
(let ((disable-vpn? (connman-configuration-disable-vpn? config)))
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(mkdir-p "/var/lib/connman/")
(unless #$disable-vpn?
(mkdir-p "/var/lib/connman-vpn/"))))))
(define (connman-shepherd-service config)
"Return a shepherd service for Connman" "Return a shepherd service for Connman"
(list (shepherd-service (and
(documentation "Run Connman") (connman-configuration? config)
(provision '(networking)) (let ((connman (connman-configuration-connman config))
(requirement '(user-processes dbus-system loopback wpa-supplicant)) (disable-vpn? (connman-configuration-disable-vpn? config)))
(start #~(make-forkexec-constructor (list (shepherd-service
(list (string-append #$connman (documentation "Run Connman")
"/sbin/connmand") (provision '(networking))
"-n" "-r"))) (requirement
(stop #~(make-kill-destructor))))) '(user-processes dbus-system loopback wpa-supplicant))
(start #~(make-forkexec-constructor
(list (string-append #$connman
"/sbin/connmand")
"-n" "-r"
#$@(if disable-vpn? '("--noplugin=vpn") '()))))
(stop #~(make-kill-destructor)))))))
(define connman-service-type (define connman-service-type
(service-type (name 'connman) (let ((connman-package (compose list connman-configuration-connman)))
(extensions (service-type (name 'connman)
(list (service-extension shepherd-root-service-type (extensions
connman-shepherd-service) (list (service-extension shepherd-root-service-type
(service-extension dbus-root-service-type list) connman-shepherd-service)
(service-extension activation-service-type (service-extension dbus-root-service-type
(const %connman-activation)) connman-package)
;; Add connman to the system profile. (service-extension activation-service-type
(service-extension profile-service-type list))))) connman-activation)
;; Add connman to the system profile.
(define* (connman-service #:key (connman connman)) (service-extension profile-service-type
"Return a service that runs @url{https://01.org/connman,Connman}, a network connman-package))))))
connection manager.
This service adds the @var{connman} package to the global profile, providing
several the @command{connmanctl} command to interact with the daemon and
configure networking."
(service connman-service-type connman))
;;; ;;;