From patchwork Sun Nov 5 22:30:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 55962 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 5606F27BBEA; Sun, 5 Nov 2023 22:31:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 413C227BBE2 for ; Sun, 5 Nov 2023 22:31:33 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzleR-0002Uj-7q; Sun, 05 Nov 2023 17:31:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzleP-0002UP-Oq for guix-patches@gnu.org; Sun, 05 Nov 2023 17:31:26 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qzleP-0000y2-Gb for guix-patches@gnu.org; Sun, 05 Nov 2023 17:31:25 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qzlf0-0003VS-F8 for guix-patches@gnu.org; Sun, 05 Nov 2023 17:32:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#65343] [PATCH v2] home: services: Add 'x11-display' service. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 05 Nov 2023 22:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65343 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Oleg Pykhalov Cc: 65343@debbugs.gnu.org, Brian Cully Received: via spool by 65343-submit@debbugs.gnu.org id=B65343.169922348713424 (code B ref 65343); Sun, 05 Nov 2023 22:32:02 +0000 Received: (at 65343) by debbugs.gnu.org; 5 Nov 2023 22:31:27 +0000 Received: from localhost ([127.0.0.1]:38315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzleR-0003US-Cn for submit@debbugs.gnu.org; Sun, 05 Nov 2023 17:31:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzleQ-0003UE-El for 65343@debbugs.gnu.org; Sun, 05 Nov 2023 17:31:26 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzldY-0000kf-Fp; Sun, 05 Nov 2023 17:30:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=j8FxZkeeXD/0/5pp3FmjZC1k0IQ6m+ALpWDhzAwDZs4=; b=fI7xb8Fzsw/Vj9jB5a5z uUYvQnw5tD/3YsraYEggtV2eQaA4IPWfra2TIWj1g64PEpK6vy+3RC0oJ8IKf3zzIL93W0nQStsph I7x9ME7jgNotvwyHqo30w4ZFKdrDcTyGdxvch7NI3Ft00CBMu+OCBCf0fZa7iCbrIs1RiX0iaHP1I KxNQDQE8Si7u4Xnt9eN0nZ07/TQGB6Z1mpaMV0O3r8abvr3tw7B4ne3BVeCXkaij0Oe1kA3EEG0DD 8Bk7duy4Xf4Qqbh6f8/iYOstkoZlmEbOkoSZq4n3F/5FweESxshhvdqth6A5E9dhuQ3hZoS3l8svT OrWFZ5+dQG78ag==; From: Ludovic =?utf-8?q?Court=C3=A8s?= In-Reply-To: <87lebekc3u.fsf@gmail.com> (Oleg Pykhalov's message of "Fri, 03 Nov 2023 19:58:29 +0300") References: <87il8c2xdd.fsf@gmail.com> <87lebekc3u.fsf@gmail.com> Date: Sun, 05 Nov 2023 23:30:30 +0100 Message-ID: <87wmuvygs9.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi, Oleg Pykhalov skribis: > During testing in a virtual machine I found an issue, which could be > reproduced with the steps bellow. It's not an emergency issue which > blocks the patch from merging, because we still have a workaround in our > pocket (stop and start ‘shepherd’ manually on a specific ‘DISPLAY’). > > - start ‘shepherd’ manually on ‘127.0.0.1:5’ by typing ‘shepherd’ in a > GUI terminal; > - stop ‘x11-display’ with ‘herd stop x11-display’; > - start ‘x11-display’ with ‘herd start x11-display :1’; > - start ‘redshift’ with ‘herd start redshift’. > > The ‘redshift’ service starts a ‘redshift’ process. The > /proc/REDSHIFT_PID/environ file has a ‘DISPLAY’ variable setted to > ‘127.0.0.1:5’. Indeed, good catch! There was a bug: it’s not enough to call ‘setenv’ because ‘make-forkexec-constructor’ & co. have an explicit #:environment-variables parameter, which defaults to the environment of ‘shepherd’ when it was started. (On top of that, setting the ‘default-environment-variables’ SRFI-39 parameter from the ‘start’ method of ‘x11-display’ wouldn’t work because each fiber has its own dynamic environment…) I had to make the change below. Result pushed as commit 08d94fe20eca47b69678b3eced8749dd02c700a4. Thank you for reviewing and testing! Ludo’. diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm index 45a319c0f8..91465bf168 100644 --- a/gnu/home/services/desktop.scm +++ b/gnu/home/services/desktop.scm @@ -92,6 +92,11 @@ (define (x11-shepherd-service delay) (let ((display (or display (find-display #$delay)))) (when display + ;; Note: 'make-forkexec-constructor' calls take their + ;; default #:environment-variables value before this service + ;; is started and are thus unaffected by the 'setenv' call + ;; below. Users of this service have to explicitly query + ;; its value. (setenv "DISPLAY" display)) display))) (stop #~(lambda (_) @@ -244,9 +249,20 @@ (define (redshift-shepherd-service config) ;; available, and fails to start otherwise. (requirement '(x11-display)) - (start #~(make-forkexec-constructor - (list #$(file-append (home-redshift-configuration-redshift config) "/bin/redshift") - "-c" #$config-file))) + (modules '((srfi srfi-1) + (srfi srfi-26))) + (start #~(lambda _ + (fork+exec-command + (list #$(file-append + (home-redshift-configuration-redshift config) + "/bin/redshift") + "-c" #$config-file) + + ;; Inherit the 'DISPLAY' variable set by 'x11-display'. + #:environment-variables + (cons (string-append "DISPLAY=" (getenv "DISPLAY")) + (remove (cut string-prefix? "DISPLAY=" <>) + (default-environment-variables)))))) (stop #~(make-kill-destructor)) (actions (list (shepherd-configuration-action config-file))))))