summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-04-19 22:06:32 +0200
committerLudovic Courtès <ludo@gnu.org>2020-04-19 23:50:17 +0200
commit5e7076f2a54e84894b5d8f3ef719e7a552b5bb03 (patch)
tree685f4fa5633a04f35867db589a0ea729667c781e /gnu/services
parenta03943ec0024f22e2b7d6358dea9989c9eb06499 (diff)
downloadpatches-5e7076f2a54e84894b5d8f3ef719e7a552b5bb03.tar
patches-5e7076f2a54e84894b5d8f3ef719e7a552b5bb03.tar.gz
services: Add 'simulated-wifi-service-type'.
* gnu/services/networking.scm (simulated-wifi-shepherd-services): New procedure. (simulated-wifi-service-type): New variable. * doc/guix.texi (Networking Services): Document it.
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/networking.scm48
1 files changed, 48 insertions, 0 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 30e1173f2b..383b2b0d04 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -151,6 +151,8 @@
hostapd-configuration-driver
hostapd-service-type
+ simulated-wifi-service-type
+
openvswitch-service-type
openvswitch-configuration
@@ -1429,6 +1431,52 @@ extra-settings "\n"))))
"Run the @uref{https://w1.fi/hostapd/, hostapd} daemon for Wi-Fi access
points and authentication servers.")))
+(define (simulated-wifi-shepherd-services config)
+ "Return Shepherd services to run hostapd with CONFIG, a
+<hostapd-configuration>, as well as services to set up WiFi hardware
+simulation."
+ (append (hostapd-shepherd-services config
+ #:requirement
+ '(unblocked-wifi
+ mac-simulation-module))
+ (list (shepherd-service
+ (provision '(unblocked-wifi))
+ (requirement '(file-systems mac-simulation-module))
+ (documentation
+ "Unblock WiFi devices for use by mac80211_hwsim.")
+ (start #~(lambda _
+ (invoke #$(file-append util-linux "/sbin/rfkill")
+ "unblock" "0")
+ (invoke #$(file-append util-linux "/sbin/rfkill")
+ "unblock" "1")))
+ (one-shot? #t))
+ (shepherd-service
+ (provision '(mac-simulation-module))
+ (requirement '(file-systems))
+ (modules '((guix build utils)))
+ (documentation
+ "Load the mac80211_hwsim Linux kernel module.")
+ (start (with-imported-modules '((guix build utils))
+ #~(lambda _
+ ;; XXX: We can't use 'load-linux-module*' here because it
+ ;; expects a flat module directory.
+ (setenv "LINUX_MODULE_DIRECTORY"
+ "/run/booted-system/kernel/lib/modules")
+ (invoke #$(file-append kmod "/bin/modprobe")
+ "mac80211_hwsim"))))
+ (one-shot? #t)))))
+
+(define simulated-wifi-service-type
+ (service-type
+ (name 'simulated-wifi)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ simulated-wifi-shepherd-services)))
+ (default-value (hostapd-configuration
+ (interface "wlan1")
+ (ssid "Test Network")))
+ (description "Run hostapd to simulate WiFi connectivity.")))
+
;;;
;;; Open vSwitch