summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2020-04-23 13:33:09 +0200
committerMarius Bakke <mbakke@fastmail.com>2020-04-23 13:33:09 +0200
commit030f6f489fe9544f35ebaf95135acd1dd67ce63f (patch)
treef1d5d1f1b68de81daec6f05d032a0410a475d960 /gnu/services
parent95c14929a7fbd3c55c5e8756953c2f257625e2b7 (diff)
parent938df0de739aa13c2fb483f440ec1db281a52aaa (diff)
Merge branch 'master' into core-updates
Conflicts: etc/news.scm gnu/local.mk gnu/packages/bootloaders.scm gnu/packages/linphone.scm gnu/packages/linux.scm gnu/packages/tls.scm gnu/system.scm
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/base.scm24
-rw-r--r--gnu/services/desktop.scm4
-rw-r--r--gnu/services/mail.scm7
-rw-r--r--gnu/services/networking.scm119
-rw-r--r--gnu/services/shepherd.scm3
-rw-r--r--gnu/services/spice.scm2
6 files changed, 150 insertions, 9 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index a532e884c3..3a772d3121 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -12,6 +12,7 @@
;;; Copyright © 2019 John Soo <jsoo1@asu.edu>
;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -92,6 +93,7 @@
udev-service
udev-rule
file->udev-rule
+ udev-rules-service
login-configuration
login-configuration?
@@ -557,7 +559,7 @@ down.")))
(documentation "Add TRNG to entropy pool.")
(requirement '(udev))
(provision '(trng))
- (start #~(make-forkexec-constructor #$@rngd-command))
+ (start #~(make-forkexec-constructor '#$rngd-command))
(stop #~(make-kill-destructor))))))
(define* (rngd-service #:key
@@ -2042,6 +2044,26 @@ extra rules from the packages listed in @var{rules}."
(service udev-service-type
(udev-configuration (udev udev) (rules rules))))
+(define* (udev-rules-service name rules #:key (groups '()))
+ "Return a service that extends udev-service-type with RULES and
+account-service-type with GROUPS as system groups. This works by creating a
+singleton service type NAME-udev-rules, of which the returned service is an
+instance."
+ (let* ((name (symbol-append name '-udev-rules))
+ (account-extension
+ (const (map (lambda (group)
+ (user-group (name group) (system? #t)))
+ groups)))
+ (udev-extension (const (list rules)))
+ (type (service-type
+ (name name)
+ (extensions (list
+ (service-extension
+ account-service-type account-extension)
+ (service-extension
+ udev-service-type udev-extension))))))
+ (service type #f)))
+
(define swap-service-type
(shepherd-service-type
'swap
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index 8663243256..e165d87c5f 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -452,8 +452,8 @@ site} for more information."
(requirement '(dbus-system udev))
(documentation "Run the bluetoothd daemon.")
(start #~(make-forkexec-constructor
- (string-append #$(bluetooth-configuration-bluez config)
- "/libexec/bluetooth/bluetoothd")))
+ (list #$(file-append (bluetooth-configuration-bluez config)
+ "/libexec/bluetooth/bluetoothd"))))
(stop #~(make-kill-destructor))))
(define bluetooth-service-type
diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 7791780dfc..cfcaf4601b 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -1544,9 +1544,10 @@ greyed out, instead of only later giving \"not selectable\" popup error.
(start #~(make-forkexec-constructor
(list (string-append #$dovecot "/sbin/dovecot")
"-F")))
- (stop #~(make-forkexec-constructor
- (list (string-append #$dovecot "/sbin/dovecot")
- "stop")))))))
+ (stop #~(lambda _
+ (invoke #$(file-append dovecot "/sbin/dovecot")
+ "stop")
+ #f))))))
(define %dovecot-pam-services
(list (unix-pam-service "dovecot")))
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 618dd95969..383b2b0d04 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,18 @@
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
+
+ simulated-wifi-service-type
+
openvswitch-service-type
openvswitch-configuration
@@ -1360,6 +1373,112 @@ 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.")))
+
+(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
;;;
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index e99458da43..2f30c6c907 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -297,8 +297,7 @@ and return the resulting '.go' file."
;; everything slow. Thus, increase the timeout compared to the
;; default 5s in the Shepherd 0.7.0. See
;; <https://bugs.gnu.org/40572>.
- ;; XXX: Use something better when the next Shepherd is out.
- (set! (@@ (shepherd service) %pid-file-timeout) 30)
+ (default-pid-file-timeout 30)
;; Arrange to spawn a REPL if something goes wrong. This is better
;; than a kernel panic.
diff --git a/gnu/services/spice.scm b/gnu/services/spice.scm
index 8a835fe78e..fd85dc234f 100644
--- a/gnu/services/spice.scm
+++ b/gnu/services/spice.scm
@@ -54,7 +54,7 @@
(documentation "Spice vdagentd service")
(requirement '(udev))
(provision '(spice-vdagentd))
- (start #~(make-forkexec-constructor #$@spice-vdagentd-command))
+ (start #~(make-forkexec-constructor '#$spice-vdagentd-command))
(stop #~(make-kill-destructor)))))
(define spice-vdagent-profile