From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: [PATCH] services: network-manager: Use record for configuration. Date: Fri, 20 Jan 2017 08:01:07 +0000 Message-ID: <20170120080107.6759-1-mail@cbaines.net> References: <87ziinb7fr.fsf@member.fsf.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUU8L-0005UG-7Z for guix-devel@gnu.org; Fri, 20 Jan 2017 03:01:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUU8G-0001ps-Ca for guix-devel@gnu.org; Fri, 20 Jan 2017 03:01:17 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:36457 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUU8G-0001ox-3f for guix-devel@gnu.org; Fri, 20 Jan 2017 03:01:12 -0500 Received: from localhost (79-71-12-252.dynamic.dsl.as9105.com [79.71.12.252]) by mira.cbaines.net (Postfix) with ESMTPSA id 6CED013D1D8 for ; Fri, 20 Jan 2017 08:01:08 +0000 (GMT) Received: from dhcppc78.dlink.com (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id ee6f3945 for ; Fri, 20 Jan 2017 08:01:07 +0000 (UTC) In-Reply-To: <87ziinb7fr.fsf@member.fsf.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * gnu/services/network-manager.scm (): 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. --- doc/guix.texi | 38 +++++++++++++++++++--- gnu/services/networking.scm | 77 +++++++++++++++++++++++++++++---------------- 2 files changed, 83 insertions(+), 32 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 7cd9cd046..46daac3b9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8758,11 +8758,39 @@ and @command{wicd-curses} user interfaces. @end deffn @cindex NetworkManager -@deffn {Scheme Procedure} network-manager-service @ - [#:network-manager @var{network-manager}] -Return a service that runs NetworkManager, a network connection manager -attempting to keep network connectivity active when available. -@end deffn + +@defvr {Scheme Variable} network-manager-service-type +This is the service type for the +@uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager} +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 deftp @cindex Connman @deffn {Scheme Procedure} connman-service @ diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index ac011f128..8f136f0dc 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -64,7 +64,12 @@ wicd-service-type wicd-service - network-manager-service + + network-manager-configuration + network-manager-configuration? + network-manager-configuration-dns + network-manager-service-type + connman-service wpa-supplicant-service-type)) @@ -679,40 +684,58 @@ and @command{wicd-curses} user interfaces." ;;; NetworkManager ;;; +(define-record-type* + 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 ;; Activation gexp for NetworkManager. #~(begin (use-modules (guix build utils)) (mkdir-p "/etc/NetworkManager/system-connections"))) -(define (network-manager-shepherd-service network-manager) - "Return a shepherd service for NETWORK-MANAGER." - (list (shepherd-service - (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") - "--no-daemon"))) - (stop #~(make-kill-destructor))))) +(define network-manager-shepherd-service + (match-lambda + (($ network-manager dns) + (let + ((conf (plain-file "NetworkManager.conf" + (string-append " +[main] +dns=" dns " +")))) + (list (shepherd-service + (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 - (service-type (name 'network-manager) - (extensions - (list (service-extension shepherd-root-service-type - network-manager-shepherd-service) - (service-extension dbus-root-service-type list) - (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)) - "Return a service that runs NetworkManager, a network connection manager -that attempting to keep active network connectivity when available." - (service network-manager-service-type network-manager)) + (let + ((config->package + (match-lambda + (($ network-manager) + (list network-manager))))) + + (service-type + (name 'network-manager) + (extensions + (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)))))) ;;; -- 2.11.0