services: network-manager: Add support for VPN plug-ins.
* gnu/services.scm (directory-union): Export. * gnu/services/networking.scm (<network-manager-configuration>)[vpn-plugins]: New field. (vpn-plugin-directory, network-manager-environment): New procedure. (network-manager-shepherd-service): Pass #:environment-variables to 'make-forkexec-constructor'. (network-manager-service-type): Add SESSION-ENVIRONMENT-SERVICE-TYPE extension. * doc/guix.texi (Networking Services): Document it.
This commit is contained in:
parent
fbc31dc124
commit
94d2a25091
|
@ -10125,6 +10125,11 @@ then update @code{resolv.conf} to point to the local nameserver.
|
||||||
NetworkManager will not modify @code{resolv.conf}.
|
NetworkManager will not modify @code{resolv.conf}.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@item @code{vpn-plugins} (default: @code{'()})
|
||||||
|
This is the list of available plugins for virtual private networks
|
||||||
|
(VPNs). An example of this is the @code{network-manager-openvpn}
|
||||||
|
package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,8 @@
|
||||||
%activation-service
|
%activation-service
|
||||||
etc-service
|
etc-service
|
||||||
|
|
||||||
file-union)) ;XXX: for lack of a better place
|
file-union ;XXX: for lack of a better place
|
||||||
|
directory-union))
|
||||||
|
|
||||||
;;; Comment:
|
;;; Comment:
|
||||||
;;;
|
;;;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
#:use-module (gnu services shepherd)
|
#:use-module (gnu services shepherd)
|
||||||
#:use-module (gnu services dbus)
|
#:use-module (gnu services dbus)
|
||||||
|
#:use-module (gnu services base)
|
||||||
#:use-module (gnu system shadow)
|
#:use-module (gnu system shadow)
|
||||||
#:use-module (gnu system pam)
|
#:use-module (gnu system pam)
|
||||||
#:use-module (gnu packages admin)
|
#:use-module (gnu packages admin)
|
||||||
|
@ -909,7 +910,9 @@ and @command{wicd-curses} user interfaces."
|
||||||
(network-manager network-manager-configuration-network-manager
|
(network-manager network-manager-configuration-network-manager
|
||||||
(default network-manager))
|
(default network-manager))
|
||||||
(dns network-manager-configuration-dns
|
(dns network-manager-configuration-dns
|
||||||
(default "default")))
|
(default "default"))
|
||||||
|
(vpn-plugins network-manager-vpn-plugins ;list of <package>
|
||||||
|
(default '())))
|
||||||
|
|
||||||
(define %network-manager-activation
|
(define %network-manager-activation
|
||||||
;; Activation gexp for NetworkManager.
|
;; Activation gexp for NetworkManager.
|
||||||
|
@ -917,15 +920,25 @@ and @command{wicd-curses} user interfaces."
|
||||||
(use-modules (guix build utils))
|
(use-modules (guix build utils))
|
||||||
(mkdir-p "/etc/NetworkManager/system-connections")))
|
(mkdir-p "/etc/NetworkManager/system-connections")))
|
||||||
|
|
||||||
|
(define (vpn-plugin-directory plugins)
|
||||||
|
"Return a directory containing PLUGINS, the NM VPN plugins."
|
||||||
|
(directory-union "network-manager-vpn-plugins" plugins))
|
||||||
|
|
||||||
|
(define network-manager-environment
|
||||||
|
(match-lambda
|
||||||
|
(($ <network-manager-configuration> network-manager dns vpn-plugins)
|
||||||
|
;; Define this variable in the global environment such that
|
||||||
|
;; "nmcli connection import type openvpn file foo.ovpn" works.
|
||||||
|
`(("NM_VPN_PLUGIN_DIR"
|
||||||
|
. ,(file-append (vpn-plugin-directory vpn-plugins)
|
||||||
|
"/lib/NetworkManager/VPN"))))))
|
||||||
|
|
||||||
(define network-manager-shepherd-service
|
(define network-manager-shepherd-service
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <network-manager-configuration> network-manager dns)
|
(($ <network-manager-configuration> network-manager dns vpn-plugins)
|
||||||
(let
|
(let ((conf (plain-file "NetworkManager.conf"
|
||||||
((conf (plain-file "NetworkManager.conf"
|
(string-append "[main]\ndns=" dns "\n")))
|
||||||
(string-append "
|
(vpn (vpn-plugin-directory vpn-plugins)))
|
||||||
[main]
|
|
||||||
dns=" dns "
|
|
||||||
"))))
|
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(documentation "Run the NetworkManager.")
|
(documentation "Run the NetworkManager.")
|
||||||
(provision '(networking))
|
(provision '(networking))
|
||||||
|
@ -934,7 +947,10 @@ dns=" dns "
|
||||||
(list (string-append #$network-manager
|
(list (string-append #$network-manager
|
||||||
"/sbin/NetworkManager")
|
"/sbin/NetworkManager")
|
||||||
(string-append "--config=" #$conf)
|
(string-append "--config=" #$conf)
|
||||||
"--no-daemon")))
|
"--no-daemon")
|
||||||
|
#:environment-variables
|
||||||
|
(list (string-append "NM_VPN_PLUGIN_DIR=" #$vpn
|
||||||
|
"/lib/NetworkManager/VPN"))))
|
||||||
(stop #~(make-kill-destructor))))))))
|
(stop #~(make-kill-destructor))))))))
|
||||||
|
|
||||||
(define network-manager-service-type
|
(define network-manager-service-type
|
||||||
|
@ -953,6 +969,8 @@ dns=" dns "
|
||||||
(service-extension polkit-service-type config->package)
|
(service-extension polkit-service-type config->package)
|
||||||
(service-extension activation-service-type
|
(service-extension activation-service-type
|
||||||
(const %network-manager-activation))
|
(const %network-manager-activation))
|
||||||
|
(service-extension session-environment-service-type
|
||||||
|
network-manager-environment)
|
||||||
;; Add network-manager to the system profile.
|
;; Add network-manager to the system profile.
|
||||||
(service-extension profile-service-type config->package)))
|
(service-extension profile-service-type config->package)))
|
||||||
(default-value (network-manager-configuration))
|
(default-value (network-manager-configuration))
|
||||||
|
|
Loading…
Reference in New Issue