From patchwork Wed Oct 12 20:21:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "\\(" X-Patchwork-Id: 43354 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D4C2C27BBEA; Wed, 12 Oct 2022 21:23:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 51E8127BBE9 for ; Wed, 12 Oct 2022 21:23:14 +0100 (BST) Received: from localhost ([::1]:36404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiiG0-00056S-Td for patchwork@mira.cbaines.net; Wed, 12 Oct 2022 16:23:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiiEs-0004VN-8T for guix-patches@gnu.org; Wed, 12 Oct 2022 16:22:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oiiEr-0002jU-Sz for guix-patches@gnu.org; Wed, 12 Oct 2022 16:22:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oiiEr-0004AG-Hx for guix-patches@gnu.org; Wed, 12 Oct 2022 16:22:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58454] [PATCH v3] gnu: home: Add home-dbus-service-type. References: <20221011194513.26008-1-paren@disroot.org> In-Reply-To: <20221011194513.26008-1-paren@disroot.org> Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 12 Oct 2022 20:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58454 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58454@debbugs.gnu.org Cc: "\(" Received: via spool by 58454-submit@debbugs.gnu.org id=B58454.166560611115992 (code B ref 58454); Wed, 12 Oct 2022 20:22:01 +0000 Received: (at 58454) by debbugs.gnu.org; 12 Oct 2022 20:21:51 +0000 Received: from localhost ([127.0.0.1]:58503 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiiEh-00049r-7Z for submit@debbugs.gnu.org; Wed, 12 Oct 2022 16:21:51 -0400 Received: from knopi.disroot.org ([178.21.23.139]:33268) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oiiEe-00049i-PH for 58454@debbugs.gnu.org; Wed, 12 Oct 2022 16:21:50 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 2E8414DAE3; Wed, 12 Oct 2022 22:21:47 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id erdCwQ4L6kuS; Wed, 12 Oct 2022 22:21:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665606105; bh=XjXXUYSL9JuXeWyUBLOhGDSVcOkZLh11+xyf4GoQWYY=; h=From:To:Cc:Subject:Date; b=NW19+dGQH9IvGzVZ67URpi96zHGf1F/MszE2mrj+IBIRtwAZte4sHZNz1cu3Dv1Jd pV59AknIGQ0DEvXfvME3IDXdoJ1WAOtSCTGem5eA9DHQo3q0SGV0tAHGwMhK82DtFd XvnT62gpSckrVMmWN8fOhHzRwXBvWnVRXwDH3ruR8w7ZycYg21Lo6qMqLPv9qrxpDz eL2aWGBjC2fy8tkFGz5O8G3h9yEGs6wElMVIj+O9fbsOmBJeL1MuD8dzZcx1xtSjog WB/GrDwAmCA6uV7j5s8qg3K+SjpDHhtBaAN4py84XYOvvLhXth8kUE6eU9RYwTMu+T 0vStxBmp47Acg== Date: Wed, 12 Oct 2022 21:21:39 +0100 Message-Id: <20221012202139.8379-1-paren@disroot.org> Mime-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: "\(" X-ACL-Warn: , "\( via Guix-patches" X-Patchwork-Original-From: "\( via Guix-patches" via From: "\\(" X-getmail-retrieved-from-mailbox: Patches * 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 +;;; Copyright © 2022 ( ;;; ;;; 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 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.")))