guile-wm.scm 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2016 Alex ter Weele <alex.ter.weele@gmail.com>
  4. ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
  5. ;;; Copyright © 2017 Nikita <nikita@n0.is>
  6. ;;; Copyright © 2019 Pierre-Moana Levesque <pierre.moana.levesque@gmail.com>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages guile-wm)
  23. #:use-module (guix licenses)
  24. #:use-module (gnu packages)
  25. #:use-module (gnu packages xorg)
  26. #:use-module (gnu packages guile)
  27. #:use-module (gnu packages pkg-config)
  28. #:use-module (gnu packages texinfo)
  29. #:use-module (guix packages)
  30. #:use-module (guix download)
  31. #:use-module (guix git-download)
  32. #:use-module (guix build-system gnu))
  33. (define-public guile-xcb
  34. (let ((commit "db7d5a393cc37a56f66541b3f33938b40c6f35b3")
  35. (revision "1"))
  36. (package
  37. (name "guile-xcb")
  38. (version (git-version "1.3" revision commit))
  39. (source (origin
  40. (method git-fetch)
  41. (uri (git-reference
  42. (url "https://github.com/mwitmer/guile-xcb")
  43. (commit commit)))
  44. (file-name (git-file-name name version))
  45. (sha256
  46. (base32
  47. "16w4vgzbmnwih4bgfn8rw85ryfvzhc6hyly6bic9sd7hhc82rcnd"))))
  48. (build-system gnu-build-system)
  49. (arguments '(;; Parallel builds fail.
  50. #:parallel-build? #f
  51. #:configure-flags (list (string-append
  52. "--with-guile-site-dir="
  53. (assoc-ref %outputs "out")
  54. "/share/guile/site/2.2")
  55. (string-append
  56. "--with-guile-site-ccache-dir="
  57. (assoc-ref %outputs "out")
  58. "/lib/guile/2.2/site-ccache"))))
  59. (native-inputs `(("guile" ,guile-2.2)
  60. ("pkg-config" ,pkg-config)
  61. ("texinfo" ,texinfo)))
  62. (inputs `(("guile" ,guile-2.2)
  63. ("xcb" ,xcb-proto)))
  64. (home-page "https://github.com/mwitmer/guile-xcb")
  65. (synopsis "XCB bindings for Guile")
  66. (description
  67. "Guile-XCB implements the XCB protocol and provides all the tools
  68. necessary to write X client code in Guile Scheme without any external
  69. dependencies.")
  70. (license gpl3+))))
  71. (define-public guile-wm
  72. (let ((commit "f3c7b3be719f425ffb87265d34855a73366351be")
  73. (revision "1"))
  74. (package
  75. (name "guile-wm")
  76. (version (git-version "1.0" revision commit))
  77. (synopsis "X11 window manager toolkit in Scheme")
  78. (source (origin
  79. (method git-fetch)
  80. (uri (git-reference
  81. (url "https://github.com/mwitmer/guile-wm")
  82. (commit commit)))
  83. (file-name (git-file-name name version))
  84. (sha256
  85. (base32
  86. "086dijnpl5dpglf70d6f9sizyakr313y7blpdjrmbi687j1x3qcl"))))
  87. (build-system gnu-build-system)
  88. (arguments
  89. `(#:modules ((guix build gnu-build-system)
  90. (guix build utils)
  91. (ice-9 rdelim)
  92. (ice-9 popen))
  93. ;; The '.scm' files go to $(datadir), so set that to the
  94. ;; standard value.
  95. #:configure-flags (list (string-append "--datadir="
  96. (assoc-ref %outputs "out")
  97. "/share/guile/site/2.2"))
  98. #:phases
  99. (modify-phases %standard-phases
  100. (add-before 'configure 'set-module-directory
  101. (lambda* (#:key outputs #:allow-other-keys)
  102. ;; Install .scm files to $out/share/guile/site/2.2.
  103. (let ((out (assoc-ref outputs "out"))
  104. (effective (read-line
  105. (open-pipe* OPEN_READ
  106. "guile" "-c"
  107. "(display (effective-version))"))))
  108. (substitute* "module/Makefile.in"
  109. (("^wmdir = .*$")
  110. (string-append "wmdir = " out
  111. "/share/guile/site/"
  112. effective "\n"))))
  113. #t))
  114. (add-after 'install 'set-load-path
  115. (lambda* (#:key inputs outputs #:allow-other-keys)
  116. ;; Put Guile-XCB's and Guile-WM's modules in the
  117. ;; search path of PROG.
  118. (let* ((out (assoc-ref outputs "out"))
  119. (effective (read-line
  120. (open-pipe* OPEN_READ
  121. "guile" "-c"
  122. "(display (effective-version))")))
  123. (prog (string-append out "/bin/guile-wm"))
  124. (mods (string-append out "/share/guile/site/" effective))
  125. (gos (string-append out "/lib/guile/" effective "/site-ccache"))
  126. (xcb (assoc-ref inputs "guile-xcb")))
  127. (wrap-program prog
  128. `("GUILE_AUTO_COMPILE" ":" = ("0"))
  129. `("GUILE_LOAD_PATH" ":" prefix
  130. (,mods ,(string-append xcb "/share/guile/site/" effective)))
  131. `("GUILE_LOAD_COMPILED_PATH" ":" prefix
  132. (,gos ,(string-append xcb "/lib/guile/"
  133. effective "/site-ccache")))))
  134. #t))
  135. (add-after 'install 'install-go-files
  136. (lambda* (#:key outputs inputs #:allow-other-keys)
  137. (let* ((out (assoc-ref outputs "out"))
  138. (effective (read-line
  139. (open-pipe* OPEN_READ
  140. "guile" "-c"
  141. "(display (effective-version))")))
  142. (module-dir (string-append out "/share/guile/site/"
  143. effective))
  144. (object-dir (string-append out "/lib/guile/" effective
  145. "/site-ccache"))
  146. (prefix (string-length module-dir)))
  147. (setenv "GUILE_AUTO_COMPILE" "0")
  148. ;; compile to the destination
  149. (for-each (lambda (file)
  150. (let* ((base (string-drop (string-drop-right file 4)
  151. prefix))
  152. (go (string-append object-dir base ".go")))
  153. (invoke "guild" "compile" "-L" module-dir
  154. file "-o" go)))
  155. (find-files module-dir "\\.scm$"))
  156. #t)))
  157. (add-after 'install 'install-xsession
  158. (lambda* (#:key outputs #:allow-other-keys)
  159. ;; add a .desktop file to xsessions
  160. (let ((xsessions (string-append
  161. %output "/share/xsessions")))
  162. (mkdir-p xsessions)
  163. (call-with-output-file (string-append
  164. xsessions "/guile-wm.desktop")
  165. (lambda (port)
  166. (format port
  167. "[Desktop Entry]~@
  168. Name=~a~@
  169. Comment=~a~@
  170. Exec=~a/bin/guile-wm~@
  171. Type=Application~%"
  172. ,name ,synopsis %output))))
  173. #t)))))
  174. (native-inputs `(("guile" ,guile-2.2)
  175. ("guile-xcb" ,guile-xcb)
  176. ("pkg-config" ,pkg-config)
  177. ("texinfo" ,texinfo)))
  178. (inputs `(("guile" ,guile-2.2)
  179. ("guile-xcb" ,guile-xcb)))
  180. (home-page "https://github.com/mwitmer/guile-wm/releases")
  181. (description
  182. "Guile-WM is a simple window manager that's completely customizable—you
  183. have total control of what it does by choosing which modules to include.
  184. Included with it are a few modules that provide basic TinyWM-like window
  185. management, some window record-keeping, multi-monitor support, and emacs-like
  186. keymaps and minibuffer. At this point, it's just enough to get you started.")
  187. (license gpl3+))))