all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "\( via Guix-patches" via <guix-patches@gnu.org>
To: 58454@debbugs.gnu.org
Cc: "\(" <paren@disroot.org>
Subject: [bug#58454] [PATCH v2] gnu: home: Add home-dbus-service-type.
Date: Wed, 12 Oct 2022 09:01:47 +0100	[thread overview]
Message-ID: <20221012080147.4971-1-paren@disroot.org> (raw)
In-Reply-To: <20221011194513.26008-1-paren@disroot.org>

* gnu/home/services/desktop.scm (home-dbus-service-type): New
  variable.
(home-dbus-configuration): New record type.
* doc/guix.texi: Document them.
---
 doc/guix.texi                 | 17 ++++++++++
 gnu/home/services/desktop.scm | 58 ++++++++++++++++++++++++++++++++++-
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5867acb746..990113703b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41262,6 +41262,23 @@ format.
 
 @end deftp
 
+@defvr {Scheme Variable} home-dbus-service-type
+This is the service type for running a session-specific D-Bus, for
+unprivileged applications that require D-Bus to be running.
+@end defvr
+
+@deftp {Data Type} home-dbus-configuration
+The configuration record for @code{home-dbus-service-type}.
+
+@table @asis
+@item @code{dbus} (default: @code{dbus})
+The package providing the @code{/bin/dbus-daemon} command.
+
+@item @code{verbose?} (default: @code{#f})
+Whether to enable logging.
+@end table
+@end deftp
+
 @node Guix Home Services
 @subsection Guix Home Services
 
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index b0f4d969b0..20d0724055 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,6 +21,7 @@ (define-module (gnu home services desktop)
   #:use-module (gnu home services)
   #:use-module (gnu home services shepherd)
   #:use-module (gnu services configuration)
+  #:autoload   (gnu packages glib)    (dbus)
   #:autoload   (gnu packages xdisorg) (redshift)
   #:use-module (guix records)
   #:use-module (guix gexp)
@@ -27,8 +29,10 @@ (define-module (gnu home services desktop)
   #:use-module (ice-9 match)
   #:export (home-redshift-configuration
             home-redshift-configuration?
+            home-redshift-service-type
 
-            home-redshift-service-type))
+            home-dbus-configuration
+            home-dbus-service-type))
 
 \f
 ;;;
@@ -172,3 +176,55 @@ (define home-redshift-service-type
    (description
     "Run Redshift, a program that adjusts the color temperature of display
 according to time of day.")))
+
+\f
+;;;
+;;; D-Bus.
+;;;
+
+(define-record-type* <home-dbus-configuration>
+  home-dbus-configuration make-home-dbus-configuration
+  home-dbus-configuration?
+  (dbus home-dbus-dbus                  ;file-like
+        (default dbus))
+  (verbose? home-dbus-verbose?          ;boolean
+            (default #f)))
+
+(define (home-dbus-shepherd-services config)
+  (list (shepherd-service
+         (documentation "Run the D-Bus daemon in session-specific mode.")
+         (provision '(dbus-session))
+         (start #~(make-forkexec-constructor
+                   (list #$(file-append (home-dbus-dbus config)
+                                        "/bin/dbus-daemon")
+                         "--nofork" "--session"
+                         (format #f "--address=unix:path=~a/bus"
+                                 (or (getenv "XDG_RUNTIME_DIR")
+                                     (format #f "/run/user/~a"
+                                             (getuid)))))
+                   #$@(if (home-dbus-verbose? config)
+                          (list #:environment-variables
+                                #~(list "DBUS_VERBOSE=1")
+                                #:log-file
+                                (format #f "~a/dbus-daemon.log"
+                                        (or (getenv "XDG_LOG_HOME")
+                                            (format #f "~a/.local/var/log"
+                                                    (getenv "HOME")))))
+                          '())))
+         (stop #~(make-kill-destructor)))))
+
+(define (home-dbus-environment-variables config)
+  '(("DBUS_SESSION_BUS_ADDRESS"
+     . "unix:path=${XDG_RUNTIME_DIR:-/run/user/$UID}/bus")))
+
+(define home-dbus-service-type
+  (service-type
+   (name 'home-dbus)
+   (extensions
+    (list (service-extension home-shepherd-service-type
+                             home-dbus-shepherd-services)
+          (service-extension home-environment-variables-service-type
+                             home-dbus-environment-variables)))
+   (default-value (home-dbus-configuration))
+   (description
+    "Run the session-specific D-Bus inter-process message bus.")))
-- 
2.38.0





  parent reply	other threads:[~2022-10-12  8:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 19:45 [bug#58454] [PATCH 0/1] gnu: home: Add home-dbus-service-type ( via Guix-patches via
2022-10-11 19:54 ` [bug#58454] [PATCH 1/1] " ( via Guix-patches via
2022-10-12  7:25   ` Andrew Tropin
2022-10-12  7:53     ` ( via Guix-patches via
2022-10-12 10:37       ` Andrew Tropin
2022-10-12 14:57         ` ( via Guix-patches via
2022-10-12  8:01 ` [bug#58454] [PATCH] " ( via Guix-patches via
2022-10-12  8:01 ` ( via Guix-patches via [this message]
2022-10-12 20:21 ` [bug#58454] [PATCH v3] " ( via Guix-patches via
2022-10-13  5:22   ` Andrew Tropin
2022-10-13  6:10     ` ( via Guix-patches via
2022-10-14 15:15 ` [bug#58454] [PATCH 0/1] " Ludovic Courtès
2022-10-14 19:19   ` ( via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221012080147.4971-1-paren@disroot.org \
    --to=guix-patches@gnu.org \
    --cc=58454@debbugs.gnu.org \
    --cc=paren@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.