From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: [PATCH 2/2] services: network-manager: Use record for configuration. Date: Thu, 19 Jan 2017 06:55:39 +0000 Message-ID: <20170119065539.988-2-mail@cbaines.net> References: <20170119065539.988-1-mail@cbaines.net> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cU6dN-0005Nd-DG for guix-devel@gnu.org; Thu, 19 Jan 2017 01:55:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cU6dK-00071y-6n for guix-devel@gnu.org; Thu, 19 Jan 2017 01:55:45 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:44272 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cU6dJ-00071D-Tk for guix-devel@gnu.org; Thu, 19 Jan 2017 01:55:42 -0500 Received: from localhost (88-104-162-239.dynamic.dsl.as9105.com [88.104.162.239]) by mira.cbaines.net (Postfix) with ESMTPSA id CF25713D1DD for ; Thu, 19 Jan 2017 06:55:39 +0000 (GMT) Received: from dhcppc78.dlink.com (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id a2a75805 for ; Thu, 19 Jan 2017 06:55:39 +0000 (UTC) In-Reply-To: <20170119065539.988-1-mail@cbaines.net> 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. --- gnu/services/networking.scm | 77 +++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 27 deletions(-) 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