Subject: [PATCH 3/3] gnu: Add mahogany

From: Karl Hallsby <[email-masked]>
Date: Thu, 19 Oct 2023 00:06:03 -0500

* gnu/packages/wm.scm (New variable): Add mahogany window manager.
---
 gnu/packages/wm.scm | 71 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/gnu/packages/wm.scm b/gnu/packages/wm.scm
index 8576d0297d..86276165e3 100644
--- a/gnu/packages/wm.scm
+++ b/gnu/packages/wm.scm
@@ -64,6 +64,7 @@
 ;;; Copyright © 2023 Jonathan Brielamier <[email-masked]>
 ;;; Copyright © 2023 Vessel Wave <[email-masked]>
 ;;; Copyright © 2023 Nicolas Graves <[email-masked]>
+;;; Copyright © 2023 Raven Hallsby <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2614,6 +2615,76 @@ (define-public sbcl-stumpwm-battery-portable
 modeline.  It can be displayed in the modeline with %B.")
     (license (list license:expat license:gpl3+))))
 
+(define-public mahogany
+  (let ((commit "ca4472bdb284b4f70bb7365fbaa421f6c2d382d1")
+        (revision "0"))
+  (package
+    (name "mahogany")
+    (version (git-version "0.0.0" revision commit))
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/stumpwm/mahogany")
+             (commit commit)))
+       (file-name (git-file-name "mahogany" version))
+       (sha256
+        (base32 "1bnnw5p0wp1lm7jvf66mlgiaxbxxxnd54nhxd2794ajlgmdfps3h"))))
+    (build-system asdf-build-system/sbcl)
+    (native-inputs
+     (list sbcl-fiasco
+           sbcl-prove))
+    (inputs
+     (list libxkbcommon
+           sbcl-xkbcommon
+           sbcl-wayland
+           sbcl-alexandria
+           sbcl-cl-ansi-text
+           sbcl-terminfo
+           sbcl-snakes
+           sbcl-iterate
+           sbcl-cffi ;; Provides cffi-grovel
+           sbcl-closer-mop
+           sbcl-cl-ppcre
+           sbcl-clx
+           wayland
+           wayland-protocols))
+    (outputs '("out" "lib"))
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'create-asdf-configuration 'build-program
+            (lambda* (#:key outputs #:allow-other-keys)
+              (build-program
+               (string-append (assoc-ref outputs "out") "/bin/mahogany")
+               outputs
+               #:entry-program '((mahogany::run-server) 0))))
+          (add-after 'build-program 'create-desktop-file
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (xsessions (string-append out "/share/xsessions")))
+                (mkdir-p xsessions)
+                (call-with-output-file
+                    (string-append xsessions "/mahogany.desktop")
+                  (lambda (file)
+                    (format file
+                       "[Desktop Entry]~@
+                        Name=stumpwm~@
+                        Comment=The Mahogany Window Manager~@
+                        Exec=~a/bin/mahogany~@
+                        TryExec=~@*~a/bin/mahogany~@
+                        Icon=~@
+                        Type=Application~%"
+                       out)))))))))
+    (synopsis "Window manager for Wayland written in Common Lisp")
+    (description
+     "Mahogany is a tiling window manager for Wayland modeled after StumpWM.
+While it is not a drop-in replacement for stumpwm, stumpwm users should be
+very comfortable with Mahogany.")
+    (home-page "https://github.com/stumpwm/mahogany")
+    (license license:gpl2+))))
+
 (define-public lemonbar
   (package
     (name "lemonbar")
-- 
2.41.0