Subject: Re: [bug#77266] [PATCH v4 1/2] gnu: Merge xorg configurations when extending.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 12 May 2025 08:59:24 +0200

Hi Ian,

Ian Eure <[email-masked]> writes:

> 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

[...]

> +(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)))

As I mentioned before, since ‘equal?’ cannot be meaningfully applied
here on file-like objects in general, all these ‘delete-duplicates’
calls should be removed.

>  (define (xorg-configuration->file config)
>    "Compute an Xorg configuration file corresponding to CONFIG, an
>  <xorg-configuration> 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)))))))

As I wrote before, in ‘xorg-configuration->file’, ‘delete-duplicates’
should be used for drivers, modules, and fonts, but not for
‘extra-config’ (which is merely a string).

Could you update it accordingly?

Thanks,
Ludo’.