From patchwork Tue Apr 22 00:18:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Eure X-Patchwork-Id: 41912 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 6A04327BC4B; Tue, 22 Apr 2025 01:20:31 +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=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 B700827BC49 for ; Tue, 22 Apr 2025 01:20:30 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u71My-0000Ew-2M; Mon, 21 Apr 2025 20:20:12 -0400 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 1u71Mo-0000Dx-U2 for guix-patches@gnu.org; Mon, 21 Apr 2025 20:20:05 -0400 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 1u71Mo-0002Jm-Fe for guix-patches@gnu.org; Mon, 21 Apr 2025 20:20:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=7DQBBY9GAa/Cmr9PXdvmsPVYkQfFGi/GMhfkmwoOyDM=; b=gHZCAKzTdZ3hS+oMKKWubKYdLi1Ygu641du3fCqKbP9mrGWgEu1oE6nBuLizx/t6MDHaUCmaIHbLWwGhZ0Z4zRPL7JLI+YcQAFd7JCyA7VBPrj5AfEaLPG0Pwg5bjk5hwtgnvgbHsbsc2YZ07g+5fFZh+y28ac6K+aAPPwMo9+FqVYNa46uWLYaIDPl8ItpRXTlZDjwtiQKrh0IDQ8fWZLK/moBT3hqSLrujlsFfgbmyWquhN+iJDcM8rkXkf7FjwK5ciDQLs0fyKl012zLmiYqr/ysRF7+59uloUq+dlGgSius56A2W7HMJtvj0KjqjVYnIilvoZKGMAhijoJ5h/Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u71Mo-00066z-7a for guix-patches@gnu.org; Mon, 21 Apr 2025 20:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77266] [PATCH v4 1/2] gnu: Merge xorg configurations when extending. References: <20250326042354.14033-1-ian@retrospec.tv> In-Reply-To: <20250326042354.14033-1-ian@retrospec.tv> Resent-From: Ian Eure Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 22 Apr 2025 00:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77266 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77266@debbugs.gnu.org Cc: Ian Eure Received: via spool by 77266-submit@debbugs.gnu.org id=B77266.174528114423399 (code B ref 77266); Tue, 22 Apr 2025 00:20:02 +0000 Received: (at 77266) by debbugs.gnu.org; 22 Apr 2025 00:19:04 +0000 Received: from localhost ([127.0.0.1]:41195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u71Lo-00064z-H7 for submit@debbugs.gnu.org; Mon, 21 Apr 2025 20:19:04 -0400 Received: from fhigh-a8-smtp.messagingengine.com ([103.168.172.159]:47113) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u71Lj-00064J-9C for 77266@debbugs.gnu.org; Mon, 21 Apr 2025 20:18:59 -0400 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 199CF1140170; Mon, 21 Apr 2025 20:18:50 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Mon, 21 Apr 2025 20:18:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=retrospec.tv; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :subject:subject:to:to; s=fm1; t=1745281130; x=1745367530; bh=7D QBBY9GAa/Cmr9PXdvmsPVYkQfFGi/GMhfkmwoOyDM=; b=YBtc8SXy8MiO9PrYkD JfnV082N0V6TLILrkOhxssQjrDybWoGDq9MiWRI6++racSNSHKFWc4NxRg0aCzlh 6Nc9MgYoRTniWdyGKq9THE3chGuOMKNGTyyXt0fnjAtpXBzq4ANPX+yQul+0Ut+E hYH/tTF1a+5s5ahPQ5SoanCEHGZ0IoKRJSfWajW9A99nXfMOhUfA1FwCkX42l/IK CBOYtYzptGsrUfxp22WxaBmvYUawbq6Z7RPbLzXvYICeDGzTG5A0dnqBDkjUtfII SZPQn/iw0dEx+p+ZhdrN4xb2r1XdmCiCeY0osCw4P5U5uGNDR0gJ0wnTlhnibzF4 iT3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1745281130; x=1745367530; bh=7DQBBY9GAa/Cmr9PXdvmsPVYkQfF Gi/GMhfkmwoOyDM=; b=oRzKKBe0zwLe4oPGyPXdFQVO3Ln1GWY2cjGCQ+kjGG/s smxhbmiKPUW7HfwH6zWONEXXchLP1Wf0Jh1zpHiYzHZDlTRC6Gb9vHkiwRhZ6RGq IWf1eQdNitnKFYN88+SlZC9vCENFj+TfzHThO4BJBizdsUJTf4PydNPeEpddgfs3 8c3Dle9Tf1EpA0DFPmOamNc1ri6GmggdzdnJCZG39biLAWozGlf3Y/rMwIShO9v3 z1s/oUyrv9bnC7AP6TumuPStKjwEoECMw7tS0MBR+bYzB6jv9FPwduA6HFW1CoqI VkntIgHp4g4yz73R6R91XDTEMIJvW4DOoXCpIuyy7g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvgedvvdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvf evufffkffogggtgfesthekredtredtjeenucfhrhhomhepkfgrnhcugfhurhgvuceoihgr nhesrhgvthhrohhsphgvtgdrthhvqeenucggtffrrghtthgvrhhnpefgueekffejudfgvd evteelteeitdeuuddufffhuefhiefhjeetuefhgfettedvteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehirghnsehrvghtrhhoshhpvggtrd htvhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep jeejvdeiieesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehirghnsehrvg htrhhoshhpvggtrdhtvh X-ME-Proxy: Feedback-ID: id9014242:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Apr 2025 20:18:49 -0400 (EDT) From: Ian Eure Date: Mon, 21 Apr 2025 17:18:43 -0700 Message-ID: <20250422001845.20855-1-ian@retrospec.tv> X-Mailer: git-send-email 2.49.0 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 Configuration for xorg is embedded in the various display-manager configuration records, and extension support is factored out into the `handle-xorg-configuration' macro. However, the extension mechanism replaces the existing xorg-configuration with the supplied one, making it impossible to compose configuration from multiple sources. This patch adds a procedure to merge two xorg-configuration records, and calls it within handle-xorg-configuration, allowing the config to be built piecemeal. * gnu/services/xorg.scm (merge-xorg-configurations): New variable. (handle-xorg-configuration): Merge xorg configs. * doc/guix.texi (X Window): Document xorg-configuration composition. Change-Id: I20e9db911eef5d4efe98fdf382f3084e4defc1ba --- doc/guix.texi | 48 +++++++++++++++++++++++++++++++++++++++++-- gnu/services/xorg.scm | 42 ++++++++++++++++++++++++++++++------- 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index eebc1a1590..15e3192939 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -138,6 +138,7 @@ Copyright @copyright{} 2024 45mg@* Copyright @copyright{} 2025 Sören Tempel@* Copyright @copyright{} 2025 Rostislav Svoboda@* Copyright @copyright{} 2025 Zacchaeus@* +Copyright @copyright{} 2025 Ian Eure@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -24916,8 +24917,51 @@ Tell the log-in manager (of type @var{login-manager-service-type}) to use @var{config}, an @code{} record. Since the Xorg configuration is embedded in the log-in manager's -configuration---e.g., @code{gdm-configuration}---this procedure provides a -shorthand to set the Xorg configuration. +configuration---e.g., @code{gdm-configuration}---this procedure provides +a shorthand to set the Xorg configuration. + +In addition to @code{set-xorg-configuration}, you may extend your log-in +manager’s service-type to provide reusable, partial configurations, +which are concatenated to create the final Xorg configuration: + +@lisp +;; A service which configures Intel video drivers. +(define %xorg-intel-service + (simple-service + 'xorg-intel + gdm-service-type + (xorg-configuration + (modules (list xf86-video-intel)) + (drivers '("intel")) + (extra-config " + Section \"Device\" + Identifier \"Intel GPU\" + Driver \"intel\" + Option \"TearFree\" \"true\" + EndSection")))) + +;; A service which configures the keyboard. +(define %xorg-keyboard-service + (simple-service + 'xorg-keyboard + gdm-service-type + (xorg-configuration + (keyboard-layout + (keyboard-layout "us" #:options '("ctrl:nocaps")))))) + +(operating-system + (services + (append + (list (service gdm-service-type) + %xorg-intel-service + %xorg-keyboard-service) + %base-services)) + @dots{}) +@end lisp + +Service extension and @code{set-xorg-configuration} can each be used +seperately, or in conjunction. + @end deffn @deffn {Procedure} xorg-start-command [config] diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index bef05b9bb9..c313b7bc59 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -209,6 +209,34 @@ (define-record-type* (server-arguments xorg-configuration-server-arguments ;list of strings (default %default-xorg-server-arguments))) +(define (merge-xorg-configurations a b) + (let ((configs (list b a))) ; Prefer later configurations. + (xorg-configuration + (modules + (delete-duplicates (append-map xorg-configuration-modules configs))) + (fonts + (delete-duplicates (append-map xorg-configuration-fonts configs))) + (drivers + (delete-duplicates (append-map xorg-configuration-drivers configs))) + (resolutions + (delete-duplicates (append-map xorg-configuration-resolutions configs))) + (extra-config (append-map xorg-configuration-extra-config configs)) + ;; Prefer the more recently set layout. + (keyboard-layout (or (xorg-configuration-keyboard-layout b) + (xorg-configuration-keyboard-layout a) + #f)) + (server + ;; Prefer the non-default server. + (if (eq? xorg-server (xorg-configuration-server a)) + (xorg-configuration-server b) + (xorg-configuration-server a))) + (server-arguments + ;; Prefer the non-default arguments. + (if (eq? %default-xorg-server-arguments + (xorg-configuration-server-arguments a)) + (xorg-configuration-server-arguments b) + (xorg-configuration-server-arguments a)))))) + (define (xorg-configuration->file config) "Compute an Xorg configuration file corresponding to CONFIG, an record." @@ -334,9 +362,12 @@ (define (expand modules) port) (newline port))) - (for-each (lambda (config) - (display config port)) - '#$(xorg-configuration-extra-config config)))))) + (for-each + (lambda (config) + (display config port) + (newline port)) + (delete-duplicates + '#$(xorg-configuration-extra-config config))))))) (computed-file "xserver.conf" build))) @@ -628,10 +659,7 @@ (define-syntax handle-xorg-configuration ((_ configuration-record service-type-definition) (service-type (inherit service-type-definition) - (compose (lambda (extensions) - (match extensions - (() #f) - ((config . _) config)))) + (compose (cut reduce merge-xorg-configurations #f <>)) (extend (lambda (config xorg-configuration) (if xorg-configuration (configuration-record