[PATCH] services: xorg-wrapper: Support xorg server input

  • Done
  • quality assurance status badge
Details
4 participants
  • 宋文武
  • Ludovic Courtès
  • Roman Scherer
  • Roman Scherer
Owner
unassigned
Submitted by
Roman Scherer
Severity
normal

Debbugs page

R
R
Roman Scherer wrote on 12 Feb 2023 10:52
(name . Guix Patches)(address . guix-patches@gnu.org)
86k00mvgmi.fsf@burningswell.com
Hello Guix,

I would like to replace the Mesa package in my Xorg configuration. I
tried to do this with the following snippet:

```
(modify-services %desktop-services
(slim-service-type config =>
(slim-configuration
(inherit config)
(xorg-configuration
(xorg-configuration
(server (replace-mesa xorg-server)))))))
```

But this unfortunately does not work, because the xorg-wrapper uses
static paths for the mesa, xkbcomp and xkeyboard-config packages in the
derivation.

The xserver starts now with the replaced mesa, but some paths still
point to the hard coded packages in Guix itself (and not the
replacement), which cause some things to not work.

This patch changes this to lookup the paths from the inputs of the
server field of the xorg-configuration instead. That way the correct
paths are setup in the xor-wrapper script. If those inputs are not found
for some reason it falls back to the current behavior, using the
packages from Guix.

Could you please review this?

Thanks, Roman.
From d035c99ed4703da0e3e9b62299c390560c074a17 Mon Sep 17 00:00:00 2001
From: r0man <roman@burningswell.com>
Date: Sat, 11 Feb 2023 19:36:16 +0100
Subject: [PATCH] services: xorg-wrapper: Support xorg server input
transformations.

* gnu/services/xorg.scm (xorg-wrapper): Support xorg server input transformations.
---
gnu/services/xorg.scm | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

