~abcdw/rde-devel

gnu: home-services: wm: Add XMonad service. v1 APPLIED

Xinglu Chen: 1
 gnu: home-services: wm: Add XMonad service.

 1 files changed, 75 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~abcdw/rde-devel/patches/22967/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] gnu: home-services: wm: Add XMonad service. Export this patch

* wm.scm (home-xmonad-configuration): New record type
(xmonad-profile-service, xmonad-files-service,
xmonad-environment-variables-service,
generate-home-xmonad-documentation): New procedures.
(home-xmonad-service-type): New service type
---
 gnu/home-services/wm.scm | 76 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/gnu/home-services/wm.scm b/gnu/home-services/wm.scm
index 26b74f0..a61958c 100644
--- a/gnu/home-services/wm.scm
+++ b/gnu/home-services/wm.scm
@@ -14,7 +14,10 @@
  #:use-module (ice-9 match)

  #:export (home-sway-service-type
	    home-sway-configuration))
	    home-sway-configuration

            home-xmonad-service-type
            home-xmonad-configuration))

;;; Commentary:
;;;
@@ -173,3 +176,74 @@ Install and configure Sway, a Wayland compositor compatible with i3.")))
   `((home-sway-configuration
      ,home-sway-configuration-fields))
   'home-sway-configuration))



;;;
;;; XMonad.
;;;

(define-configuration/no-serialization home-xmonad-configuration
  (package
    (package xmonad)
    "The XMonad package to use.")
  (xmonad-contrib?
   (boolean #f)
   "Whether to install the @code{ghc-xmonad-contrib} package, which
contains many third-party extensions for XMonad.")
  (xdg-flavor?
   (boolean #t)
   "Whether to respect XDG base directory, this will set the relevant
environment variables if enabled.")
  (config
   (text-config '())
   "List of strings or gexps containing the XMonad configuration, see
the @uref{https://xmonad.org/documentation.html, official XMonad
documentation} for how to configure it."))

(define xmonad-profile-service
  (match-lambda
    (($ <home-xmonad-configuration> _ package xmonad-contrib?)
     (if xmonad-contrib?
         (list package ghc-xmonad-contrib)
         (list package)))))

(define xmonad-files-service
  (match-lambda
    (($ <home-xmonad-configuration> _ package xmonad-contrib?
                                    xdg-flavor? config)
     (if (eq? config 'disabled)
         '()
         `((,(string-append (if xdg-flavor? "config/" "") "xmonad/xmonad.hs")
            ,(mixed-text-file "xmonad-config"
                              (serialize-text-config #f config))))))))

(define xmonad-environment-variables-service
  (match-lambda
    (($ <home-xmonad-configuration> _ package xmonad-contrib?
                                    xdg-flavor? config)
     (optional xdg-flavor?
               '(("XMONAD_CONFIG_DIR" . "$XDG_CONFIG_HOME/xmonad")
                 ("XMONAD_DATA_DIR" . "$XDG_DATA_HOME/xmonad")
                 ("XMONAD_CACHE_DIR" . "$XDG_CACHE_HOME/xmonad"))))))

(define home-xmonad-service-type
  (service-type (name 'home-xmonad)
                (extensions
                 ;; TODO: Extend `on-change' service.
                 (list (service-extension
                        home-profile-service-type
                        xmonad-profile-service)
                       (service-extension
                        home-files-service-type
                        xmonad-files-service)
                       (service-extension
                        home-environment-variables-service-type
                        xmonad-environment-variables-service)))
                (description "\
Install and configure XMonad, a window manager written in Haskell.")))

(define (generate-home-xmonad-documentation)
  (generate-documentation
   `((home-xmonad-configuration
      ,home-xmonad-configuration-fields))
   'home-xmonad-configuration))

base-commit: ad070db2339873b7bcae11d5b565a518ece27a46
-- 
2.31.1
Seems Xmonad already supports XDG base directories, no need to set
environment variables.

https://github.com/xmonad/xmonad/blob/master/src/XMonad/Core.hs#L502

I didn't test those changes, but the code looks good to me.  Applied.
Thank you for the patch)