when look at our xorg service, the first thing I want to do is remove
the hard-coded modules and fonts from the xserver.conf.
the attach show what I intend to do, but I don't know how to
feed `mixed-text-file` the desired arguments now.

for each module, a line of `ModulePath "$package/lib/xorg/modules/"`
(or more specified one like `lib/xorg/modules/drivers`?  I haven't test)
need to be added to the Files Section.  Since package is an object,
I can't use string-append to compose them as one argument to
mixed-text-file,  do I need a macro?

for fonts, it's more difficult (and on topic), because it does need to
know the actual contents (the directories contains fonts.dir).

see NixOS, it did the same thing by run shell commands on store items :-)
https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/x11/xserver.nix#L74-L105

How I can do it?
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index dc2625d..23a7642 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -54,7 +54,29 @@
 ;;;
 ;;; Code:
 
-(define* (xorg-configuration-file #:key (drivers '()) (resolutions '())
+(define %default-xorg-modules
+  (list xf86-video-vesa
+        xf86-video-fbdev
+        xf86-video-modesetting
+        xf86-video-cirrus
+        xf86-video-intel
+        xf86-video-mach64
+        xf86-video-nouveau
+        xf86-video-nv
+        xf86-video-sis
+        xf86-input-libinput
+        xf86-input-evdev
+        xf86-input-keyboard
+        xf86-input-mouse
+        xf86-input-synaptics))
+
+(define %default-xorg-fonts
+  (list font-alias
+        font-adobe75dpi))
+
+(define* (xorg-configuration-file #:key (modules %default-xorg-modules)
+                                  (fonts %default-xorg-fonts)
+                                  (drivers '()) (resolutions '())
                                   (extra-config '()))
   "Return a configuration file for the Xorg server containing search paths for
 all the common drivers.
@@ -92,6 +114,9 @@ Section \"Screen\"
   EndSubSection
 EndSection"))
 
+  (define (module-path module)
+    (list "  ModulePath \"" module "/lib/xorg/modules\"\n"))
+
   (apply mixed-text-file "xserver.conf" "
 Section \"Files\"
   FontPath \"" font-alias "/share/fonts/X11/75dpi\"
@@ -99,28 +124,7 @@ Section \"Files\"
   FontPath \"" font-alias "/share/fonts/X11/misc\"
   FontPath \"" font-alias "/share/fonts/X11/cyrillic\"
   FontPath \"" font-adobe75dpi "/share/fonts/X11/75dpi\"
-  ModulePath \"" xf86-video-vesa "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-fbdev "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-modesetting "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-cirrus "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-intel "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-mach64 "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-nouveau "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-nv "/lib/xorg/modules/drivers\"
-  ModulePath \"" xf86-video-sis "/lib/xorg/modules/drivers\"
-
-  # Libinput is the new thing and is recommended over evdev/synaptics
-  # by those who know:
-  # <http://who-t.blogspot.fr/2015/01/xf86-input-libinput-compatibility-with.html>.
-  ModulePath \"" xf86-input-libinput "/lib/xorg/modules/input\"
-
-  ModulePath \"" xf86-input-evdev "/lib/xorg/modules/input\"
-  ModulePath \"" xf86-input-keyboard "/lib/xorg/modules/input\"
-  ModulePath \"" xf86-input-mouse "/lib/xorg/modules/input\"
-  ModulePath \"" xf86-input-synaptics "/lib/xorg/modules/input\"
-  ModulePath \"" xorg-server "/lib/xorg/modules\"
-  ModulePath \"" xorg-server "/lib/xorg/modules/extensions\"
-  ModulePath \"" xorg-server "/lib/xorg/modules/multimedia\"
+" (apply string-append (map module-path modules)) "
 EndSection
 
 Section \"ServerFlags\"

Reply via email to