diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-04-19 18:01:13 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-04-19 23:50:17 +0200 |
commit | a03943ec0024f22e2b7d6358dea9989c9eb06499 (patch) | |
tree | 72c7b03d90b80115b7a2fb389c05fd879b18332b /gnu | |
parent | 4313e6ec552a83082410a7f32660b84f7fc19554 (diff) |
services: Add 'hostapd-service-type'.
* gnu/services/networking.scm (<hostapd-configuration>): New record
type.
(hostapd-configuration-file, hostapd-shepherd-services): New
procedures.
(hostapd-service-type): New variable.
* doc/guix.texi (Networking Services): Document it.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/services/networking.scm | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 618dd95969..30e1173f2b 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -32,6 +32,7 @@ (define-module (gnu services networking) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services configuration) #:use-module (gnu services shepherd) #:use-module (gnu services dbus) #:use-module (gnu system shadow) @@ -140,6 +141,16 @@ wpa-supplicant-configuration-extra-options wpa-supplicant-service-type + hostapd-configuration + hostapd-configuration? + hostapd-configuration-package + hostapd-configuration-interface + hostapd-configuration-ssid + hostapd-configuration-broadcast-ssid? + hostapd-configuration-channel + hostapd-configuration-driver + hostapd-service-type + openvswitch-service-type openvswitch-configuration @@ -1360,6 +1371,66 @@ implements authentication, key negotiation and more for wireless networks.") ;;; +;;; Hostapd. +;;; + +(define-record-type* <hostapd-configuration> + hostapd-configuration make-hostapd-configuration + hostapd-configuration? + (package hostapd-configuration-package + (default hostapd)) + (interface hostapd-configuration-interface ;string + (default "wlan0")) + (ssid hostapd-configuration-ssid) ;string + (broadcast-ssid? hostapd-configuration-broadcast-ssid? ;Boolean + (default #t)) + (channel hostapd-configuration-channel ;integer + (default 1)) + (driver hostapd-configuration-driver ;string + (default "nl80211")) + ;; See <https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf> for a list of + ;; additional options we could add. + (extra-settings hostapd-configuration-extra-settings ;string + (default ""))) + +(define (hostapd-configuration-file config) + "Return the configuration file for CONFIG, a <hostapd-configuration>." + (match-record config <hostapd-configuration> + (interface ssid broadcast-ssid? channel driver extra-settings) + (plain-file "hostapd.conf" + (string-append "\ +# Generated from your Guix configuration. + +interface=" interface " +ssid=" ssid " +ignore_broadcast_ssid=" (if broadcast-ssid? "0" "1") " +channel=" (number->string channel) "\n" +extra-settings "\n")))) + +(define* (hostapd-shepherd-services config #:key (requirement '())) + "Return Shepherd services for hostapd." + (list (shepherd-service + (provision '(hostapd)) + (requirement `(user-processes ,@requirement)) + (documentation "Run the hostapd WiFi access point daemon.") + (start #~(make-forkexec-constructor + (list #$(file-append hostapd "/sbin/hostapd") + #$(hostapd-configuration-file config)) + #:log-file "/var/log/hostapd.log")) + (stop #~(make-kill-destructor))))) + +(define hostapd-service-type + (service-type + (name 'hostapd) + (extensions + (list (service-extension shepherd-root-service-type + hostapd-shepherd-services))) + (description + "Run the @uref{https://w1.fi/hostapd/, hostapd} daemon for Wi-Fi access +points and authentication servers."))) + + +;;; ;;; Open vSwitch ;;; |