From patchwork Sun Apr 20 06:21:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Eure X-Patchwork-Id: 41820 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 8D5BB27BC4B; Sun, 20 Apr 2025 07:23:13 +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 EFC1D27BC49 for ; Sun, 20 Apr 2025 07:23:12 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u6O4l-0001Q3-QC; Sun, 20 Apr 2025 02:22:51 -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 1u6O42-0001FS-SW for guix-patches@gnu.org; Sun, 20 Apr 2025 02:22:08 -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 1u6O42-0008EX-Fs for guix-patches@gnu.org; Sun, 20 Apr 2025 02:22: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:References:In-Reply-To:Date:From:To:Subject; bh=JlsQTN9bjc6RKKbJU+j1LxeoSX3acM7Z/LKbZGCX1q8=; b=dG+fCJ9scc1g/OQCIhJRf7emBSIAE6NC4aLeIqjAcyhPxzh93UTzsm0YdGK/YpPvOn6REh35eidXnI7zEbjsaKrfFZjy0Zf17X3wTl/2InTbwWzyQUXCp6gPJKP2jvbwhdcRy5IWi2M9sIRdAiZ50CON3mxCe/o1Q9FiAB2N5crR5FYq7Hy2/AEZQWABzKG/cuIg9fgnMOdsX4vmVvUdZde3JZm2xl7jyyYWAUTrP6pVHE2xD23mYw9Jn66Ext5FsnPfm+kvAsz24IFLXWiUYKNJWqJ8cJhmfC505NA4tic6hVzPi969xBrA+jpDPxZB6yz68YRPC2xPshjAhg9YdQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u6O42-0001sw-Aj for guix-patches@gnu.org; Sun, 20 Apr 2025 02:22:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77266] [PATCH v3 1/2] gnu: Merge xorg configurations when extending. Resent-From: Ian Eure Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 20 Apr 2025 06:22: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.17451301067192 (code B ref 77266); Sun, 20 Apr 2025 06:22:02 +0000 Received: (at 77266) by debbugs.gnu.org; 20 Apr 2025 06:21:46 +0000 Received: from localhost ([127.0.0.1]:43807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u6O3l-0001rv-Bo for submit@debbugs.gnu.org; Sun, 20 Apr 2025 02:21:45 -0400 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]:50091) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u6O3i-0001rH-6a for 77266@debbugs.gnu.org; Sun, 20 Apr 2025 02:21:43 -0400 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id 08D5A13800EF; Sun, 20 Apr 2025 02:21:37 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Sun, 20 Apr 2025 02:21:37 -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:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1745130097; x=1745216497; bh=JlsQTN9bjc6RKKbJU+j1LxeoSX3acM7Z/LKbZGCX1q8=; b= g15tpMoWfDmB9hovC4K/wJPDfBSt6Y2o+x1E5RTIBvfX3Avn25hLWXh+Chv5HCSz f+FICBevogJuUE3DxzQHxidPkStCXU0J6R+ajSQrwYX198aKzQ/2stRnrcrCknBt e9c1OYkNKxaTr2BlQAfRpWtsu23geFykH+kKC7wqOqxKeM1CsiIdeH2nP5g41RBa ceQgMa9LwodZaCw5UjrpubKOTf4nxTLf/kaN1hWgu/4cCmj84+TWB8qlxUYvmFTV pedErtqbJPNVXNltYN5SYHnLNmxMAuvCloE95l/rlyMEnczd1UK5O+JvAhUdBArq JXWw9WzyC/In8meHyLwMUA== 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:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1745130097; x= 1745216497; bh=JlsQTN9bjc6RKKbJU+j1LxeoSX3acM7Z/LKbZGCX1q8=; b=Z WkPISXgtPS6/N8T+DvUwgT+Jddx0uSWuJdXwbPbt2qv3e4368jOOZM7XjlFBCea/ EiMpR1rEJn+AlAIU9oa5Dy4lD0r99Nm+E9shVcXxO684s6e9dPYRJ3KtP+5cMf3/ kXvdFZxJ6I5jifA9UtHEoAGGeu2n7ANTFV4r24lxZ10A/lwyNS9sICQPgZ2igzMx S/rc3z0uxEnOsyaZl8CNiMBFOTR15lElSzdRaiCaeXn/y43v3eR1C8pjfCHnLgzv SYAz04HkJvGzj3pNvnClWNoGH0uX5izE/FZmPWs6AUi3D2UL/n4HaEwPepRSIC6z /rUNFeYhFQIkoJScNcOEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvfeejudejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvf evufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepkfgrnhcugfhurhgvuceo ihgrnhesrhgvthhrohhsphgvtgdrthhvqeenucggtffrrghtthgvrhhnpefggeehudelle eggfevueehffefgeevieejiedtteduleeluefhjeeiudfhudffteenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehirghnsehrvghtrhhoshhpvg gtrdhtvhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthht ohepjeejvdeiieesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehirghnse hrvghtrhhoshhpvggtrdhtvh X-ME-Proxy: Feedback-ID: id9014242:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 20 Apr 2025 02:21:36 -0400 (EDT) From: Ian Eure Date: Sat, 19 Apr 2025 23:21:20 -0700 Message-ID: <20250420062123.22442-2-ian@retrospec.tv> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420062123.22442-1-ian@retrospec.tv> References: <20250420062123.22442-1-ian@retrospec.tv> 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 | 49 +++++++++++++++++++++++++++++++++++++++++-- gnu/services/xorg.scm | 42 ++++++++++++++++++++++++++++++------- 2 files changed, 82 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index eebc1a1590..02150eb497 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,52 @@ 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..cb933693b7 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 + (append-map xorg-configuration-modules configs)) + (fonts + (append-map xorg-configuration-fonts configs)) + (drivers + (append-map xorg-configuration-drivers configs)) + (resolutions + (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