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