projects/guix·blob javascript-team · refs

326 lines · 15.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Diego Nicola Barbato <[email protected]>
3;;; Copyright © 2024 Homo <[email protected]>
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu packages inferno)
21 #:use-module (guix build-system gnu)
22 #:use-module (guix gexp)
23 #:use-module (guix git-download)
24 #:use-module (guix packages)
25 #:use-module ((guix licenses)
26 #:prefix license:)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages plan9)
29 #:use-module (gnu packages xorg)
30 #:use-module (ice-9 match))
31
32(define-public inferno
33 ;; There are no tags, also a lot of improvements and bugfixes happenned since 2015.
34 (let ((commit "67e70befb2ad0058fd7894be34c492ddb6d09988")
35 (revision "0"))
36 (package
37 (name "inferno")
38 (version (git-version "4" revision commit))
39 (source
40 (origin
41 (method git-fetch)
42 (uri (git-reference
43 (url "https://github.com/inferno-os/inferno-os")
44 (commit commit)
45 ;; Inferno uses customized Freetype library with #include "lib9.h"
46 ;; TODO: use packaged Freetype library.
47 (recursive? #t)))
48 (file-name (git-file-name name version))
49 (sha256
50 (base32 "0g3fzb991hbwa7r3vsnybw7m1v13nins5ajmygnvz4vmx5rzl405"))
51 (patches (search-patches "inferno-fix-crash.patch"))
52 (modules '((guix build utils)))
53 ;; Remove bundled non-free and potentially non-free fonts.
54 (snippet '(delete-file-recursively "fonts"))))
55 (build-system gnu-build-system)
56 (arguments
57 (list
58 ;; Force a 32-bit build targeting a similar architecture, i.e.:
59 ;; armhf for armhf/aarch64, i686 for i686/x86_64.
60 ;; TODO: mips and powerpc.
61 #:system (match (%current-system)
62 ((or "armhf-linux" "aarch64-linux")
63 "armhf-linux")
64 (_ "i686-linux"))
65 ;; No tests.
66 #:tests? #f
67 #:phases
68 #~(modify-phases %standard-phases
69 (replace 'unpack
70 (lambda* (#:key source #:allow-other-keys)
71 (let* ((root (string-append #$output "/inferno")))
72 ;; Copy directly to 'root' since the source
73 ;; tree doubles as Inferno's root directory
74 ;; and its path is baked into the emu binary.
75 (mkdir-p root)
76 (copy-recursively source root)
77 (chdir root))))
78 ;; Scripts running in virtual machine need /dis/sh.
79 (delete 'patch-generated-file-shebangs)
80 (delete 'patch-shebangs)
81 (replace 'patch-source-shebangs
82 (lambda* (#:key inputs #:allow-other-keys)
83 ;; Substitute ocurrences of /bin/sh.
84 (for-each (lambda (file)
85 (substitute* file
86 (("/bin/sh")
87 (search-input-file inputs "/bin/bash"))))
88 '("makemk.sh"
89 "mkfiles/mkhost-Linux"
90 "emu/Linux/mk-wrt"
91 "utils/mk/Posix.c"))))
92 (add-after 'patch-source-shebangs 'patch-src-files
93 (lambda _
94 ;; Do not pass '-m32' unconditionally
95 ;; when building mk.
96 (substitute* "makemk.sh" (("-m32") ""))
97 ;; Use the correct name for gcc.
98 (substitute* "mkfiles/mkfile-Linux-386"
99 (("cc -")
100 ;; Don't match yacc.
101 "gcc -"))
102 (substitute* "mkfiles/mkfile-Linux-arm"
103 (("arm-gcc")
104 "gcc"))
105 ;; Conflicting occurence of fsub.
106 (for-each (lambda (file)
107 (substitute* file
108 (("fsub")
109 "_fsub")))
110 '("utils/libmach/vcodas.c"
111 "utils/libmach/vdb.c"))
112 ;; Fix build.
113 (for-each (lambda (file)
114 (substitute* file
115 (("^CFLAGS=")
116 (string-append
117 "CFLAGS=-D_GNU_SOURCE"
118 " -Wno-error=implicit-function-declaration"
119 " -Wno-error=incompatible-pointer-types"
120 " -fcommon"))))
121 '("mkfiles/mkfile-Linux-386"
122 "mkfiles/mkfile-Linux-arm"
123 "mkfiles/mkfile-Linux-power"
124 "mkfiles/mkfile-Linux-spim"))
125 ;; Make build reproducible by
126 ;; ensuring timestamps embedded into
127 ;; binaries are set to 0.
128 (substitute* "emu/Linux/mkfile"
129 (("^KERNDATE=.*$")
130 "KERNDATE=0\n"))))
131 (replace 'configure
132 (lambda* (#:key inputs #:allow-other-keys)
133 (let* ((objtype #$@(match (%current-system)
134 ((or "armhf-linux" "aarch64-linux")
135 `("arm"))
136 (_ `("386"))))
137 (root (string-append #$output "/inferno"))
138 (root/bindir (string-append root "/Linux/" objtype "/bin")))
139 (substitute* "mkconfig"
140 (("ROOT=/usr/inferno")
141 (string-append "ROOT=" root))
142 (("SYSHOST=Plan9")
143 "SYSHOST=Linux")
144 (("OBJTYPE=\\$objtype")
145 (string-append "OBJTYPE=" objtype)))
146 ;; Delete pre-built binaries.
147 (delete-file-recursively root/bindir)
148 (mkdir-p root/bindir)
149 ;; Avoid duplicating objtype variable later.
150 (symlink root/bindir (string-append #$output "/inferno/bin"))
151 (setenv "PATH"
152 (string-append
153 ;; These utilities will be used later in build.
154 root/bindir ":"
155 (getenv "PATH") ":"
156 ;; Bootstrap mk binary.
157 (search-input-directory inputs "/plan9/bin"))))))
158 (replace 'build
159 (lambda _
160 ;; Build emu, utilities and Dis binaries using mk.
161 (invoke "mk" "-s" "nuke" "mkdirs" "install")))
162 (replace 'install
163 (lambda* (#:key inputs #:allow-other-keys)
164 (let* ((bindir (string-append #$output "/bin"))
165 (emu-script (string-append bindir "/emu"))
166 (infwm-script (string-append bindir "/infwm"))
167 (root/bindir (string-append #$output "/inferno/bin"))
168 (simulate-fonts
169 (lambda (size targets)
170 (string-concatenate
171 (map (lambda (file)
172 (string-append
173 "ramfile /fonts/" file ".font; "
174 "bind /fonts/fixed/unicode." size ".font"
175 " /fonts/" file ".font; "))
176 targets))))
177 (write-script
178 (lambda (file cmds)
179 (with-output-to-file file
180 (lambda ()
181 (display
182 (string-concatenate
183 (cons* "#!"
184 (search-input-file inputs "/bin/bash")
185 "\n"
186 cmds)))))
187 (chmod file #o755))))
188 (mkdir-p bindir)
189 (mkdir-p "fonts")
190 ;; Install emu script.
191 (write-script emu-script (list
192 "exec " root/bindir "/emu sh -c \""
193 ;; Use plan9port's fonts.
194 "bind '#U*"
195 (search-input-directory inputs "/plan9/font")
196 "' /fonts; "
197 ;; Pretend fonts were not removed.
198 ;; TODO: de-hardcode fonts from apps.
199 ;; TODO: use fonts available in the host system,
200 ;; plan9port's fontsrv is a good way to start.
201 ;; TODO: find fix for minitel fonts.
202 "memfs -b /fonts; "
203 (string-concatenate
204 (map (lambda (dir)
205 (string-append
206 "mkdir /fonts/" dir "; "
207 "bind /fonts/fixed /fonts/" dir "; "))
208 '("charon" "lucida" "lucidasans" "lucm" "pelm")))
209 (simulate-fonts "6x9"
210 '("charon/cw.tiny"
211 "charon/plain.tiny"
212 "lucida/unicode.6"
213 "lucidasans/latin1.6"
214 "lucidasans/typelatin1.6"
215 "lucidasans/unicode.6"))
216 (simulate-fonts "7x13"
217 '("charon/cw.small"
218 "charon/plain.small"
219 "lucida/unicode.7"
220 "lucidasans/latin1.7"
221 "lucidasans/typelatin1.7"
222 "lucidasans/unicode.7"))
223 (simulate-fonts "8x13"
224 '("charon/cw.normal"
225 "charon/plain.normal"
226 "lucida/unicode.8"
227 "lucidasans/euro.8"
228 "lucidasans/latin1.8"
229 "lucidasans/typelatin1.8"
230 "lucidasans/unicode.8"
231 "pelm/unicode.8"))
232 (simulate-fonts "9x15"
233 '("charon/cw.large"
234 "charon/plain.large"
235 "lucida/unicode.10"
236 "lucidasans/latin1.10"
237 "lucidasans/typelatin1.10"
238 "lucidasans/unicode.10"
239 "lucm/unicode.9"
240 "pelm/ascii.12"
241 "pelm/latin1.9"
242 "pelm/unicode.9"))
243 (simulate-fonts "10x20"
244 '("charon/cw.vlarge"
245 "charon/plain.vlarge"
246 "lucida/moo.16"
247 "lucida/unicode.13"
248 "lucidasans/latin1.13"
249 "lucidasans/typelatin1.13"
250 "lucidasans/unicode.13"
251 "pelm/ascii.16"))
252 (simulate-fonts "6x13O"
253 '("charon/italic.tiny"
254 "charon/italic.small"
255 "lucidasans/italiclatin1.6"
256 "lucidasans/italiclatin1.7"))
257 (simulate-fonts "7x13O"
258 '("charon/italic.normal"
259 "lucidasans/italiclatin1.8"))
260 (simulate-fonts "8x13O"
261 '("charon/italic.large"
262 "charon/italic.vlarge"
263 "lucidasans/italiclatin1.10"
264 "lucidasans/italiclatin1.13"))
265 (simulate-fonts "6x13B"
266 '("charon/bold.tiny"
267 "lucidasans/boldlatin1.6"))
268 (simulate-fonts "7x13B"
269 '("charon/bold.small"
270 "lucidasans/boldlatin1.7"))
271 (simulate-fonts "8x13B"
272 '("charon/bold.normal"
273 "lucidasans/boldlatin1.8"))
274 (simulate-fonts "9x15B"
275 '("charon/bold.large"
276 "lucidasans/boldlatin1.10"))
277 (simulate-fonts "9x18B"
278 '("charon/bold.vlarge"
279 "lucidasans/boldlatin1.13"))
280 ;; Bind the host's /tmp to Inferno's
281 ;; /tmp to make it writable.
282 "bind -bc '#U*/tmp' /tmp; "
283 ;; Bind the host's /home to Inferno's
284 ;; /usr.
285 "bind '#U*/home' /usr; "
286 "$*\"\n"))
287 ;; Install infwm script.
288 (write-script infwm-script (list
289 "exec " bindir "/emu $* wm/wm wm/logon -u $USER\n"))
290 ;; Install a symlink to the Limbo compiler.
291 (symlink (string-append root/bindir "/limbo")
292 (string-append bindir "/limbo")))))
293 ;; Inferno doesn't compress man pages.
294 (delete 'compress-documentation))))
295 (inputs (list libx11 libxext plan9port xorgproto))
296 (home-page "https://www.inferno-os.org")
297 (synopsis
298 "Compact operating system for building cross-platform distributed systems")
299 (description
300 ;; Except for the last sentence this is taken verbatim from the
301 ;; intro(1) man page (man/1/0intro in the source tree).
302 "Inferno is a virtualised operating system that can run natively across
303a wide range of processor architectures or hosted on a wide range of
304operating systems. The principal components of the system are:
305@itemize
306@item The Inferno kernel which can run both native and hosted on a
307range of platforms and which presents the same interface to programs
308in both cases.
309@item The Dis virtual machine.
310@item Styx - the tiny broad-spectrum file service protocol.
311@item Limbo - a new simple, modular, concurrent programming language.
312@item Tk and Prefab - graphical user interface (GUI) primitives
313without a lot of goo.
314@item The portable cross-development suites that allow any native
315Inferno platform to be cross-compiled on any hosted system.
316@end itemize
317This package provides hosted Inferno.
318")
319 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"
320 "aarch64-linux"))
321 (license (list license:expat ;MIT license
322 license:freetype
323 ;; According to NOTICE the combined work is effectively
324 ;; GPLv2+.
325 license:gpl2+
326 license:lgpl2.0+)))))