* [PATCH] services: connman: Rework service.
@ 2017-02-20 15:25 Mathieu Othacehe
2017-03-16 9:58 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Othacehe @ 2017-02-20 15:25 UTC (permalink / raw)
To: guix-devel
* 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.
---
doc/guix.texi | 34 +++++++++++++-----
gnu/services/networking.scm | 86 ++++++++++++++++++++++++++-------------------
2 files changed, 75 insertions(+), 45 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 6cdb5e5..c00346d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8972,16 +8972,34 @@ NetworkManager will not modify @code{resolv.conf}.
@end deftp
@cindex Connman
-@deffn {Scheme Procedure} connman-service @
- [#:connman @var{connman}]
-Return a service that runs @url{https://01.org/connman,Connman}, a network
-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."
+@deffn {Scheme Variable} connman-service-type
+This is the service type to run @url{https://01.org/connman,Connman},
+a network connection manager.
+
+Its value must be an
+@code{connman-configuration} record as in this example:
+
+@example
+(service connman-service-type
+ (connman-configuration
+ (disable-vpn? #t)))
+@end example
+
+See below for details about @code{connman-configuration}.
@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
@defvr {Scheme Variable} wpa-supplicant-service-type
This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 18bce2a..9b8e5b3 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -80,7 +80,10 @@
network-manager-configuration-dns
network-manager-service-type
- connman-service
+ connman-configuration
+ connman-configuration?
+ connman-service-type
+
wpa-supplicant-service-type
openvswitch-service-type
@@ -822,45 +825,54 @@ dns=" dns "
;;; Connman
;;;
-(define %connman-activation
- ;; Activation gexp for Connman.
- #~(begin
- (use-modules (guix build utils))
- (mkdir-p "/var/lib/connman/")
- (mkdir-p "/var/lib/connman-vpn/")))
-
-(define (connman-shepherd-service connman)
+(define-record-type* <connman-configuration>
+ connman-configuration make-connman-configuration
+ connman-configuration?
+ (connman connman-configuration-connman
+ (default connman))
+ (disable-vpn? connman-configuration-disable-vpn?
+ (default #f)))
+
+(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"
- (list (shepherd-service
- (documentation "Run Connman")
- (provision '(networking))
- (requirement '(user-processes dbus-system loopback wpa-supplicant))
- (start #~(make-forkexec-constructor
- (list (string-append #$connman
- "/sbin/connmand")
- "-n" "-r")))
- (stop #~(make-kill-destructor)))))
+ (and
+ (connman-configuration? config)
+ (let ((connman (connman-configuration-connman config))
+ (disable-vpn? (connman-configuration-disable-vpn? config)))
+ (list (shepherd-service
+ (documentation "Run Connman")
+ (provision '(networking))
+ (requirement
+ '(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
- (service-type (name 'connman)
- (extensions
- (list (service-extension shepherd-root-service-type
- connman-shepherd-service)
- (service-extension dbus-root-service-type list)
- (service-extension activation-service-type
- (const %connman-activation))
- ;; Add connman to the system profile.
- (service-extension profile-service-type list)))))
-
-(define* (connman-service #:key (connman connman))
- "Return a service that runs @url{https://01.org/connman,Connman}, a network
-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))
-
+ (let ((connman-package (compose list connman-configuration-connman)))
+ (service-type (name 'connman)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ connman-shepherd-service)
+ (service-extension dbus-root-service-type
+ connman-package)
+ (service-extension activation-service-type
+ connman-activation)
+ ;; Add connman to the system profile.
+ (service-extension profile-service-type
+ connman-package))))))
\f
;;;
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] services: connman: Rework service.
2017-02-20 15:25 [PATCH] services: connman: Rework service Mathieu Othacehe
@ 2017-03-16 9:58 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-03-16 9:58 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: guix-devel
Hi Mathieu,
Mathieu Othacehe <m.othacehe@gmail.com> skribis:
> * 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.
This had fallen through the cracks, sorry about that! I’ve just applied
it.
BTW, please use guix-patches@gnu.org, which goes to
<https://bugs.gnu.org/guix-patches>, to minimize the risk of patches
getting forgotten. :-)
Thank you!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-16 9:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-20 15:25 [PATCH] services: connman: Rework service Mathieu Othacehe
2017-03-16 9:58 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.