Toggle diff (45 lines)
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index 5f073d05d3..92735e6004 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -355,6 +355,21 @@ (define files
files)
#t))))
+(define (xorg-configuration-append-input config input default-input path)
+ (let ((server (xorg-configuration-server config)))
+ (file-append (or (lookup-package-direct-input server input) default-input)
+ path)))
+
+(define (xorg-configuration-dri-driver-path config)
+ (xorg-configuration-append-input config "mesa" mesa "/lib/dri"))
+
+(define (xorg-configuration-xkb-bin-dir config)
+ (xorg-configuration-append-input config "xkbcomp" xkbcomp "/bin"))
+
+(define (xorg-configuration-xkb-dir config)
+ (xorg-configuration-append-input config "xkeyboard-config"
+ xkeyboard-config "/share/X11/xkb"))
+
(define* (xorg-wrapper #:optional (config (xorg-configuration)))
"Return a derivation that builds a script to start the X server with the
given @var{config}. The resulting script should be used in place of
@@ -362,12 +377,13 @@ (define* (xorg-wrapper #:optional (config (xorg-configuration)))
(define exp
;; Write a small wrapper around the X server.
#~(begin
- (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
- (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
+ (setenv "XORG_DRI_DRIVER_PATH"
+ #$(xorg-configuration-dri-driver-path config))
+ (setenv "XKB_BINDIR" #$(xorg-configuration-xkb-bin-dir config))
(let ((X (string-append #$(xorg-configuration-server config) "/bin/X")))
(apply execl X X
- "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
+ "-xkbdir" #$(xorg-configuration-xkb-dir config)
"-config" #$(xorg-configuration->file config)
"-configdir" #$(xorg-configuration-directory
(xorg-configuration-modules config))
--
2.38.1
-----BEGIN PGP SIGNATURE-----

iQFTBAEBCAA9FiEE0iajOdjfRIFd3gygPdpSUn0qwZkFAmPpOxUfHHJvbWFuLnNj
aGVyZXJAYnVybmluZ3N3ZWxsLmNvbQAKCRA92lJSfSrBmbUaB/9OdqZsRIF7ndO/
M/S0Xjglb4clxdKAwIPr42FLq2AFm8hAZbUNfWyNyEdG8JcIxOdhcmangDlyv9n7
CHFJuZBheVxHPQiJnm8/jOFmosnVtH9rtUE0p1iZ1ZJ+O7SMhF3dFZ/Dtr4y9Ssm
ow+EIWp5/afeHFA9iLRfy6qcQ7I29A8N9f+bJs7NTDy6t0ThI0abTfTP1HPrtZkj
PuZ4kCw7cyIaPu+Uu8xPWkpsfV24ZiE9sh9iZ336gQZrOEb9oVJ7lRCKladefw9W
S/DJ5xNXOngU1PYrMPTbZ9r+/jxK5f8vuYqLLOr+cQoyuIcJtp97fjKraXjs/VBG
lVcF8NlU
=ppDt
-----END PGP SIGNATURE-----

宋
宋文武 wrote on 6 Mar 2023 17:30
(name . Roman Scherer)(address . roman.scherer@burningswell.com)(address . 61458@debbugs.gnu.org)
871qm1nyau.fsf@envs.net
Roman Scherer <roman.scherer@burningswell.com> writes:

Toggle quote (33 lines)
> Hello Guix,
>
> I would like to replace the Mesa package in my Xorg configuration. I
> tried to do this with the following snippet:
>
> ```
> (modify-services %desktop-services
> (slim-service-type config =>
> (slim-configuration
> (inherit config)
> (xorg-configuration
> (xorg-configuration
> (server (replace-mesa xorg-server)))))))
> ```
>
> But this unfortunately does not work, because the xorg-wrapper uses
> static paths for the mesa, xkbcomp and xkeyboard-config packages in the
> derivation.
>
> The xserver starts now with the replaced mesa, but some paths still
> point to the hard coded packages in Guix itself (and not the
> replacement), which cause some things to not work.
>
> This patch changes this to lookup the paths from the inputs of the
> server field of the xorg-configuration instead. That way the correct
> paths are setup in the xor-wrapper script. If those inputs are not found
> for some reason it falls back to the current behavior, using the
> packages from Guix.
>
> Could you please review this?
>
> Thanks, Roman.

Sorry for a long deley..
Toggle quote (7 lines)
>
> From d035c99ed4703da0e3e9b62299c390560c074a17 Mon Sep 17 00:00:00 2001
> From: r0man <roman@burningswell.com>
> Date: Sat, 11 Feb 2023 19:36:16 +0100
> Subject: [PATCH] services: xorg-wrapper: Support xorg server input
> transformations.

I think it's better add some explaination to commit message like:
The xorg-wrapper uses [...]
This patch [...]

Should be good.
Toggle quote (18 lines)
>
> * gnu/services/xorg.scm (xorg-wrapper): Support xorg server input transformations.
> ---
> gnu/services/xorg.scm | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
> index 5f073d05d3..92735e6004 100644
> --- a/gnu/services/xorg.scm
> +++ b/gnu/services/xorg.scm
> @@ -355,6 +355,21 @@ (define files
> files)
> #t))))
>
> +(define (xorg-configuration-append-input config input default-input path)
> + (let ((server (xorg-configuration-server config)))
> + (file-append (or (lookup-package-direct-input server input) default-input)
> + path)))
I'm not sure about the procedure name, maybe add a docstring explain
it's function?


Otherwise, look good to me, thank you!
R
R
Roman Scherer wrote on 10 Mar 2023 07:32
(name . 宋文武)(address . iyzsong@envs.net)(address . 61458@debbugs.gnu.org)
86o7p039kj.fsf@burningswell.com
Hi 宋文武,

thanks for taking a look. I messed up my system, but will update the
patch once I got everyting working again.

Roman

宋文武 <iyzsong@envs.net> writes:

Toggle quote (71 lines)
> Roman Scherer <roman.scherer@burningswell.com> writes:
>
>> Hello Guix,
>>
>> I would like to replace the Mesa package in my Xorg configuration. I
>> tried to do this with the following snippet:
>>
>> ```
>> (modify-services %desktop-services
>> (slim-service-type config =>
>> (slim-configuration
>> (inherit config)
>> (xorg-configuration
>> (xorg-configuration
>> (server (replace-mesa xorg-server)))))))
>> ```
>>
>> But this unfortunately does not work, because the xorg-wrapper uses
>> static paths for the mesa, xkbcomp and xkeyboard-config packages in the
>> derivation.
>>
>> The xserver starts now with the replaced mesa, but some paths still
>> point to the hard coded packages in Guix itself (and not the
>> replacement), which cause some things to not work.
>>
>> This patch changes this to lookup the paths from the inputs of the
>> server field of the xorg-configuration instead. That way the correct
>> paths are setup in the xor-wrapper script. If those inputs are not found
>> for some reason it falls back to the current behavior, using the
>> packages from Guix.
>>
>> Could you please review this?
>>
>> Thanks, Roman.
>
> Sorry for a long deley..
>>
>> From d035c99ed4703da0e3e9b62299c390560c074a17 Mon Sep 17 00:00:00 2001
>> From: r0man <roman@burningswell.com>
>> Date: Sat, 11 Feb 2023 19:36:16 +0100
>> Subject: [PATCH] services: xorg-wrapper: Support xorg server input
>> transformations.
>
> I think it's better add some explaination to commit message like:
> The xorg-wrapper uses [...]
> This patch [...]
>
> Should be good.
>>
>> * gnu/services/xorg.scm (xorg-wrapper): Support xorg server input transformations.
>> ---
>> gnu/services/xorg.scm | 22 +++++++++++++++++++---
>> 1 file changed, 19 insertions(+), 3 deletions(-)
>>
>> diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
>> index 5f073d05d3..92735e6004 100644
>> --- a/gnu/services/xorg.scm
>> +++ b/gnu/services/xorg.scm
>> @@ -355,6 +355,21 @@ (define files
>> files)
>> #t))))
>>
>> +(define (xorg-configuration-append-input config input default-input path)
>> + (let ((server (xorg-configuration-server config)))
>> + (file-append (or (lookup-package-direct-input server input) default-input)
>> + path)))
> I'm not sure about the procedure name, maybe add a docstring explain
> it's function?
>
>
> Otherwise, look good to me, thank you!
-----BEGIN PGP SIGNATURE-----

iQFTBAEBCAA9FiEE0iajOdjfRIFd3gygPdpSUn0qwZkFAmQLTcwfHHJvbWFuLnNj
aGVyZXJAYnVybmluZ3N3ZWxsLmNvbQAKCRA92lJSfSrBmcpaB/94+vinsbcxYfj1
6hAhCdyIOr5ngPdHlJiPpRYSYqbfEK0Mq8WJTGljE0TXKsrNXsamCzkgHxk2Q2sU
TUoEGYxeM8cryx12el+ISDNM0iuAcHMdRSxzO9+wF62dr5XJ0L2cJqbQxIkudt7+
ORljc5QP0x4CQ8dIXjd1syxG1n8UQJPVuxtErApwLUL5r1HsW8cSgPa4jxl+Xd7H
8I34/1NA2YQlAbFA1o85o2/Ed8i0Gpd5qGss7jlKxTmALLcXkfghX1sUDEVYXAAG
8YxCsua2kePxZ3pwM4dvp/lNYtmEADx9LxhWI6Vz5EhCCNMCHahUz3Q1v9HI/osu
ulqQABGN
=J74u
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 16 Mar 2023 04:05
control message for bug #61458
(address . control@debbugs.gnu.org)
877cvhgdmh.fsf@gnu.org
tags 61458 + moreinfo
quit
R
R
Roman Scherer wrote on 21 Mar 2023 12:11
[PATCH v2 0/1] Support xorg server input rewriting
(address . 61458@debbugs.gnu.org)
cover.1679425545.git.roman@burningswell.com
Hi 宋文武,

I'm back on track. Here's an improved version of the patch. It was indeed way
too complicated. :)

Can you have another look please?

Thanks, Roman.

r0man (1):
services: xorg-wrapper: Support xorg server input rewriting.

gnu/services/xorg.scm | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

--
2.39.1
R
R
Roman Scherer wrote on 21 Mar 2023 12:11
[PATCH v2 1/1] services: xorg-wrapper: Support xorg server input rewriting.
(address . 61458@debbugs.gnu.org)
af690c2b48f456fda57a00bb2622b571df15aec9.1679425545.git.roman@burningswell.com
From: r0man <roman@burningswell.com>

* gnu/services/xorg.scm (xorg-wrapper): Support xorg server input rewriting.

This patch adds support for proper xorg server input rewriting. It uses the
lookup-package-direct-input procedure to configure the X server paths
dynamically, instead of always using the hard coded package. Something like
this is now possible:

(define other-mesa
(package-input-rewriting/spec `(("mesa" . ,(const other-mesa)))))

(xorg-configuration
(xorg-configuration
(server (other-mesa xorg-server))))

Without this patch the X server would still be configured with mesa (causing
version issues), and not with other-mesa (as per the input rewrite).
---
gnu/services/xorg.scm | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

Toggle diff (46 lines)
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index c4745cecf5..7295a45b59 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -358,6 +358,22 @@ (define (xorg-configuration-directory modules)
files)
#t))))
+(define (xorg-configuration-server-package-path config input path)
+ "Lookup the direct @var{input} in the xorg server package of @var{config}
+and append @var{path} to it."
+ (let* ((server (xorg-configuration-server config))
+ (package (lookup-package-direct-input server input)))
+ (when package (file-append package path))))
+
+(define (xorg-configuration-dri-driver-path config)
+ (xorg-configuration-server-package-path config "mesa" "/lib/dri"))
+
+(define (xorg-configuration-xkb-bin-dir config)
+ (xorg-configuration-server-package-path config "xkbcomp" "/bin"))
+
+(define (xorg-configuration-xkb-dir config)
+ (xorg-configuration-server-package-path config "xkeyboard-config" "/share/X11/xkb"))
+
(define* (xorg-wrapper #:optional (config (xorg-configuration)))
"Return a derivation that builds a script to start the X server with the
given @var{config}. The resulting script should be used in place of
@@ -365,12 +381,13 @@ (define* (xorg-wrapper #:optional (config (xorg-configuration)))
(define exp
;; Write a small wrapper around the X server.
#~(begin
- (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
- (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
+ (setenv "XORG_DRI_DRIVER_PATH"
+ #$(xorg-configuration-dri-driver-path config))
+ (setenv "XKB_BINDIR" #$(xorg-configuration-xkb-bin-dir config))
(let ((X (string-append #$(xorg-configuration-server config) "/bin/X")))
(apply execl X X
- "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
+ "-xkbdir" #$(xorg-configuration-xkb-dir config)
"-config" #$(xorg-configuration->file config)
"-configdir" #$(xorg-configuration-directory
(xorg-configuration-modules config))
--
2.39.1
宋
宋文武 wrote on 24 Mar 2023 19:11
Re: bug#61458: [PATCH] services: xorg-wrapper: Support xorg server input
(name . Roman Scherer)(address . roman@burningswell.com)(address . 61458-done@debbugs.gnu.org)
871qldinrb.fsf_-_@envs.net
Roman Scherer <roman@burningswell.com> writes:

Toggle quote (2 lines)
> services: xorg-wrapper: Support xorg server input rewriting.

Pushed with some commit description added:

* gnu/services/xorg.scm (xorg-configuration-server-package-path)
(xorg-configuration-dri-driver-path, xorg-configuration-xkb-bin-dir)
(xorg-configuration-xkb-dir): New procedures.
(xorg-wrapper): Use them for dri and xkb paths.

Thank you!
Closed
R
R
Roman Scherer wrote on 25 Mar 2023 00:56
(name . 宋文武)(address . iyzsong@envs.net)(address . 61458-done@debbugs.gnu.org)
86y1nl462b.fsf@burningswell.com
Thank you 宋文武!

宋文武 <iyzsong@envs.net> writes:

Toggle quote (12 lines)
> Roman Scherer <roman@burningswell.com> writes:
>
>> services: xorg-wrapper: Support xorg server input rewriting.
>
> Pushed with some commit description added:
>
> * gnu/services/xorg.scm (xorg-configuration-server-package-path)
> (xorg-configuration-dri-driver-path, xorg-configuration-xkb-bin-dir)
> (xorg-configuration-xkb-dir): New procedures.
> (xorg-wrapper): Use them for dri and xkb paths.
>
> Thank you!
-----BEGIN PGP SIGNATURE-----

iQFTBAEBCAA9FiEE0iajOdjfRIFd3gygPdpSUn0qwZkFAmQeqU0fHHJvbWFuLnNj
aGVyZXJAYnVybmluZ3N3ZWxsLmNvbQAKCRA92lJSfSrBmTYnB/4uYoOa458kflIY
1eeI2Ht2Hs6hF3YGltS7a+3v1LiPq9MeX+OzRsBo9rIA3Z+Nas80gpP0+wU05R6c
g8mRyvxU2fvRyThN1/VsnpLHiWZ+H+M3nAwUfrYIjpiO6gGOwMCIaX87FyuaLz8d
5Qk8/vQ/KsrjMEZb8ghJGoPHN36sBvLjJpO7gV+RuFCJcOuH706KOUjUOHiPjgXt
W7L2qlBd3yKMDJkOqCf1ZbaLtgw7ba6rhHN5k9YApIsJi9aeRRA+/e8gC/fadkVn
26JViTtFyhz0KacXSMvoxYEvsIynUDSEmtWZoLljQix7ECgHIN9dw/vRenqLeVfv
mXC0eKRl
=sOT9
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 61458@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 61458
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch