summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/desktop.scm58
-rw-r--r--gnu/services/herd.scm36
-rw-r--r--gnu/services/networking.scm62
3 files changed, 89 insertions, 67 deletions
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index 24fd43a207..0499071436 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -1075,10 +1075,60 @@ include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
(define (elogind-dbus-service config)
- (list (wrapped-dbus-service (elogind-package config)
- "libexec/elogind/elogind"
- `(("ELOGIND_CONF_FILE"
- ,(elogind-configuration-file config))))))
+ "Return a @file{org.freedesktop.login1.service} file that tells D-Bus how to
+\"start\" elogind. In practice though, our elogind is started when booting by
+shepherd. Thus, the @code{Exec} line of this @file{.service} file does not
+explain how to start elogind; instead, it spawns a wrapper that waits for the
+@code{elogind} shepherd service. This avoids a race condition where both
+@command{shepherd} and @command{dbus-daemon} would attempt to start elogind."
+ ;; For more info on the elogind startup race, see
+ ;; <https://issues.guix.gnu.org/55444>.
+
+ (define elogind
+ (elogind-package config))
+
+ (define wrapper
+ (program-file "elogind-dbus-shepherd-sync"
+ (with-imported-modules '((gnu services herd))
+ #~(begin
+ (use-modules (gnu services herd)
+ (srfi srfi-34))
+
+ (guard (c ((service-not-found-error? c)
+ (format (current-error-port)
+ "no elogind shepherd service~%")
+ (exit 1))
+ ((shepherd-error? c)
+ (format (current-error-port)
+ "elogind shepherd service not \
+started~%")
+ (exit 2)))
+ (wait-for-service 'elogind))))))
+
+ (define build
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils)
+ (ice-9 match))
+
+ (define service-directory
+ "/share/dbus-1/system-services")
+
+ (mkdir-p (dirname (string-append #$output service-directory)))
+ (copy-recursively (string-append #$elogind service-directory)
+ (string-append #$output service-directory))
+ (symlink (string-append #$elogind "/etc") ;for etc/dbus-1
+ (string-append #$output "/etc"))
+
+ ;; Replace the "Exec=" line of the 'org.freedesktop.login1.service'
+ ;; file with one that refers to WRAPPER instead of elogind.
+ (match (find-files #$output "\\.service$")
+ ((file)
+ (substitute* file
+ (("Exec[[:blank:]]*=.*" _)
+ (string-append "Exec=" #$wrapper "\n"))))))))
+
+ (list (computed-file "elogind-dbus-service-wrapper" build)))
(define (pam-extension-procedure config)
"Return an extension for PAM-ROOT-SERVICE-TYPE that ensures that all the PAM
diff --git a/gnu/services/herd.scm b/gnu/services/herd.scm
index 80d08f849e..a7c845b4b0 100644
--- a/gnu/services/herd.scm
+++ b/gnu/services/herd.scm
@@ -58,7 +58,8 @@
load-services/safe
start-service
stop-service
- restart-service))
+ restart-service
+ wait-for-service))
;;; Commentary:
;;;
@@ -313,6 +314,39 @@ when passed a service with an already-registered name."
(with-shepherd-action name ('restart) result
result))
+(define* (wait-for-service name #:key (timeout 20))
+ "Wait for the service providing NAME, a symbol, to be up and running, and
+return its \"running value\". Give up after TIMEOUT seconds and raise a
+'&shepherd-error' exception. Raise a '&service-not-found-error' exception
+when NAME is not found."
+ (define (relevant-service? service)
+ (memq name (live-service-provision service)))
+
+ (define start
+ (car (gettimeofday)))
+
+ ;; Note: As of Shepherd 0.9.1, we cannot just call the 'start' method and
+ ;; wait for it: it would spawn an additional elogind process. Thus, poll.
+ (let loop ((attempts 0))
+ (define services
+ (current-services))
+
+ (define now
+ (car (gettimeofday)))
+
+ (when (>= (- now start) timeout)
+ (raise (condition (&shepherd-error)))) ;XXX: better exception?
+
+ (match (find relevant-service? services)
+ (#f
+ (raise (condition (&service-not-found-error
+ (service name)))))
+ (service
+ (or (live-service-running service)
+ (begin
+ (sleep 1)
+ (loop (+ attempts 1))))))))
+
;; Local Variables:
;; eval: (put 'alist-let* 'scheme-indent-function 2)
;; eval: (put 'with-shepherd 'scheme-indent-function 1)
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index d8fe638940..90b9317510 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -57,7 +57,6 @@
#:use-module (gnu packages messaging)
#:use-module (gnu packages networking)
#:use-module (gnu packages ntp)
- #:use-module (gnu packages wicd)
#:use-module (gnu packages gnome)
#:use-module (gnu packages ipfs)
#:use-module (gnu build linux-container)
@@ -130,9 +129,6 @@
tor-hidden-service
tor-service-type
- wicd-service-type
- wicd-service
-
network-manager-configuration
network-manager-configuration?
network-manager-configuration-dns
@@ -1094,64 +1090,6 @@ project's documentation} for more information."
;;;
-;;; Wicd.
-;;;
-
-(define %wicd-activation
- ;; Activation gexp for Wicd.
- #~(begin
- (use-modules (guix build utils))
-
- (mkdir-p "/etc/wicd")
- (let ((file-name "/etc/wicd/dhclient.conf.template.default"))
- (unless (file-exists? file-name)
- (copy-file (string-append #$wicd file-name)
- file-name)))
-
- ;; Wicd invokes 'wpa_supplicant', which needs this directory for its
- ;; named socket files.
- (mkdir-p "/var/run/wpa_supplicant")
- (chmod "/var/run/wpa_supplicant" #o750)))
-
-(define (wicd-shepherd-service wicd)
- "Return a shepherd service for WICD."
- (list (shepherd-service
- (documentation "Run the Wicd network manager.")
- (provision '(networking))
- (requirement '(user-processes dbus-system loopback))
- (start #~(make-forkexec-constructor
- (list (string-append #$wicd "/sbin/wicd")
- "--no-daemon")))
- (stop #~(make-kill-destructor)))))
-
-(define wicd-service-type
- (service-type (name 'wicd)
- (extensions
- (list (service-extension shepherd-root-service-type
- wicd-shepherd-service)
- (service-extension dbus-root-service-type
- list)
- (service-extension activation-service-type
- (const %wicd-activation))
-
- ;; Add Wicd to the global profile.
- (service-extension profile-service-type list)))
- (description
- "Run @url{https://launchpad.net/wicd,Wicd}, a network
-management daemon that aims to simplify wired and wireless networking.")))
-
-(define* (wicd-service #:key (wicd wicd))
- "Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
-management daemon that aims to simplify wired and wireless networking.
-
-This service adds the @var{wicd} package to the global profile, providing
-several commands to interact with the daemon and configure networking:
-@command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
-and @command{wicd-curses} user interfaces."
- (service wicd-service-type wicd))
-
-
-;;;
;;; ModemManager
;;;