unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#61458] [PATCH] services: xorg-wrapper: Support xorg server input
@ 2023-02-12 18:52 Roman Scherer
  2023-03-07  1:30 ` 宋文武 via Guix-patches via
  2023-03-21 19:11 ` [bug#61458] [PATCH v2 0/1] Support xorg server input rewriting Roman Scherer
  0 siblings, 2 replies; 7+ messages in thread
From: Roman Scherer @ 2023-02-12 18:52 UTC (permalink / raw)
  To: 61458


[-- Attachment #1.1: Type: text/plain, Size: 1110 bytes --]


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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-services-xorg-wrapper-Support-xorg-server-input-tran.patch --]
[-- Type: text/x-patch, Size: 2563 bytes --]

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

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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#61458] [PATCH] services: xorg-wrapper: Support xorg server input
  2023-02-12 18:52 [bug#61458] [PATCH] services: xorg-wrapper: Support xorg server input Roman Scherer
@ 2023-03-07  1:30 ` 宋文武 via Guix-patches via
  2023-03-10 15:32   ` Roman Scherer
  2023-03-21 19:11 ` [bug#61458] [PATCH v2 0/1] Support xorg server input rewriting Roman Scherer
  1 sibling, 1 reply; 7+ messages in thread
From: 宋文武 via Guix-patches via @ 2023-03-07  1:30 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 61458

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!




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#61458] [PATCH] services: xorg-wrapper: Support xorg server input
  2023-03-07  1:30 ` 宋文武 via Guix-patches via
@ 2023-03-10 15:32   ` Roman Scherer
  0 siblings, 0 replies; 7+ messages in thread
From: Roman Scherer @ 2023-03-10 15:32 UTC (permalink / raw)
  To: 宋文武; +Cc: 61458

[-- Attachment #1: Type: text/plain, Size: 2795 bytes --]


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:

> 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!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#61458] [PATCH v2 0/1] Support xorg server input rewriting
  2023-02-12 18:52 [bug#61458] [PATCH] services: xorg-wrapper: Support xorg server input Roman Scherer
  2023-03-07  1:30 ` 宋文武 via Guix-patches via
@ 2023-03-21 19:11 ` Roman Scherer
  2023-03-21 19:11   ` [bug#61458] [PATCH v2 1/1] services: xorg-wrapper: " Roman Scherer
  2023-03-25  2:11   ` bug#61458: [PATCH] services: xorg-wrapper: Support xorg server input 宋文武 via Guix-patches via
  1 sibling, 2 replies; 7+ messages in thread
From: Roman Scherer @ 2023-03-21 19:11 UTC (permalink / raw)
  To: 61458; +Cc: Roman Scherer, iyzsong

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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#61458] [PATCH v2 1/1] services: xorg-wrapper: Support xorg server input rewriting.
  2023-03-21 19:11 ` [bug#61458] [PATCH v2 0/1] Support xorg server input rewriting Roman Scherer
@ 2023-03-21 19:11   ` Roman Scherer
  2023-03-25  2:11   ` bug#61458: [PATCH] services: xorg-wrapper: Support xorg server input 宋文武 via Guix-patches via
  1 sibling, 0 replies; 7+ messages in thread
From: Roman Scherer @ 2023-03-21 19:11 UTC (permalink / raw)
  To: 61458; +Cc: r0man, iyzsong

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

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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#61458: [PATCH] services: xorg-wrapper: Support xorg server input
  2023-03-21 19:11 ` [bug#61458] [PATCH v2 0/1] Support xorg server input rewriting Roman Scherer
  2023-03-21 19:11   ` [bug#61458] [PATCH v2 1/1] services: xorg-wrapper: " Roman Scherer
@ 2023-03-25  2:11   ` 宋文武 via Guix-patches via
  2023-03-25  7:56     ` [bug#61458] " Roman Scherer
  1 sibling, 1 reply; 7+ messages in thread
From: 宋文武 via Guix-patches via @ 2023-03-25  2:11 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 61458-done

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!




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#61458] [PATCH] services: xorg-wrapper: Support xorg server input
  2023-03-25  2:11   ` bug#61458: [PATCH] services: xorg-wrapper: Support xorg server input 宋文武 via Guix-patches via
@ 2023-03-25  7:56     ` Roman Scherer
  0 siblings, 0 replies; 7+ messages in thread
From: Roman Scherer @ 2023-03-25  7:56 UTC (permalink / raw)
  To: 宋文武; +Cc: 61458-done

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]


Thank you 宋文武!

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

> 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!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-25 13:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-12 18:52 [bug#61458] [PATCH] services: xorg-wrapper: Support xorg server input Roman Scherer
2023-03-07  1:30 ` 宋文武 via Guix-patches via
2023-03-10 15:32   ` Roman Scherer
2023-03-21 19:11 ` [bug#61458] [PATCH v2 0/1] Support xorg server input rewriting Roman Scherer
2023-03-21 19:11   ` [bug#61458] [PATCH v2 1/1] services: xorg-wrapper: " Roman Scherer
2023-03-25  2:11   ` bug#61458: [PATCH] services: xorg-wrapper: Support xorg server input 宋文武 via Guix-patches via
2023-03-25  7:56     ` [bug#61458] " Roman Scherer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).