Subject: bug#67314: xorg-configuration's extra-config should support file-like objects

From: Ian Eure <[email-masked]>
Date: Mon, 20 Nov 2023 15:33:17 -0800

I needed to tweak some xorg settings (set scroll direction, enable
tearfree, etc).  On other distros, this is done by dropping files 
of
config snippets into /etc/xorg.conf.d.

On Guix, this needs to be done through the extra-config field of 
the
xorg-configuration record.  That field requires a list of strings, 
which
means the configurations need to be inlined into the config, which 
is
verbose and unsightly.

For example:

    (operating-system
      (services
       (append (list (service openssh-service-type)
                     (set-xorg-configuration
                      (xorg-configuration
                       (keyboard-layout keyboard-layout)
                       (extra-config
                        (list
                         "Section \"InputClass\"
                         Identifier \"Touchpads\"
                         MatchIsTouchpad \"on\"

                         Driver \"libinput\"

                         Option \"ClickMethod\" \"clickfinger\"
                         Option \"DisableWhileTyping\" \"on\"
                         Option \"NaturalScrolling\" \"on\"
                         Option \"Tapping\" \"off\"
                         EndSection"))))))))

The manual states that extra-config takes "a list of strings or
objects," but doesn’t indicate what type of object is expected. 
If I
pass a file-like object, like this:

    (operating-system
      (services
       (append (list (service openssh-service-type)
                     (set-xorg-configuration
                      (xorg-configuration
                       (keyboard-layout keyboard-layout)
                       (extra-config
                        (list (local-file 
                        "xorg/touchpads.conf")))))))))

The resulting Xorg configutation has the store paths for those 
files
added to it, instead of their contents.  This is an invalid
configuation, rendering Xorg unable to start.

I was able to split the difference by reading the file contents 
into the
config, ala:

    (set-xorg-configuration
     (xorg-configuration
      (keyboard-layout keyboard-layout)
      (extra-config
       (map (lambda (file)
              (call-with-port (open-file (string-append "xorg/" 
              file ".conf") "r") get-string-all))
            '("radeon" "elecom-huge" "trackpad")))))

But this feels like a graceless hack to me.

The situation would be drastically simplified if extra-config 
supported
file-like objects.