summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorIan Eure <ian@retrospec.tv>2025-03-25 15:17:03 -0700
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2025-12-26 13:15:41 +0100
commita9462997d743e4cb4edd557d7ffeeb98048bb4de (patch)
treedb25b0bfd34b27c27711862c948cca9e8796825a /gnu/services
parent5ef86f97e23bb6bc1bb16ece959a597b306916b3 (diff)
gnu: Merge xorg configurations when extending.
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. Change-Id: I20e9db911eef5d4efe98fdf382f3084e4defc1ba Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/xorg.scm56
1 files changed, 44 insertions, 12 deletions
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index 25f44566beb..313023f38a0 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -16,6 +16,7 @@
16;;; Copyright © 2023 muradm <mail@muradm.net> 16;;; Copyright © 2023 muradm <mail@muradm.net>
17;;; Copyright © 2024 Zheng Junjie <873216071@qq.com> 17;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
18;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz> 18;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz>
19;;; Copyright © 2025 Ian Eure <ian@retrospec.tv>
19;;; 20;;;
20;;; This file is part of GNU Guix. 21;;; This file is part of GNU Guix.
21;;; 22;;;
@@ -43,6 +44,7 @@
43 #:use-module (gnu system privilege) 44 #:use-module (gnu system privilege)
44 #:use-module (gnu services base) 45 #:use-module (gnu services base)
45 #:use-module (gnu services dbus) 46 #:use-module (gnu services dbus)
47 #:use-module (gnu services desktop)
46 #:use-module (gnu packages base) 48 #:use-module (gnu packages base)
47 #:use-module (gnu packages guile) 49 #:use-module (gnu packages guile)
48 #:use-module (gnu packages xorg) 50 #:use-module (gnu packages xorg)
@@ -194,6 +196,8 @@ the first one in the list is loaded."
194 ;; Default command-line arguments for X. 196 ;; Default command-line arguments for X.
195 '("-nolisten" "tcp")) 197 '("-nolisten" "tcp"))
196 198
199(define %default-xorg-server xorg-server)
200
197;; Configuration of an Xorg server. 201;; Configuration of an Xorg server.
198(define-record-type* <xorg-configuration> 202(define-record-type* <xorg-configuration>
199 xorg-configuration make-xorg-configuration 203 xorg-configuration make-xorg-configuration
@@ -217,10 +221,42 @@ the first one in the list is loaded."
217 (extra-config xorg-configuration-extra-config ;list of strings 221 (extra-config xorg-configuration-extra-config ;list of strings
218 (default '())) 222 (default '()))
219 (server xorg-configuration-server ;file-like 223 (server xorg-configuration-server ;file-like
220 (default xorg-server)) 224 (default %default-xorg-server))
221 (server-arguments xorg-configuration-server-arguments ;list of strings 225 (server-arguments xorg-configuration-server-arguments ;list of strings
222 (default %default-xorg-server-arguments))) 226 (default %default-xorg-server-arguments)))
223 227
228(define (merge-xorg-configurations configs)
229 ;; Find whichever config has a non-default Xorg server.
230 (let ((config-with-server
231 (or
232 (find
233 (lambda (config)
234 (or (not (eq? %default-xorg-server
235 (xorg-configuration-server config)))
236 (not (eq? %default-xorg-server-arguments
237 (xorg-configuration-server-arguments config)))))
238 (reverse configs))
239 (xorg-configuration))))
240
241 (xorg-configuration
242 (modules
243 (delete-duplicates (append-map xorg-configuration-modules configs)))
244 (fonts
245 (delete-duplicates (append-map xorg-configuration-fonts configs)))
246 (drivers
247 (delete-duplicates (append-map xorg-configuration-drivers configs)))
248 (resolutions
249 (delete-duplicates (append-map xorg-configuration-resolutions configs)))
250 (extra-config
251 (append-map xorg-configuration-extra-config configs))
252 (keyboard-layout
253 (any xorg-configuration-keyboard-layout (reverse configs)))
254 ;; Use the later config with non-default server for both these fields.
255 (server
256 (xorg-configuration-server config-with-server))
257 (server-arguments
258 (xorg-configuration-server-arguments config-with-server)))))
259
224(define (xorg-configuration->file config) 260(define (xorg-configuration->file config)
225 "Compute an Xorg configuration file corresponding to CONFIG, an 261 "Compute an Xorg configuration file corresponding to CONFIG, an
226<xorg-configuration> record." 262<xorg-configuration> record."
@@ -347,7 +383,7 @@ EndSection\n" port)
347 (newline port))) 383 (newline port)))
348 384
349 (for-each (lambda (config) 385 (for-each (lambda (config)
350 (display config port)) 386 (display (string-append config "\n\n") port))
351 '#$(xorg-configuration-extra-config config)))))) 387 '#$(xorg-configuration-extra-config config))))))
352 388
353 (computed-file "xserver.conf" build))) 389 (computed-file "xserver.conf" build)))
@@ -644,16 +680,12 @@ a `service-extension', as used by `set-xorg-configuration'."
644 ((_ configuration-record service-type-definition) 680 ((_ configuration-record service-type-definition)
645 (service-type 681 (service-type
646 (inherit service-type-definition) 682 (inherit service-type-definition)
647 (compose (lambda (extensions) 683 (compose cons*)
648 (match extensions 684 (extend (lambda (config xorg-configurations)
649 (() #f) 685 (configuration-record
650 ((config . _) config)))) 686 (inherit config)
651 (extend (lambda (config xorg-configuration) 687 (xorg-configuration
652 (if xorg-configuration 688 (merge-xorg-configurations xorg-configurations)))))))))
653 (configuration-record
654 (inherit config)
655 (xorg-configuration xorg-configuration))
656 config)))))))
657 689
658(define (xorg-server-profile-service config) 690(define (xorg-server-profile-service config)
659 ;; XXX: profile-service-type only accepts <package> objects. 691 ;; XXX: profile-service-type only accepts <package> objects.