1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2018, 2020 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
6 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
7 ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
8 ;;; Copyright © 2020 Rene Saavedra <pacoon@protonmail.com>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages hurd)
26 #:use-module ((guix licenses) #:hide (zlib))
27 #:use-module (guix download)
28 #:use-module (guix packages)
29 #:use-module (gnu packages)
30 #:use-module (guix gexp)
31 #:use-module (guix utils)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system trivial)
34 #:use-module (gnu packages autotools)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages flex)
37 #:use-module (gnu packages gawk)
38 #:use-module (gnu packages gnupg)
39 #:use-module (gnu packages bison)
40 #:use-module (gnu packages libdaemon)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages base)
45 #:use-module (gnu packages bash)
46 #:use-module (gnu packages texinfo)
47 #:use-module (gnu packages onc-rpc)
48 #:use-module (gnu packages xorg) ; libpciaccess
49 #:use-module (guix git-download)
50 #:export (hurd-system?
54 (define (hurd-triplet? triplet)
55 (and (string-suffix? "-gnu" triplet)
56 (not (string-contains triplet "linux"))))
58 (define (hurd-target?)
59 "Return true if the cross-compilation target or the current system is
61 (or (and=> (%current-target-system) hurd-triplet?)
62 (and (not (%current-target-system))
63 (and=> (%current-system) hurd-triplet?))))
65 (define (hurd-system?)
66 "Return true if the current system is the Hurd."
67 (and=> (%current-system) hurd-triplet?))
69 (define (hurd-source-url version)
70 (string-append "mirror://gnu/hurd/hurd-"
73 (define-public gnumach-headers
74 (let ((commit "097f9cf735ffa1212b828682ad92f0f6c5f1c552")
77 (name "gnumach-headers")
78 (version (git-version "1.8" revision commit))
83 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
85 (file-name (git-file-name "gnumach" version))
88 "0q36z7k02bykrld90zaxbhyzxlmwlqqs4divgir6ix38zsp6icqk"))))
89 (build-system gnu-build-system)
92 (modify-phases %standard-phases
95 (invoke "make" "install-data")))
98 ;; GNU Mach supports only IA32 currently, so cheat so that we can at
99 ;; least install its headers.
100 ,@(if (%current-target-system)
102 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-06/msg00042.html>
103 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-06/msg00716.html>
104 '(#:configure-flags '("--build=i586-pc-gnu"
105 "--host=i686-linux-gnu")))
109 `(("autoconf" ,autoconf)
110 ("automake" ,automake)
111 ("texinfo" ,texinfo-4)))
112 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html")
113 (synopsis "GNU Mach kernel headers")
115 "Headers of the GNU Mach kernel.")
125 (uri (string-append "mirror://gnu/mig/mig-"
129 "1gyda8sq6b379nx01hkpbd85lz39irdvz2b9wbr63gicicx8i706"))))
130 (build-system gnu-build-system)
131 ;; Flex is needed both at build and run time.
132 (inputs `(("gnumach-headers" ,gnumach-headers)
137 (arguments `(#:tests? #f))
138 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/mig/gnu_mig.html")
139 (synopsis "Mach 3.0 interface generator for the Hurd")
141 "GNU MIG is the GNU distribution of the Mach 3.0 interface generator
142 MIG, as maintained by the GNU Hurd developers for the GNU project.
143 You need this tool to compile the GNU Mach and GNU Hurd distributions,
144 and to compile the GNU C library for the Hurd. Also, you will need it
145 for other software in the GNU system that uses Mach-based inter-process
149 (define-public hurd-headers
150 ;; Resort to a post-0.9 snapshot that provides the 'file_utimens' and
151 ;; 'file_exec_paths' RPCs that glibc 2.28 expects.
153 (commit "91a51672ff4cfe1f1a0712b4c542ded3081c825b"))
155 (name "hurd-headers")
156 (version (git-version "0.9" revision commit))
160 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
164 "16k9wkahz9wasviijz53n6i13nmiwa9fs64ikf1jqh8rl60hw7cz"))
165 (file-name (git-file-name name version))))
166 (build-system gnu-build-system)
169 ("autoconf" ,autoconf)
170 ("automake" ,automake)))
173 (modify-phases %standard-phases
176 (invoke "make" "install-headers" "no_deps=t")))
179 #:configure-flags '( ;; Pretend we're on GNU/Hurd; 'configure' wants
181 ,@(if (%current-target-system)
183 '("--host=i586-pc-gnu"))
185 ;; Reduce set of dependencies.
192 ;; Skip the clnt_create check because it expects
193 ;; a working glibc causing a circular dependency.
194 "ac_cv_search_clnt_create=no"
196 ;; Annihilate the checks for the 'file_exec_paths'
197 ;; & co. libc functions to avoid "link tests are
198 ;; not allowed after AC_NO_EXECUTABLES" error.
199 "ac_cv_func_file_exec_paths=no"
200 "ac_cv_func_exec_exec_paths=no"
201 "ac_cv_func__hurd_exec_paths=no"
202 "ac_cv_func_file_futimens=no")
205 (home-page "https://www.gnu.org/software/hurd/hurd.html")
206 (synopsis "GNU Hurd headers")
208 "This package provides C headers of the GNU Hurd, used to build the GNU C
209 Library and other user programs.")
212 (define-public hurd-minimal
213 (package (inherit hurd-headers)
214 (name "hurd-minimal")
215 (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers)))
217 (substitute-keyword-arguments (package-arguments hurd-headers)
219 '(modify-phases %standard-phases
221 (lambda* (#:key outputs #:allow-other-keys)
222 (let ((out (assoc-ref outputs "out")))
223 ;; We need to copy libihash.a to the output directory manually,
224 ;; since there is no target for that in the makefile.
225 (mkdir-p (string-append out "/include"))
226 (copy-file "libihash/ihash.h"
227 (string-append out "/include/ihash.h"))
228 (mkdir-p (string-append out "/lib"))
229 (copy-file "libihash/libihash.a"
230 (string-append out "/lib/libihash.a"))
234 ;; Install <assert-backtrace.h> & co.
235 (invoke "make" "-Clibshouldbeinlibc"
236 "../include/assert-backtrace.h")
239 (invoke "make" "-Clibihash" "libihash.a")))))))
240 (home-page "https://www.gnu.org/software/hurd/hurd.html")
241 (synopsis "GNU Hurd libraries")
243 "This package provides libihash, needed to build the GNU C
244 Library for GNU/Hurd.")
247 (define-public hurd-core-headers
249 (name "hurd-core-headers")
250 (version (package-version hurd-headers))
252 (build-system trivial-build-system)
254 '(#:modules ((guix build union))
256 (use-modules (ice-9 match)
259 (((names . directories) ...)
260 (union-build (assoc-ref %outputs "out")
263 (inputs `(("gnumach-headers" ,gnumach-headers)
264 ("hurd-headers" ,hurd-headers)
265 ("hurd-minimal" ,hurd-minimal)))
266 (synopsis "Union of the Hurd headers and libraries")
268 "This package contains the union of the Mach and Hurd headers and the
269 Hurd-minimal package which are needed for both glibc and GCC.")
270 (home-page (package-home-page hurd-headers))
271 (license (package-license hurd-headers))))
273 (define-public gnumach
275 (inherit gnumach-headers)
278 (substitute-keyword-arguments (package-arguments gnumach-headers)
279 ((#:configure-flags flags ''())
280 `(cons "--enable-kdb" ,flags)) ;enable kernel debugger
281 ((#:phases phases '%standard-phases)
282 `(modify-phases %standard-phases
283 (add-after 'install 'produce-image
284 (lambda* (#:key outputs #:allow-other-keys)
285 (let* ((out (assoc-ref outputs "out"))
286 (boot (string-append out "/boot")))
287 (invoke "make" "gnumach.gz")
288 (install-file "gnumach.gz" boot)
293 ("autoconf" ,autoconf)
294 ("automake" ,automake)
295 ("texinfo" ,texinfo-4)))
296 (supported-systems (cons "i686-linux" %hurd-systems))
297 (synopsis "Microkernel of the GNU system")
299 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
302 ;; GNU Unifont, <http://gnu.org/s/unifont>.
303 ;; Used the the VGA driver of the Hurd's console client.
307 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
310 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
312 (define (hurd-rc-script)
313 "Return a script to be installed as /libexec/rc in the 'hurd' package. The
314 script takes care of installing the relevant passive translators on the first
315 boot, since this cannot be done from GNU/Linux."
317 '(("/servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
318 ("/servers/crash-kill" ("/hurd/crash" "--kill"))
319 ("/servers/crash-suspend" ("/hurd/crash" "--suspend"))
320 ("/servers/password" ("/hurd/password"))
321 ("/servers/socket/1" ("/hurd/pflocal"))
322 ("/servers/socket/2" ("/hurd/pfinet" "--interface" "eth0"
323 "--address" "10.0.2.15" ;the default QEMU guest IP
324 "--netmask" "255.255.255.0"
325 "--gateway" "10.0.2.2"
326 "--ipv6" "/servers/socket/16"))))
329 (with-imported-modules '((guix build utils))
331 (use-modules (guix build utils)
334 ;; "@HURD@" is a placeholder.
335 (setenv "PATH" "@HURD@/bin")
337 (define (translated? node)
338 ;; Return true if a translator is installed on NODE.
339 (with-output-to-port (%make-void-port "w")
341 (with-error-to-port (%make-void-port "w")
343 (zero? (system* "showtrans" "-s" node)))))))
345 (for-each (match-lambda
347 (unless (translated? node)
348 (mkdir-p (dirname node))
349 (apply invoke "settrans" "-c" node command))))
352 ;; Start the oh-so-fancy console client.
353 (mkdir-p "/var/run") ;for the PID file
354 (invoke "console" "--daemonize" "-c" "/dev/vcs"
355 "-d" "vga" "-d" "pc_kbd" "-d" "generic_speaker"))))
357 ;; FIXME: We want the program to use the cross-compiled Guile when
358 ;; cross-compiling. But why do we need to be explicit here?
359 (with-parameters ((%current-target-system "i586-pc-gnu"))
360 (program-file "rc" rc)))
363 ;; This is the current tip of the dde branch
364 (let ((commit "ac1c7eb7a8b24b7469bed5365be38a968d59a136"))
368 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
372 "1vryinbg75xpydfrv9dbgfnds6knlh8l8bk2rxp32y9dc58z0692"))
373 (file-name (git-file-name "dde" commit)))))
378 (version (package-version hurd-headers))
379 (source (origin (inherit (package-source hurd-headers))
380 (patches (search-patches "hurd-cross.patch"))))
383 (modify-phases %standard-phases
384 (add-after 'unpack 'prepare-dde
385 (lambda* (#:key native-inputs inputs #:allow-other-keys)
386 (substitute* "Makefile"
388 "libbpf libmachdev libmachdevdde libddekit"))
389 (for-each make-file-writable (find-files "."))
390 (let ((dde (or (assoc-ref inputs "dde-sources")
391 (assoc-ref native-inputs "dde-sources"))))
392 (for-each (lambda (dir)
394 (string-append dde "/" dir ) dir))
395 '("libmachdev" "libmachdevdde" "libddekit")))
397 (add-after 'unpack 'find-tirpc
398 (lambda* (#:key inputs #:allow-other-keys)
399 (for-each (lambda (var)
401 (string-append (assoc-ref inputs "libtirpc")
403 (or (getenv var) ""))))
404 '("CROSS_C_INCLUDE_PATH" "C_INCLUDE_PATH"
405 "CROSS_CPATH" "CPATH"))
407 (add-after 'unpack 'fix-rpc-headers
409 (substitute* "nfs/mount.c"
410 (("#undef (TRUE|FALSE)") "")
411 (("#include <rpc/pmap_prot.h>" m)
412 (string-append "#include <rpc/xdr.h>\n" m)))
413 (substitute* '("nfsd/cache.c")
414 (("#undef (TRUE|FALSE)") ""))
415 (substitute* '("nfsd/loop.c"
418 (("#include <rpc/pmap_prot.h>" m)
419 (string-append "#include <rpc/types.h>\n#include <rpc/xdr.h>\n" m)))
421 (add-before 'build 'pre-build
423 ;; Don't change the ownership of any file at this time.
424 (substitute* '("daemons/Makefile" "utils/Makefile")
425 (("-o root -m 4755") ""))
427 (add-before 'build 'set-file-names
428 (lambda* (#:key inputs outputs #:allow-other-keys)
429 (let* ((out (assoc-ref outputs "out"))
430 (bash (assoc-ref inputs "bash-minimal"))
431 (coreutils (assoc-ref inputs "coreutils"))
432 (sed (assoc-ref inputs "sed"))
433 (grep (assoc-ref inputs "grep"))
434 (util-linux (assoc-ref inputs "util-linux")))
435 (substitute* '("daemons/runttys.c" "daemons/getty.c" "utils/login.c")
437 (string-append out "/bin/login"))
438 (("/bin/bash") (string-append bash "/bin/bash")))
439 (substitute* '("startup/startup.c" "init/init.c" "config/ttys")
441 (string-append out "/libexec/")))
442 (substitute* '("utils/uptime.sh")
444 (string-append out "/bin/w")))
445 (substitute* "daemons/console-run.c"
447 (string-append out "/hurd/")))
449 (substitute* '("daemons/runsystem.sh"
450 "daemons/runsystem.hurd.sh"
453 (string-append "PATH=" out "/bin:" out "/sbin:"
455 sed "/bin:" grep "/bin:"
456 util-linux "/bin\n"))
458 (string-append "SHELL=" bash "/bin/bash\n"))
459 (("/sbin/") (string-append out "/sbin/"))
460 (("/libexec/") (string-append out "/libexec/"))
461 (("/hurd/") (string-append out "/hurd/")))
463 (substitute* "daemons/runsystem.sh"
465 (string-append "export PATH\n"
467 fsysopts / --writable
469 # MAKEDEV relies on pipes so this needs to be set up.
470 settrans -c /servers/socket/1 /hurd/pflocal
472 (cd /dev; MAKEDEV -D /dev std vcs tty{1,2,3,4,5,6})\n")))
474 (substitute* "daemons/runsystem.hurd.sh"
477 fsysopts / --writable\n"))
479 (add-after 'patch-shebangs 'patch-libexec-shebangs
480 (lambda* (#:key inputs outputs #:allow-other-keys)
481 ;; XXX: Since the 'patch-shebangs' phase doesn't traverse
482 ;; /libexec, do it here.
483 (let* ((out (assoc-ref outputs "out"))
484 (bash (assoc-ref inputs "bash-minimal"))
485 (path (list (string-append bash "/bin"))))
486 (for-each (lambda (file)
487 (patch-shebang file path))
488 (find-files (string-append out "/libexec")))
490 (add-after 'install 'install-goodies
491 (lambda* (#:key inputs outputs #:allow-other-keys)
492 ;; Install additional goodies.
493 ;; TODO: Build & install *.msgids for rpctrace.
494 (let* ((out (assoc-ref outputs "out"))
495 (datadir (string-append out "/share/hurd")))
496 ;; Install the fancy UTF-8 motd.
497 (mkdir-p (string-append out "/etc"))
498 (copy-file "console/motd.UTF8"
499 (string-append out "/etc/motd"))
501 ;; Install the BDF font for use by the console client.
502 (copy-file (assoc-ref inputs "unifont")
504 (invoke "gunzip" "unifont.gz")
507 (string-append datadir "/vga-system.bdf"))
509 (add-after 'install 'install-rc-file
510 (lambda* (#:key inputs outputs #:allow-other-keys)
511 (let* ((out (assoc-ref outputs "out"))
512 (file (string-append out "/libexec/rc"))
513 (rc (assoc-ref inputs "hurd-rc")))
519 #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
525 ;; This is needed to pass the configure check for
527 "ac_func_search_save_LIBS=-ltirpc"
528 "ac_cv_search_clnt_create=false")))
529 (build-system gnu-build-system)
531 `(("glibc-hurd-headers" ,glibc/hurd-headers)
532 ("hurd-rc" ,(hurd-rc-script))
534 ("libgcrypt" ,libgcrypt) ;for /hurd/random
535 ("libdaemon" ,libdaemon) ;for /bin/console --daemonize
537 ("libpciaccess" ,libpciaccess)
540 ("libtirpc" ,libtirpc/hurd)
542 ;; Tools for the /libexec/* scripts.
543 ("bash-minimal" ,bash-minimal)
544 ("coreutils" ,coreutils)
547 ("util-linux" ,util-linux)))
549 `(("autoconf" ,autoconf)
550 ("automake" ,automake)
551 ("libgcrypt" ,libgcrypt) ;for 'libgcrypt-config'
552 ("pkg-config" ,pkg-config)
553 ("mig" ,(if (%current-target-system)
554 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
558 (arguments `(#:system "i686-linux")))
561 ("texinfo" ,texinfo-4)
562 ("dde-sources" ,dde-sources)))
563 (supported-systems %hurd-systems)
564 (home-page "https://www.gnu.org/software/hurd/hurd.html")
565 (synopsis "The kernel servers for the GNU operating system")
567 "The Hurd is the kernel for the GNU system, a replacement and
568 augmentation of standard Unix kernels. It is a collection of protocols for
569 system interaction (file systems, networks, authentication), and servers
573 (define-public netdde
574 (let ((commit "4a1016f130b6f2065d3f088325e5fb0b2997ae12")
578 ;; The version prefix corresponds to the version of Linux from which the
579 ;; drivers were taken.
580 (version (git-version "2.6.32.65" revision commit))
584 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
588 "1njv9dszq4lj05yq4v9j5v247hfghpzvvz4hzy0khjjr35mw7hr8"))
589 (file-name (git-file-name name commit))))
590 (build-system gnu-build-system)
593 (list (string-append "SHELL=" (assoc-ref %build-inputs "bash")
595 "PKGDIR=libdde_linux26"
596 ,@(if (%current-target-system)
597 (list "CC=i586-pc-gnu-gcc"
598 "LINK_PROGRAM=i586-pc-gnu-gcc")
601 (list (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib"))
603 (modify-phases %standard-phases
605 (add-after 'unpack 'prepare-dde
606 (lambda* (#:key native-inputs inputs #:allow-other-keys)
607 (for-each make-file-writable (find-files "."))
608 (let ((dde (or (assoc-ref inputs "dde-sources")
609 (assoc-ref native-inputs "dde-sources"))))
610 (for-each (lambda (dir)
612 (string-append dde "/" dir ) dir))
613 '("libdde_linux26" "libddekit")))
614 (substitute* "libdde_linux26/mk/rel2abs.sh"
615 (("/bin/bash") (which "bash")))
617 (add-after 'patch-generated-file-shebangs 'build-libdde-linux26
618 (lambda* (#:key make-flags #:allow-other-keys)
619 (with-directory-excursion "libdde_linux26"
621 (delete "PKGDIR=libdde_linux26" make-flags)))))
622 (add-after 'build-libdde-linux26 'convert
623 (lambda* (#:key make-flags #:allow-other-keys)
624 (apply invoke "make" "convert" make-flags)))
626 (lambda* (#:key make-flags #:allow-other-keys)
627 ;; no-common can be dropped with GCC 10+ where this is the
629 (apply invoke "make" "CFLAGS=-fno-common" make-flags)))
631 (lambda* (#:key outputs #:allow-other-keys)
632 (install-file "netdde"
633 (string-append (assoc-ref outputs "out")
638 ("libpciaccess" ,libpciaccess)
641 `(("coreutils" ,coreutils)
646 ("dde-sources" ,dde-sources)))
647 (supported-systems %hurd-systems)
648 (home-page "https://www.gnu.org/software/hurd/hurd.html")
649 (synopsis "Linux network drivers glued by the DDE layer")
651 "This package provides Linux 2.6 network drivers that can be embedded
652 in userland processes thanks to the DDE layer.")
653 ;; Some drivers are dually licensed with the options being GPLv2 or one
654 ;; of MPL/Expat/BSD-3 (dependent on the driver).