services: wpa-supplicant: Extend to support configuration parameters.
This allows using WPA Supplicant "standalone" without an additional network manager. The default configuration is unchanged. * gnu/services/networking.scm (<wpa-supplicant-configuration>): New record type. (wpa-supplicant-shepherd-service): Pass configuration records to the daemon. (wpa-supplicant-service-type): Adjust accordingly. * doc/guix.texi (Networking Services): Document the new service type.
This commit is contained in:
parent
a55ebe2e3a
commit
acce0a474c
|
@ -11737,19 +11737,36 @@ When true, enable connman's vpn plugin.
|
||||||
@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
|
||||||
supplicant}, an authentication daemon required to authenticate against
|
supplicant}, an authentication daemon required to authenticate against
|
||||||
encrypted WiFi or ethernet networks. It is configured to listen for
|
encrypted WiFi or ethernet networks.
|
||||||
requests on D-Bus.
|
|
||||||
|
|
||||||
The value of this service is the @code{wpa-supplicant} package to use.
|
|
||||||
Thus, it can be instantiated like this:
|
|
||||||
|
|
||||||
@lisp
|
|
||||||
(use-modules (gnu services networking))
|
|
||||||
|
|
||||||
(service wpa-supplicant-service-type)
|
|
||||||
@end lisp
|
|
||||||
@end defvr
|
@end defvr
|
||||||
|
|
||||||
|
@deftp {Data Type} wpa-supplicant-configuration
|
||||||
|
Data type representing the configuration of WPA Supplicant.
|
||||||
|
|
||||||
|
It takes the following parameters:
|
||||||
|
|
||||||
|
@table @asis
|
||||||
|
@item @code{wpa-supplicant} (default: @code{wpa-supplicant})
|
||||||
|
The WPA Supplicant package to use.
|
||||||
|
|
||||||
|
@item @code{dbus?} (default: @code{#t})
|
||||||
|
Whether to listen for requests on D-Bus.
|
||||||
|
|
||||||
|
@item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
|
||||||
|
Where to store the PID file.
|
||||||
|
|
||||||
|
@item @code{interface} (default: @code{#f})
|
||||||
|
If this is set, it must specify the name of a network interface that
|
||||||
|
WPA supplicant will control.
|
||||||
|
|
||||||
|
@item @code{config-file} (default: @code{#f})
|
||||||
|
Optional configuration file to use.
|
||||||
|
|
||||||
|
@item @code{extra-options} (default: @code{'()})
|
||||||
|
List of additional command-line arguments to pass to the daemon.
|
||||||
|
@end table
|
||||||
|
@end deftp
|
||||||
|
|
||||||
@cindex iptables
|
@cindex iptables
|
||||||
@defvr {Scheme Variable} iptables-service-type
|
@defvr {Scheme Variable} iptables-service-type
|
||||||
This is the service type to set up an iptables configuration. iptables is a
|
This is the service type to set up an iptables configuration. iptables is a
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
;;; Copyright © 2016 John Darrington <jmd@gnu.org>
|
;;; Copyright © 2016 John Darrington <jmd@gnu.org>
|
||||||
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
|
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
|
||||||
;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
|
;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
|
||||||
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
|
;;; Copyright © 2017, 2018 Marius Bakke <mbakke@fastmail.com>
|
||||||
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
|
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
|
||||||
;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
|
;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
|
||||||
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
|
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
|
||||||
|
@ -101,6 +101,16 @@
|
||||||
modem-manager-configuration
|
modem-manager-configuration
|
||||||
modem-manager-configuration?
|
modem-manager-configuration?
|
||||||
modem-manager-service-type
|
modem-manager-service-type
|
||||||
|
|
||||||
|
<wpa-supplicant-configuration>
|
||||||
|
wpa-supplicant-configuration
|
||||||
|
wpa-supplicant-configuration?
|
||||||
|
wpa-supplicant-configuration-wpa-supplicant
|
||||||
|
wpa-supplicant-configuration-pid-file
|
||||||
|
wpa-supplicant-configuration-dbus?
|
||||||
|
wpa-supplicant-configuration-interface
|
||||||
|
wpa-supplicant-configuration-config-file
|
||||||
|
wpa-supplicant-configuration-extra-options
|
||||||
wpa-supplicant-service-type
|
wpa-supplicant-service-type
|
||||||
|
|
||||||
openvswitch-service-type
|
openvswitch-service-type
|
||||||
|
@ -1019,28 +1029,62 @@ networking."))))
|
||||||
;;; WPA supplicant
|
;;; WPA supplicant
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
(define-record-type* <wpa-supplicant-configuration>
|
||||||
|
wpa-supplicant-configuration make-wpa-supplicant-configuration
|
||||||
|
wpa-supplicant-configuration?
|
||||||
|
(wpa-supplicant wpa-supplicant-configuration-wpa-supplicant ;<package>
|
||||||
|
(default wpa-supplicant))
|
||||||
|
(pid-file wpa-supplicant-configuration-pid-file ;string
|
||||||
|
(default "/var/run/wpa_supplicant.pid"))
|
||||||
|
(dbus? wpa-supplicant-configuration-dbus? ;Boolean
|
||||||
|
(default #t))
|
||||||
|
(interface wpa-supplicant-configuration-interface ;#f | string
|
||||||
|
(default #f))
|
||||||
|
(config-file wpa-supplicant-configuration-config-file ;#f | <file-like>
|
||||||
|
(default #f))
|
||||||
|
(extra-options wpa-supplicant-configuration-extra-options ;list of strings
|
||||||
|
(default '())))
|
||||||
|
|
||||||
(define (wpa-supplicant-shepherd-service wpa-supplicant)
|
(define wpa-supplicant-shepherd-service
|
||||||
"Return a shepherd service for wpa_supplicant"
|
(match-lambda
|
||||||
(list (shepherd-service
|
(($ <wpa-supplicant-configuration> wpa-supplicant pid-file dbus? interface
|
||||||
(documentation "Run WPA supplicant with dbus interface")
|
config-file extra-options)
|
||||||
(provision '(wpa-supplicant))
|
(list (shepherd-service
|
||||||
(requirement '(user-processes dbus-system loopback))
|
(documentation "Run the WPA supplicant daemon")
|
||||||
(start #~(make-forkexec-constructor
|
(provision '(wpa-supplicant))
|
||||||
(list (string-append #$wpa-supplicant
|
(requirement '(user-processes dbus-system loopback))
|
||||||
"/sbin/wpa_supplicant")
|
(start #~(make-forkexec-constructor
|
||||||
"-u" "-B" "-P/var/run/wpa_supplicant.pid")
|
(list (string-append #$wpa-supplicant
|
||||||
#:pid-file "/var/run/wpa_supplicant.pid"))
|
"/sbin/wpa_supplicant")
|
||||||
(stop #~(make-kill-destructor)))))
|
(string-append "-P" #$pid-file)
|
||||||
|
"-B" ;run in background
|
||||||
|
#$@(if dbus?
|
||||||
|
#~("-u")
|
||||||
|
#~())
|
||||||
|
#$@(if interface
|
||||||
|
#~(string-append "-i" #$interface)
|
||||||
|
#~())
|
||||||
|
#$@(if config-file
|
||||||
|
#~(string-append "-c" #$config-file)
|
||||||
|
#~())
|
||||||
|
#$@extra-options)
|
||||||
|
#:pid-file #$pid-file))
|
||||||
|
(stop #~(make-kill-destructor)))))))
|
||||||
|
|
||||||
(define wpa-supplicant-service-type
|
(define wpa-supplicant-service-type
|
||||||
(service-type (name 'wpa-supplicant)
|
(let ((config->package
|
||||||
(extensions
|
(match-lambda
|
||||||
(list (service-extension shepherd-root-service-type
|
(($ <wpa-supplicant-configuration> wpa-supplicant)
|
||||||
wpa-supplicant-shepherd-service)
|
(list wpa-supplicant)))))
|
||||||
(service-extension dbus-root-service-type list)
|
(service-type (name 'wpa-supplicant)
|
||||||
(service-extension profile-service-type list)))
|
(extensions
|
||||||
(default-value wpa-supplicant)))
|
(list (service-extension shepherd-root-service-type
|
||||||
|
wpa-supplicant-shepherd-service)
|
||||||
|
(service-extension dbus-root-service-type config->package)
|
||||||
|
(service-extension profile-service-type config->package)))
|
||||||
|
(description "Run the WPA Supplicant daemon, a service that
|
||||||
|
implements authentication, key negotiation and more for wireless networks.")
|
||||||
|
(default-value (wpa-supplicant-configuration)))))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
Loading…
Reference in New Issue