Subject: [bug#33753] [PATCH 1/3] gnu: Add stumpwm modules.

From: Nam Nguyen <[email-masked]>
Date: Mon, 24 Dec 2018 01:21:23 -0800

* gnu/packages/lisp.scm (stumpwm-contrib, stumpwm-module)
  (stumpwm-cpu, stumpwm-mem, stumpwm-hostname, stumpwm-battery-portable)
  (stumpwm-winner-mode, stumpwm-swm-gaps)
  (stumpwm-pinentry): New variables.
---
 gnu/packages/lisp.scm | 111 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 261e720e2..711c57cbc 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Alex Vong <[email-masked]>
 ;;; Copyright © 2018 Pierre Neidhardt <[email-masked]>
 ;;; Copyright © 2018 Pierre Langlois <[email-masked]>
+;;; Copyright © 2018 Nam Nguyen <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1032,6 +1033,116 @@ productive, customizable lisp based systems.")
     (inherit (sbcl-package->cl-source-package stumpwm))
     (name "cl-stumpwm")))
 
+(define stumpwm-contrib
+  (let ((commit "bd47cec14f7299711ac29468d2e1364d38a81bee")
+        (revision "1"))
+    (package
+      (name "stumpwm-contrib")
+      (version (git-version "0.0.1" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/stumpwm/stumpwm-contrib.git")
+               (commit commit)))
+         (file-name (string-append name "-" version "-checkout"))
+         (sha256
+          (base32
+           "0kh9vpmxssjvxgvl6ihpn0qh4l660n64iq80ivhagdvr8s045ddj"))))
+      (inputs
+       `(("stumpwm" ,stumpwm "lib")))
+      (build-system asdf-build-system/sbcl)
+      (arguments
+       '(#:tests? #f ; No tests exist.
+         #:phases
+         (modify-phases %standard-phases
+           ;; Delete all sources.
+           (add-after 'check 'delete-modules
+             (lambda* (#:key outputs #:allow-other-keys)
+               (delete-file-recursively
+                (string-append (assoc-ref outputs "out")
+                               "/share/common-lisp/sbcl-source"))
+               #t)))))
+      (home-page "https://github.com/stumpwm/stumpwm-contrib")
+      (synopsis "Collection of StumpWM modules")
+      (description "Modules are a way to extend StumpWM using Lisp
+code.")
+      (license (list license:gpl2+      ; TODO: swm-gaps Missing license?
+                     license:gpl3+      ; cpu, mem, battery-portable,
+                                        ; winner-mode, pinentry
+                     license:bsd-2))))) ; hostname
+
+(define* (stumpwm-module mod cat syn desc)
+  (package (inherit stumpwm-contrib)
+    (name (string-append "stumpwm-" mod))
+    (arguments
+     (substitute-keyword-arguments (package-arguments stumpwm-contrib)
+       ((#:asd-file _ "") (string-append cat "/" mod "/" mod ".asd"))
+       ((#:asd-system-name _ #f) mod)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           ;; Keep module's sources.
+           (add-before 'delete-modules 'copy-module-sources
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (clisp (string-append out "/share/common-lisp"))
+                      (source (string-append clisp "/sbcl-source/"
+                                             ,mod "/" ,cat "/" ,mod))
+                      (dest (string-append clisp "/stumpwm-contrib/"
+                                           ,mod)))
+                 (mkdir-p dest)
+                 (copy-recursively source dest))
+               #t))))))
+    (synopsis syn)
+    (description desc)))
+
+(define-public stumpwm-cpu
+  (stumpwm-module "cpu" "modeline"
+                  "Display CPU info"
+                  "Display CPU info in the StumpWM modeline."))
+
+(define-public stumpwm-mem
+  (stumpwm-module "mem" "modeline"
+                  "Display memory info"
+                  "Display memory info in the StumpWM modeline."))
+
+(define-public stumpwm-hostname
+  (stumpwm-module "hostname" "modeline"
+                  "Display hostname"
+                  "Display hostname in the StumpWM modeline."))
+
+(define-public stumpwm-battery-portable
+  (stumpwm-module "battery-portable" "modeline"
+                  "Display laptop battery info"
+                  "Display laptop battery info in the StumpWM
+modeline."))
+
+(define-public stumpwm-winner-mode
+  (stumpwm-module "winner-mode" "util"
+                  "Emacs' winner-mode for StumpWM"
+                  "Winner mode records changes in the window
+configuration so that changes can be undone.  It hooks into StumpWM to
+dump layouts.  This only works per group."))
+
+(define-public stumpwm-swm-gaps
+  (stumpwm-module "swm-gaps" "util"
+                  "Pretty (useless) gaps for StumpWM"
+                  "Add gaps to StumpWM running along various borders."))
+
+(define-public stumpwm-pinentry
+  (let ((pinentry (stumpwm-module "pinentry" "util"
+                                  "Integrate GnuPG Agent with StumpWM"
+                                  "GnuPG Agent uses
+@code{stumpwm-pinentry} to ask for your password.")))
+    (package (inherit pinentry)
+      (inputs
+       `(("sbcl-cffi" ,sbcl-cffi)
+         ("sbcl-usocket-server" ,sbcl-usocket-server)
+         ("sbcl-percent-encoding" ,sbcl-percent-encoding)
+         ,@(package-inputs stumpwm-contrib)))
+      (propagated-inputs
+       `(("netcat" ,netcat))))))
+
 ;; The slynk that users expect to install includes all of slynk's contrib
 ;; modules.  Therefore, we build the base module and all contribs first; then
 ;; we expose the union of these as `sbcl-slynk'.  The following variable
-- 
2.20.1