diff mbox series

[bug#58454,v3] gnu: home: Add home-dbus-service-type.

Message ID 20221012202139.8379-1-paren@disroot.org
State Accepted
Headers show
Series [bug#58454,v3] gnu: home: Add home-dbus-service-type. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

\( Oct. 12, 2022, 8:21 p.m. UTC
* 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                 | 14 +++++++++
 gnu/home/services/desktop.scm | 54 ++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 1 deletion(-)

Comments

Andrew Tropin Oct. 13, 2022, 5:22 a.m. UTC | #1
On 2022-10-12 21:21, "\( via Guix-patches" via wrote:

> * 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                 | 14 +++++++++
>  gnu/home/services/desktop.scm | 54 ++++++++++++++++++++++++++++++++++-
>  2 files changed, 67 insertions(+), 1 deletion(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 5867acb746..78ada9c301 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -41262,6 +41262,20 @@ 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.
> +@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..1f41ace766 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))
>  
>  
>  ;;;
> @@ -172,3 +176,51 @@ (define home-redshift-service-type
>     (description
>      "Run Redshift, a program that adjusts the color temperature of display
>  according to time of day.")))
> +
> +
> +;;;
> +;;; 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)))
> +
> +(define (home-dbus-shepherd-services config)
> +  (list (shepherd-service
> +         (documentation "Run the D-Bus daemon in session-specific mode.")
> +         (provision '(dbus-session))

Changed it to just dbus.

> +         (start #~(make-forkexec-constructor
> +                   (list #$(file-append (home-dbus-dbus config)
> +                                        "/bin/dbus-daemon")
> +                         "--nofork" "--session" "--nosyslog"

Removed --nosyslog.

> +                         (format #f "--address=unix:path=~a/bus"
> +                                 (or (getenv "XDG_RUNTIME_DIR")
> +                                     (format #f "/run/user/~a"
> +                                             (getuid)))))
> +                   #:environment-variables
> +                   #~(list "DBUS_VERBOSE=1")
> +                   #:log-file
> +                   (format #f "~a/dbus-daemon.log"

Changed it to dbus.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.")))

Applied with small adjustments mentioned above, will push soon, thank
you for the patch.

Now I can also close the TODO in rde :)
https://git.sr.ht/~abcdw/rde/tree/111130ebf3ef4a9143186604c054aeb807a84063/rde/features/base.scm#L305
\( Oct. 13, 2022, 6:10 a.m. UTC | #2
Thanks!

    -- (
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 5867acb746..78ada9c301 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41262,6 +41262,20 @@  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.
+@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..1f41ace766 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))
 
 
 ;;;
@@ -172,3 +176,51 @@  (define home-redshift-service-type
    (description
     "Run Redshift, a program that adjusts the color temperature of display
 according to time of day.")))
+
+
+;;;
+;;; 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)))
+
+(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" "--nosyslog"
+                         (format #f "--address=unix:path=~a/bus"
+                                 (or (getenv "XDG_RUNTIME_DIR")
+                                     (format #f "/run/user/~a"
+                                             (getuid)))))
+                   #: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.")))