From patchwork Wed Mar 26 23:59:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Eure X-Patchwork-Id: 40867 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 528FA27BBE9; Thu, 27 Mar 2025 00:01:08 +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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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=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 ADB3227BBE2 for ; Thu, 27 Mar 2025 00:01:04 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txafh-0005jV-Og; Wed, 26 Mar 2025 20:00:33 -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 1txafF-0005ch-Ed for guix-patches@gnu.org; Wed, 26 Mar 2025 20:00:12 -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 1txafE-0000P3-T4 for guix-patches@gnu.org; Wed, 26 Mar 2025 20:00:05 -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=0IPbQwHlpM1miJ6dfEePoY2bkga4RmIx2z3l5vx4LA8=; b=vGINhshepDk3h51x1wIKMfivXCVOrfPs1usA7jOpTpilanmSwMNXc2RuImoI3qaUpoW4i3hI0H2SzdWUWIfFcZ5/sFwUYPxr2+3z4n2kfZwQ9nZe54/s89IqyFzy01dexOkB7OmfX8Y4URhAL01tF2LtMyR8+TEzLLkl8fx+j3A9+sMAOn4Y0AIJeLv0Yydv3VcedIhrycG4ZnEQfz1lCZjp8oO0iF6EdSqp6yQx7FIbPoQxeTIQRFv3niKnmZdqpQg63GquyGWJuN0rYlcukdI6D88XLAIQnWx0MBkbMrOA0yny8L+nx6Chq99HaL21wzuxQGF1GL8PcU85ZsxGkQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1txafD-0004Vb-U5 for guix-patches@gnu.org; Wed, 26 Mar 2025 20:00:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77266] [PATCH v2] 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: Thu, 27 Mar 2025 00:00:03 +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.174303359617260 (code B ref 77266); Thu, 27 Mar 2025 00:00:03 +0000 Received: (at 77266) by debbugs.gnu.org; 26 Mar 2025 23:59:56 +0000 Received: from localhost ([127.0.0.1]:44943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1txaf5-0004UI-Ah for submit@debbugs.gnu.org; Wed, 26 Mar 2025 19:59:56 -0400 Received: from fout-a6-smtp.messagingengine.com ([103.168.172.149]:60663) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1txaf0-0004SL-4M for 77266@debbugs.gnu.org; Wed, 26 Mar 2025 19:59:53 -0400 Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 7DF1E13838F0; Wed, 26 Mar 2025 19:59:44 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 26 Mar 2025 19:59:44 -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=1743033584; x=1743119984; bh=0I PbQwHlpM1miJ6dfEePoY2bkga4RmIx2z3l5vx4LA8=; b=dvksyx6pWNa+Xz5oOb nhMwpk6laDRLiih89dZSsMoIqjAziPo0X64Gz9netKKH5sbFBOcHzS/hAeA41pk+ 0NbNpxkru92J/VRiVEnebVccSScyISuvaZhmrUSQwxneMIlMvT0EHNpme4L+rJU3 LDTqDihernMGhqdNY9aOvpdfcqw034EMb8NKU3m0ZTZRV7zgRKvRcVcaebPvQb8k ziUCd8u0AvLVIq1IOzKKYAGiLbz75Eu4CEGdDGYoI0AR/f1t2cwCoj/KMnKUNlxz tlz39ISfEB4ER4kFMD2koozfvL7E72dPEr17zsYnxjiNeu99WH4ZBOjKhaGrCLfm oExA== 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=1743033584; x=1743119984; bh=0IPbQwHlpM1miJ6dfEePoY2bkga4 RmIx2z3l5vx4LA8=; b=ehZmWx18jT3qRXyxAjw3HIvG/OHZkxwMHS2+FV4VmMl5 bH8G44n4cMZ6ubRTFrXIcechZpG6FUDDqmBGuC574rgzde1WnCw8dUCiuzQCAMSS YfiPcR+F7F3JiMiXy4iuDD3kWfvRT0JyGACtdk75IhVjjU0I3EpKCMN13DAAQCFT SoTyaFZ/25IexR3qBrX8TJ7Umggeq1SLiy0RSegUg0E4wPNp+AIcHkMyYGnqj4ra TEJBoTPisp4mDvRdaJ5ff74qDHxvW1ZGnV/5C7Be+xsfXA0bnJAhMPxHxxM9nk1/ M9C0ry8ei0WV35X44TFq+62QV/YQ9YjIyCaKSqOEww== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieeileduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvf evufffkffogggtgfesthekredtredtjeenucfhrhhomhepkfgrnhcugfhurhgvuceoihgr nhesrhgvthhrohhsphgvtgdrthhvqeenucggtffrrghtthgvrhhnpefgueekffejudfgvd evteelteeitdeuuddufffhuefhiefhjeetuefhgfettedvteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehirghnsehrvghtrhhoshhpvggtrd htvhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep jeejvdeiieesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehirghnsehrvg htrhhoshhpvggtrdhtvh X-ME-Proxy: Feedback-ID: id9014242:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 26 Mar 2025 19:59:43 -0400 (EDT) From: Ian Eure Date: Wed, 26 Mar 2025 16:59:32 -0700 Message-ID: <20250326235933.27663-1-ian@retrospec.tv> X-Mailer: git-send-email 2.48.1 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 | 34 ++++++++++++++++++++++++++++++++-- gnu/services/xorg.scm | 33 +++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 730fb45798..1dedf81715 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 @@ -24865,8 +24866,37 @@ 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. + +Note that @code{set-xorg-configuration} can only be used once, and must +provide a complete configuration. If you know the service-type of the +log-in manager, you can compose a configuration from smaller pieces: + +@lisp +(define %xorg-intel-service + (simple-service + 'xorg-intel + gdm-service-type + (xorg-configuration + (modules (list xf86-video-intel)) + (drivers '("intel"))))) + +(define %xorg-keyboard-service + (simple-service + 'xorg-keyboard + gdm-service-type + (xorg-configuration (keyboard-layout keyboard-layouut)))) + +(operating-system + (services + (cons* + (service gdm-service-type) + %xorg-intel-service + %xorg-keyboard-service + %base-services)) + ...) +@end lisp @end deffn @deffn {Procedure} xorg-start-command [config] diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index bef05b9bb9..c2e34bc10c 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." @@ -628,10 +656,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