gnu: Add dde-sources.
[jackhill/guix/guix.git] / gnu / packages / hurd.scm
CommitLineData
0193c004 1;;; GNU Guix --- Functional package management for GNU
8df672aa 2;;; Copyright © 2014, 2015, 2016, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
e62f6f77 3;;; Copyright © 2018, 2020 Ludovic Courtès <ludo@gnu.org>
fb9d6f0f 4;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
f379c665 5;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
9b943db3 6;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
706b91ea 7;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
0193c004
MR
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24(define-module (gnu packages hurd)
25 #:use-module (guix licenses)
26 #:use-module (guix download)
27 #:use-module (guix packages)
21a8fe1b 28 #:use-module (gnu packages)
f46cf8ef 29 #:use-module (guix gexp)
e1ecd50e 30 #:use-module (guix utils)
396b3c8b 31 #:use-module (guix build-system gnu)
38efbcbb 32 #:use-module (guix build-system trivial)
2d546858 33 #:use-module (gnu packages autotools)
396b3c8b 34 #:use-module (gnu packages flex)
abbeaf54 35 #:use-module (gnu packages gnupg)
dc91c10f 36 #:use-module (gnu packages bison)
1d5fc9f7 37 #:use-module (gnu packages libdaemon)
29505c7d 38 #:use-module (gnu packages linux)
dc91c10f 39 #:use-module (gnu packages perl)
1d5fc9f7 40 #:use-module (gnu packages pkg-config)
21a8fe1b 41 #:use-module (gnu packages base)
29505c7d 42 #:use-module (gnu packages bash)
fb9d6f0f 43 #:use-module (gnu packages texinfo)
706b91ea 44 #:use-module (gnu packages xorg) ; libpciaccess
62596a15 45 #:use-module (guix git-download)
9b943db3
JN
46 #:export (hurd-system?
47 hurd-target?
48 hurd-triplet?))
62596a15
MR
49
50(define (hurd-triplet? triplet)
51 (and (string-suffix? "-gnu" triplet)
52 (not (string-contains triplet "linux"))))
0193c004 53
2d546858
LC
54(define (hurd-target?)
55 "Return true if the cross-compilation target or the current system is
56GNU/Hurd."
57 (or (and=> (%current-target-system) hurd-triplet?)
9b943db3
JN
58 (and (not (%current-target-system))
59 (and=> (%current-system) hurd-triplet?))))
60
61(define (hurd-system?)
62 "Return true if the current system is the Hurd."
63 (and=> (%current-system) hurd-triplet?))
2d546858 64
b005a37a
MR
65(define (hurd-source-url version)
66 (string-append "mirror://gnu/hurd/hurd-"
67 version ".tar.gz"))
68
0193c004 69(define-public gnumach-headers
fb9d6f0f
EF
70 (let ((commit "097f9cf735ffa1212b828682ad92f0f6c5f1c552")
71 (revision "1"))
72 (package
73 (name "gnumach-headers")
74 (version (git-version "1.8" revision commit))
75 (source
76 (origin
77 (method git-fetch)
78 (uri (git-reference
79 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
80 (commit commit)))
81 (file-name (git-file-name "gnumach" version))
82 (sha256
83 (base32
84 "0q36z7k02bykrld90zaxbhyzxlmwlqqs4divgir6ix38zsp6icqk"))))
85 (build-system gnu-build-system)
86 (arguments
87 `(#:phases
88 (modify-phases %standard-phases
89 (replace 'install
90 (lambda _
91 (invoke "make" "install-data")))
92 (delete 'build))
0193c004 93
fb9d6f0f
EF
94 ;; GNU Mach supports only IA32 currently, so cheat so that we can at
95 ;; least install its headers.
96 ,@(if (%current-target-system)
97 '()
98 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-06/msg00042.html>
99 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-06/msg00716.html>
100 '(#:configure-flags '("--build=i586-pc-gnu"
101 "--host=i686-linux-gnu")))
0193c004 102
fb9d6f0f
EF
103 #:tests? #f))
104 (native-inputs
105 `(("autoconf" ,autoconf)
106 ("automake" ,automake)
107 ("texinfo" ,texinfo-4)))
108 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html")
109 (synopsis "GNU Mach kernel headers")
110 (description
111 "Headers of the GNU Mach kernel.")
112 (license gpl2+))))
396b3c8b
MR
113
114(define-public mig
115 (package
116 (name "mig")
9c9402be 117 (version "1.8")
396b3c8b
MR
118 (source
119 (origin
120 (method url-fetch)
121 (uri (string-append "mirror://gnu/mig/mig-"
122 version ".tar.gz"))
123 (sha256
124 (base32
9c9402be 125 "1gyda8sq6b379nx01hkpbd85lz39irdvz2b9wbr63gicicx8i706"))))
396b3c8b 126 (build-system gnu-build-system)
a7ecc92d
MR
127 ;; Flex is needed both at build and run time.
128 (inputs `(("gnumach-headers" ,gnumach-headers)
129 ("flex" ,flex)))
396b3c8b
MR
130 (native-inputs
131 `(("flex" ,flex)
132 ("bison" ,bison)))
133 (arguments `(#:tests? #f))
6fd52309 134 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/mig/gnu_mig.html")
396b3c8b
MR
135 (synopsis "Mach 3.0 interface generator for the Hurd")
136 (description
137 "GNU MIG is the GNU distribution of the Mach 3.0 interface generator
138MIG, as maintained by the GNU Hurd developers for the GNU project.
139You need this tool to compile the GNU Mach and GNU Hurd distributions,
35b9e423 140and to compile the GNU C library for the Hurd. Also, you will need it
396b3c8b
MR
141for other software in the GNU system that uses Mach-based inter-process
142communication.")
143 (license gpl2+)))
dc91c10f
MR
144
145(define-public hurd-headers
2d546858
LC
146 ;; Resort to a post-0.9 snapshot that provides the 'file_utimens' and
147 ;; 'file_exec_paths' RPCs that glibc 2.28 expects.
f379c665
MB
148 (let ((revision "1")
149 (commit "91a51672ff4cfe1f1a0712b4c542ded3081c825b"))
2d546858
LC
150 (package
151 (name "hurd-headers")
f379c665 152 (version (git-version "0.9" revision commit))
2d546858
LC
153 (source (origin
154 (method git-fetch)
155 (uri (git-reference
156 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
157 (commit commit)))
158 (sha256
159 (base32
f379c665 160 "16k9wkahz9wasviijz53n6i13nmiwa9fs64ikf1jqh8rl60hw7cz"))
2d546858
LC
161 (file-name (git-file-name name version))))
162 (build-system gnu-build-system)
163 (native-inputs
164 `(("mig" ,mig)
165 ("autoconf" ,autoconf)
166 ("automake" ,automake)))
167 (arguments
168 `(#:phases
169 (modify-phases %standard-phases
170 (replace 'install
171 (lambda _
172 (invoke "make" "install-headers" "no_deps=t")))
173 (delete 'build))
dc91c10f 174
2d546858
LC
175 #:configure-flags '( ;; Pretend we're on GNU/Hurd; 'configure' wants
176 ;; that.
177 ,@(if (%current-target-system)
178 '()
179 '("--host=i586-pc-gnu"))
180
181 ;; Reduce set of dependencies.
182 "--without-parted"
183 "--disable-ncursesw"
184 "--disable-test"
185 "--without-libbz2"
f379c665 186 "--without-libcrypt"
2d546858
LC
187 "--without-libz"
188 ;; Skip the clnt_create check because it expects
189 ;; a working glibc causing a circular dependency.
190 "ac_cv_search_clnt_create=no"
191
192 ;; Annihilate the checks for the 'file_exec_paths'
193 ;; & co. libc functions to avoid "link tests are
194 ;; not allowed after AC_NO_EXECUTABLES" error.
195 "ac_cv_func_file_exec_paths=no"
196 "ac_cv_func_exec_exec_paths=no"
197 "ac_cv_func__hurd_exec_paths=no"
198 "ac_cv_func_file_futimens=no")
199
200 #:tests? #f))
201 (home-page "https://www.gnu.org/software/hurd/hurd.html")
202 (synopsis "GNU Hurd headers")
203 (description
204 "This package provides C headers of the GNU Hurd, used to build the GNU C
dc91c10f 205Library and other user programs.")
2d546858 206 (license gpl2+))))
21a8fe1b
MR
207
208(define-public hurd-minimal
209 (package (inherit hurd-headers)
210 (name "hurd-minimal")
211 (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers)))
21a8fe1b 212 (arguments
e1ecd50e
MR
213 (substitute-keyword-arguments (package-arguments hurd-headers)
214 ((#:phases _)
dc1d3cde
KK
215 '(modify-phases %standard-phases
216 (replace 'install
217 (lambda* (#:key outputs #:allow-other-keys)
218 (let ((out (assoc-ref outputs "out")))
219 ;; We need to copy libihash.a to the output directory manually,
220 ;; since there is no target for that in the makefile.
221 (mkdir-p (string-append out "/include"))
222 (copy-file "libihash/ihash.h"
223 (string-append out "/include/ihash.h"))
224 (mkdir-p (string-append out "/lib"))
225 (copy-file "libihash/libihash.a"
226 (string-append out "/lib/libihash.a"))
227 #t)))
228 (replace 'build
229 (lambda _
2d546858
LC
230 ;; Install <assert-backtrace.h> & co.
231 (invoke "make" "-Clibshouldbeinlibc"
232 "../include/assert-backtrace.h")
233
234 ;; Build libihash.
a48d22d6 235 (invoke "make" "-Clibihash" "libihash.a")))))))
6fd52309 236 (home-page "https://www.gnu.org/software/hurd/hurd.html")
21a8fe1b
MR
237 (synopsis "GNU Hurd libraries")
238 (description
a124bbd2 239 "This package provides libihash, needed to build the GNU C
21a8fe1b
MR
240Library for GNU/Hurd.")
241 (license gpl2+)))
38efbcbb
MR
242
243(define-public hurd-core-headers
244 (package
245 (name "hurd-core-headers")
246 (version (package-version hurd-headers))
247 (source #f)
248 (build-system trivial-build-system)
249 (arguments
250 '(#:modules ((guix build union))
251 #:builder (begin
252 (use-modules (ice-9 match)
253 (guix build union))
254 (match %build-inputs
255 (((names . directories) ...)
256 (union-build (assoc-ref %outputs "out")
e3cfef22
MW
257 directories)
258 #t)))))
38efbcbb
MR
259 (inputs `(("gnumach-headers" ,gnumach-headers)
260 ("hurd-headers" ,hurd-headers)
261 ("hurd-minimal" ,hurd-minimal)))
262 (synopsis "Union of the Hurd headers and libraries")
263 (description
264 "This package contains the union of the Mach and Hurd headers and the
265Hurd-minimal package which are needed for both glibc and GCC.")
266 (home-page (package-home-page hurd-headers))
267 (license (package-license hurd-headers))))
8df672aa
MR
268
269(define-public gnumach
270 (package
fb9d6f0f 271 (inherit gnumach-headers)
8df672aa 272 (name "gnumach")
8df672aa 273 (arguments
e62f6f77 274 (substitute-keyword-arguments (package-arguments gnumach-headers)
29814639
LC
275 ((#:configure-flags flags ''())
276 `(cons "--enable-kdb" ,flags)) ;enable kernel debugger
e62f6f77
LC
277 ((#:phases phases '%standard-phases)
278 `(modify-phases %standard-phases
279 (add-after 'install 'produce-image
280 (lambda* (#:key outputs #:allow-other-keys)
281 (let* ((out (assoc-ref outputs "out"))
282 (boot (string-append out "/boot")))
283 (invoke "make" "gnumach.gz")
284 (install-file "gnumach.gz" boot)
285 #t)))))))
8df672aa
MR
286 (native-inputs
287 `(("mig" ,mig)
e62f6f77
LC
288 ("perl" ,perl)
289 ("autoconf" ,autoconf)
290 ("automake" ,automake)
291 ("texinfo" ,texinfo-4)))
8df672aa 292 (supported-systems (cons "i686-linux" %hurd-systems))
8df672aa
MR
293 (synopsis "Microkernel of the GNU system")
294 (description
fb9d6f0f 295 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
cc4faa35 296
ad3bbead
LC
297(define unifont
298 ;; GNU Unifont, <http://gnu.org/s/unifont>.
299 ;; Used the the VGA driver of the Hurd's console client.
300 (origin
301 (method url-fetch)
302 (uri
303 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
304 (sha256
305 (base32
306 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
307
f46cf8ef
LC
308(define (hurd-rc-script)
309 "Return a script to be installed as /libexec/rc in the 'hurd' package. The
310script takes care of installing the relevant passive translators on the first
311boot, since this cannot be done from GNU/Linux."
312 (define translators
313 '(("/servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
314 ("/servers/crash-kill" ("/hurd/crash" "--kill"))
315 ("/servers/crash-suspend" ("/hurd/crash" "--suspend"))
316 ("/servers/password" ("/hurd/password"))
317 ("/servers/socket/1" ("/hurd/pflocal"))
318 ("/servers/socket/2" ("/hurd/pfinet" "--interface" "eth0"
319 "--address" "10.0.2.77"
320 "--netmask" "255.255.255.0"
321 "--gateway" "10.0.2.2"
322 "--ipv6" "/servers/socket/16"))))
323
324 (define rc
325 (with-imported-modules '((guix build utils))
326 #~(begin
327 (use-modules (guix build utils)
328 (ice-9 match))
329
330 ;; "@HURD@" is a placeholder.
331 (setenv "PATH" "@HURD@/bin")
332
333 (define (translated? node)
334 ;; Return true if a translator is installed on NODE.
335 (with-output-to-port (%make-void-port "w")
336 (lambda ()
337 (with-error-to-port (%make-void-port "w")
338 (lambda ()
339 (zero? (system* "showtrans" "-s" node)))))))
340
341 (for-each (match-lambda
342 ((node command)
343 (unless (translated? node)
344 (mkdir-p (dirname node))
345 (apply invoke "settrans" "-c" node command))))
df0010a9
LC
346 '#$translators)
347
348 ;; Start the oh-so-fancy console client.
349 (mkdir-p "/var/run") ;for the PID file
350 (invoke "console" "--daemonize" "-c" "/dev/vcs"
351 "-d" "vga" "-d" "pc_kbd" "-d" "generic_speaker"))))
f46cf8ef
LC
352
353 ;; FIXME: We want the program to use the cross-compiled Guile when
354 ;; cross-compiling. But why do we need to be explicit here?
355 (with-parameters ((%current-target-system "i586-pc-gnu"))
356 (program-file "rc" rc)))
357
71b92e1a
RW
358(define dde-sources
359 ;; This is the current tip of the dde branch
360 (let ((commit "ac1c7eb7a8b24b7469bed5365be38a968d59a136"))
361 (origin
362 (method git-fetch)
363 (uri (git-reference
364 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
365 (commit commit)))
366 (sha256
367 (base32
368 "1vryinbg75xpydfrv9dbgfnds6knlh8l8bk2rxp32y9dc58z0692"))
369 (file-name (git-file-name "dde" commit)))))
370
cc4faa35
MR
371(define-public hurd
372 (package
373 (name "hurd")
496d607d
JN
374 (version (package-version hurd-headers))
375 (source (origin (inherit (package-source hurd-headers))
376 (patches (search-patches "hurd-cross.patch"))))
cc4faa35
MR
377 (arguments
378 `(#:phases
379 (modify-phases %standard-phases
706b91ea
RW
380 (add-after 'unpack 'prepare-dde
381 (lambda* (#:key native-inputs inputs #:allow-other-keys)
382 (substitute* "Makefile"
383 (("libbpf ")
384 "libbpf libmachdev libmachdevdde libddekit"))
385 (for-each make-file-writable (find-files "."))
386 (let ((dde (or (assoc-ref inputs "dde-sources")
387 (assoc-ref native-inputs "dde-sources"))))
388 (for-each (lambda (dir)
389 (copy-recursively
390 (string-append dde "/" dir ) dir))
391 '("libmachdev" "libmachdevdde" "libddekit")))
392 #t))
cc4faa35 393 (add-before 'build 'pre-build
f46cf8ef
LC
394 (lambda _
395 ;; Don't change the ownership of any file at this time.
396 (substitute* '("daemons/Makefile" "utils/Makefile")
397 (("-o root -m 4755") ""))
398 #t))
b7e23a92
LC
399 (add-before 'build 'set-file-names
400 (lambda* (#:key inputs outputs #:allow-other-keys)
29505c7d
LC
401 (let* ((out (assoc-ref outputs "out"))
402 (bash (assoc-ref inputs "bash-minimal"))
403 (coreutils (assoc-ref inputs "coreutils"))
404 (sed (assoc-ref inputs "sed"))
405 (grep (assoc-ref inputs "grep"))
406 (util-linux (assoc-ref inputs "util-linux")))
407 (substitute* '("daemons/runttys.c" "daemons/getty.c" "utils/login.c")
b7e23a92 408 (("/bin/login")
29505c7d
LC
409 (string-append out "/bin/login"))
410 (("/bin/bash") (string-append bash "/bin/bash")))
411 (substitute* '("startup/startup.c" "init/init.c" "config/ttys")
412 (("/libexec/")
413 (string-append out "/libexec/")))
414 (substitute* "daemons/console-run.c"
415 (("/hurd/")
416 (string-append out "/hurd/")))
417
418 (substitute* '("daemons/runsystem.sh"
419 "daemons/runsystem.hurd.sh"
420 "sutils/MAKEDEV.sh")
421 (("^PATH=.*")
422 (string-append "PATH=" out "/bin:" out "/sbin:"
423 coreutils "/bin:"
424 sed "/bin:" grep "/bin:"
425 util-linux "/bin\n"))
426 (("^SHELL=.*")
427 (string-append "SHELL=" bash "/bin/bash\n"))
428 (("/sbin/") (string-append out "/sbin/"))
429 (("/libexec/") (string-append out "/libexec/"))
430 (("/hurd/") (string-append out "/hurd/")))
431
432 (substitute* "daemons/runsystem.sh"
433 (("export PATH")
434 (string-append "export PATH\n"
435 "\
436fsysopts / --writable
437
438# MAKEDEV relies on pipes so this needs to be set up.
439settrans -c /servers/socket/1 /hurd/pflocal
440
441(cd /dev; MAKEDEV -D /dev std vcs tty{1,2,3,4,5,6})\n")))
442
443 (substitute* "daemons/runsystem.hurd.sh"
444 (("export PATH")
445 "export PATH
446fsysopts / --writable\n"))
447 #t)))
448 (add-after 'patch-shebangs 'patch-libexec-shebangs
449 (lambda* (#:key inputs outputs #:allow-other-keys)
450 ;; XXX: Since the 'patch-shebangs' phase doesn't traverse
451 ;; /libexec, do it here.
452 (let* ((out (assoc-ref outputs "out"))
453 (bash (assoc-ref inputs "bash-minimal"))
454 (path (list (string-append bash "/bin"))))
455 (for-each (lambda (file)
456 (patch-shebang file path))
457 (find-files (string-append out "/libexec")))
b7e23a92 458 #t)))
62a3bbfd 459 (add-after 'install 'install-goodies
ad3bbead 460 (lambda* (#:key inputs outputs #:allow-other-keys)
62a3bbfd
LC
461 ;; Install additional goodies.
462 ;; TODO: Build & install *.msgids for rpctrace.
ad3bbead
LC
463 (let* ((out (assoc-ref outputs "out"))
464 (datadir (string-append out "/share/hurd")))
62a3bbfd
LC
465 ;; Install the fancy UTF-8 motd.
466 (mkdir-p (string-append out "/etc"))
467 (copy-file "console/motd.UTF8"
468 (string-append out "/etc/motd"))
ad3bbead
LC
469
470 ;; Install the BDF font for use by the console client.
471 (copy-file (assoc-ref inputs "unifont")
472 "unifont.gz")
473 (invoke "gunzip" "unifont.gz")
474 (mkdir-p datadir)
475 (copy-file "unifont"
476 (string-append datadir "/vga-system.bdf"))
62a3bbfd 477 #t)))
f46cf8ef
LC
478 (add-after 'install 'install-rc-file
479 (lambda* (#:key inputs outputs #:allow-other-keys)
480 (let* ((out (assoc-ref outputs "out"))
481 (file (string-append out "/libexec/rc"))
482 (rc (assoc-ref inputs "hurd-rc")))
483 (delete-file file)
484 (copy-file rc file)
485 (substitute* file
486 (("@HURD@") out))
487 #t))))
cc4faa35
MR
488 #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
489 %output "/lib")
490 "--disable-ncursesw"
491 "--without-libbz2"
492 "--without-libz"
493 "--without-parted")))
494 (build-system gnu-build-system)
f46cf8ef
LC
495 (inputs
496 `(("glibc-hurd-headers" ,glibc/hurd-headers)
29505c7d
LC
497 ("hurd-rc" ,(hurd-rc-script))
498
abbeaf54 499 ("libgcrypt" ,libgcrypt) ;for /hurd/random
1d5fc9f7 500 ("libdaemon" ,libdaemon) ;for /bin/console --daemonize
ad3bbead 501 ("unifont" ,unifont)
706b91ea 502 ("libpciaccess" ,libpciaccess)
1d5fc9f7 503
29505c7d
LC
504 ;; Tools for the /libexec/* scripts.
505 ("bash-minimal" ,bash-minimal)
506 ("coreutils" ,coreutils)
507 ("sed" ,sed)
508 ("grep" ,grep)
509 ("util-linux" ,util-linux)))
cc4faa35 510 (native-inputs
496d607d
JN
511 `(("autoconf" ,autoconf)
512 ("automake" ,automake)
abbeaf54 513 ("libgcrypt" ,libgcrypt) ;for 'libgcrypt-config'
1d5fc9f7 514 ("pkg-config" ,pkg-config)
09ac892a
LC
515 ("mig" ,(if (%current-target-system)
516 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
517 ;; hence this hack.
518 (package
519 (inherit mig)
520 (arguments `(#:system "i686-linux")))
521 mig))
496d607d 522 ("perl" ,perl)
706b91ea 523 ("texinfo" ,texinfo-4)
71b92e1a 524 ("dde-sources" ,dde-sources)))
cc4faa35
MR
525 (supported-systems %hurd-systems)
526 (home-page "https://www.gnu.org/software/hurd/hurd.html")
527 (synopsis "The kernel servers for the GNU operating system")
528 (description
529 "The Hurd is the kernel for the GNU system, a replacement and
530augmentation of standard Unix kernels. It is a collection of protocols for
531system interaction (file systems, networks, authentication), and servers
532implementing them.")
533 (license gpl2+)))