1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2018, 2020-2022 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, 2022 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?
53 (define (hurd-target?)
54 "Return true if the cross-compilation target or the current system is
56 (or (and=> (%current-target-system) target-hurd?)
57 (and (not (%current-target-system))
58 (and=> (%current-system) target-hurd?))))
60 (define (hurd-system?)
61 "Return true if the current system is the Hurd."
62 (and=> (%current-system) target-hurd?))
64 (define (hurd-source-url version)
65 (string-append "mirror://gnu/hurd/hurd-"
68 (define-public gnumach-headers
69 (let ((commit "097f9cf735ffa1212b828682ad92f0f6c5f1c552")
72 (name "gnumach-headers")
73 (version (git-version "1.8" revision commit))
78 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
80 (file-name (git-file-name "gnumach" version))
83 "0q36z7k02bykrld90zaxbhyzxlmwlqqs4divgir6ix38zsp6icqk"))))
84 (build-system gnu-build-system)
87 (modify-phases %standard-phases
90 (invoke "make" "install-data")))
93 ;; GNU Mach supports only IA32 currently, so cheat so that we can at
94 ;; least install its headers.
95 ,@(if (%current-target-system)
97 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-06/msg00042.html>
98 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-06/msg00716.html>
99 '(#:configure-flags '("--build=i586-pc-gnu"
100 "--host=i686-linux-gnu")))
104 (list autoconf automake texinfo-4))
105 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html")
106 (synopsis "GNU Mach kernel headers")
108 "Headers of the GNU Mach kernel.")
118 (uri (string-append "mirror://gnu/mig/mig-"
122 "1gyda8sq6b379nx01hkpbd85lz39irdvz2b9wbr63gicicx8i706"))))
123 (build-system gnu-build-system)
124 ;; Flex is needed both at build and run time.
125 (inputs (list gnumach-headers flex perl))
128 (arguments `(#:tests? #f
130 (modify-phases %standard-phases
131 (add-after 'install 'patch-non-shebang-references
132 (lambda* (#:key build inputs outputs #:allow-other-keys)
133 (let ((perl (assoc-ref inputs "perl"))
134 (out (assoc-ref outputs "out")))
135 (substitute* (string-append out "/bin/mig")
136 (("perl ") (string-append perl "/bin/perl ")))
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 mig/32-bit
150 ;; When cross-compiling from x86_64-linux to i586-gnu, we need this 32-bit
155 (substitute-keyword-arguments (package-arguments mig)
158 (properties `((hidden? . #t)))))
160 (define-public hurd-headers
161 ;; Resort to a post-0.9 snapshot that provides the 'file_utimens' and
162 ;; 'file_exec_paths' RPCs that glibc 2.28 expects.
164 (commit "91a51672ff4cfe1f1a0712b4c542ded3081c825b"))
166 (name "hurd-headers")
167 (version (git-version "0.9" revision commit))
171 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
175 "16k9wkahz9wasviijz53n6i13nmiwa9fs64ikf1jqh8rl60hw7cz"))
176 (file-name (git-file-name name version))))
177 (build-system gnu-build-system)
179 (list mig autoconf automake))
182 (modify-phases %standard-phases
185 (invoke "make" "install-headers" "no_deps=t")))
188 #:configure-flags '( ;; Pretend we're on GNU/Hurd; 'configure' wants
190 ,@(if (%current-target-system)
192 '("--host=i586-pc-gnu"))
194 ;; Reduce set of dependencies.
201 ;; Skip the clnt_create check because it expects
202 ;; a working glibc causing a circular dependency.
203 "ac_cv_search_clnt_create=no"
205 ;; Annihilate the checks for the 'file_exec_paths'
206 ;; & co. libc functions to avoid "link tests are
207 ;; not allowed after AC_NO_EXECUTABLES" error.
208 "ac_cv_func_file_exec_paths=no"
209 "ac_cv_func_exec_exec_paths=no"
210 "ac_cv_func__hurd_exec_paths=no"
211 "ac_cv_func_file_futimens=no")
214 (home-page "https://www.gnu.org/software/hurd/hurd.html")
215 (synopsis "GNU Hurd headers")
217 "This package provides C headers of the GNU Hurd, used to build the GNU C
218 Library and other user programs.")
221 (define-public hurd-minimal
222 (package (inherit hurd-headers)
223 (name "hurd-minimal")
224 (inputs (list glibc/hurd-headers))
226 (substitute-keyword-arguments (package-arguments hurd-headers)
228 '(modify-phases %standard-phases
230 (lambda* (#:key outputs #:allow-other-keys)
231 (let ((out (assoc-ref outputs "out")))
232 ;; We need to copy libihash.a to the output directory manually,
233 ;; since there is no target for that in the makefile.
234 (mkdir-p (string-append out "/include"))
235 (copy-file "libihash/ihash.h"
236 (string-append out "/include/ihash.h"))
237 (mkdir-p (string-append out "/lib"))
238 (copy-file "libihash/libihash.a"
239 (string-append out "/lib/libihash.a"))
243 ;; Install <assert-backtrace.h> & co.
244 (invoke "make" "-Clibshouldbeinlibc"
245 "../include/assert-backtrace.h")
248 (invoke "make" "-Clibihash" "libihash.a")))))))
249 (home-page "https://www.gnu.org/software/hurd/hurd.html")
250 (synopsis "GNU Hurd libraries")
252 "This package provides libihash, needed to build the GNU C
253 Library for GNU/Hurd.")
256 (define-public hurd-core-headers
258 (name "hurd-core-headers")
259 (version (package-version hurd-headers))
261 (build-system trivial-build-system)
263 '(#:modules ((guix build union))
265 (use-modules (srfi srfi-1)
269 (let ((inputs (filter
270 (compose (cute member <> '("gnumach-headers"
276 (((names . directories) ...)
277 (union-build (assoc-ref %outputs "out")
280 (inputs (list gnumach-headers hurd-headers hurd-minimal))
281 (synopsis "Union of the Hurd headers and libraries")
283 "This package contains the union of the Mach and Hurd headers and the
284 Hurd-minimal package which are needed for both glibc and GCC.")
285 (home-page (package-home-page hurd-headers))
286 (license (package-license hurd-headers))))
288 (define-public gnumach
290 (inherit gnumach-headers)
293 (substitute-keyword-arguments (package-arguments gnumach-headers)
294 ((#:make-flags flags ''())
295 `(cons "CFLAGS=-fcommon" ,flags))
296 ((#:configure-flags flags ''())
297 `(cons "--enable-kdb" ,flags)) ;enable kernel debugger
298 ((#:phases phases '%standard-phases)
299 `(modify-phases %standard-phases
300 (add-after 'install 'produce-image
301 (lambda* (#:key outputs #:allow-other-keys)
302 (let* ((out (assoc-ref outputs "out"))
303 (boot (string-append out "/boot")))
304 (invoke "make" "gnumach.gz")
305 (install-file "gnumach.gz" boot))))))))
307 (list mig perl autoconf automake texinfo-4))
308 (supported-systems (cons "i686-linux" %hurd-systems))
309 (synopsis "Microkernel of the GNU system")
311 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
314 ;; GNU Unifont, <http://gnu.org/s/unifont>.
315 ;; Used the the VGA driver of the Hurd's console client.
319 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
322 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
325 ;; This is the current tip of the dde branch
326 (let ((commit "ac1c7eb7a8b24b7469bed5365be38a968d59a136"))
330 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
334 "1vryinbg75xpydfrv9dbgfnds6knlh8l8bk2rxp32y9dc58z0692"))
335 (file-name (git-file-name "dde" commit)))))
340 (version (package-version hurd-headers))
341 (source (origin (inherit (package-source hurd-headers))
342 (patches (search-patches "hurd-cross.patch"
343 "hurd-xattr.patch"))))
346 (modify-phases %standard-phases
347 (add-after 'unpack 'prepare-dde
348 (lambda* (#:key native-inputs inputs #:allow-other-keys)
349 (substitute* "Makefile"
351 "libbpf libmachdev libmachdevdde libddekit"))
352 (for-each make-file-writable (find-files "."))
353 (let ((dde (or (assoc-ref inputs "dde-sources")
354 (assoc-ref native-inputs "dde-sources"))))
355 (for-each (lambda (dir)
357 (string-append dde "/" dir ) dir))
358 '("libmachdev" "libmachdevdde" "libddekit")))
360 (add-after 'unpack 'find-tirpc
361 (lambda* (#:key inputs #:allow-other-keys)
362 (for-each (lambda (var)
365 (search-input-directory inputs
367 ":" (or (getenv var) ""))))
368 '("CROSS_C_INCLUDE_PATH" "C_INCLUDE_PATH"
369 "CROSS_CPATH" "CPATH"))
371 (add-after 'unpack 'fix-rpc-headers
373 (substitute* "nfs/mount.c"
374 (("#undef (TRUE|FALSE)") "")
375 (("#include <rpc/pmap_prot.h>" m)
376 (string-append "#include <rpc/xdr.h>\n" m)))
377 (substitute* '("nfsd/cache.c")
378 (("#undef (TRUE|FALSE)") ""))
379 (substitute* '("nfsd/loop.c"
382 (("#include <rpc/pmap_prot.h>" m)
383 (string-append "#include <rpc/types.h>\n#include <rpc/xdr.h>\n" m)))
385 (add-before 'build 'pre-build
387 ;; Don't change the ownership of any file at this time.
388 (substitute* '("daemons/Makefile" "utils/Makefile")
389 (("-o root -m 4755") ""))
391 (add-after 'unpack 'create-runsystem
393 ;; XXX Work towards having startup.c invoke the Guile rc
394 (delete-file "daemons/runsystem.sh")
395 (with-output-to-file "daemons/runsystem.sh"
397 (display "#! /bin/bash
399 # XXX Guile needs pipe support for its finalizer thread, to start.
400 # Remove this script when Linux and the Hurd have xattr patches.
404 fsysopts / --writable
406 # Note: this /hurd/ gets substituted
407 settrans --create /servers/socket/1 /hurd/pflocal
409 # parse multiboot arguments
413 system=${i#gnu.system=}
418 echo Starting ${system}/rc...
419 exec ${system}/rc \"$@\"
421 (add-before 'build 'set-file-names
422 (lambda* (#:key inputs outputs #:allow-other-keys)
423 (let* ((out (assoc-ref outputs "out"))
424 (bash (assoc-ref inputs "bash-minimal"))
425 (coreutils (assoc-ref inputs "coreutils"))
426 (sed (assoc-ref inputs "sed"))
427 (grep (assoc-ref inputs "grep"))
428 (util-linux (assoc-ref inputs "util-linux")))
429 (substitute* '("daemons/runttys.c" "daemons/getty.c" "utils/login.c")
431 (string-append out "/bin/login"))
432 (("/bin/bash") (string-append bash "/bin/bash")))
433 (substitute* '("startup/startup.c" "config/ttys")
435 (string-append out "/libexec/")))
436 (substitute* '("utils/uptime.sh")
438 (string-append out "/bin/w")))
439 ;; Upon first boot the /hurd symlink does not exist; it is
440 ;; created during activation: Hard-code the .../hurd store file
442 (substitute* '("boot/boot.c"
443 "daemons/console-run.c"
446 (string-append out "/hurd/")))
447 (substitute* '("libdiskfs/boot-start.c"
448 "libdiskfs/opts-std-startup.c")
450 (string-append "\"" out "/hurd/startup\"")))
451 (substitute* '("daemons/runsystem.sh"
457 (string-append "PATH=" out "/bin"
462 ":" util-linux "/sbin\n"))
463 (("/sbin/") (string-append out "/sbin/"))
464 (("/libexec/") (string-append out "/libexec/"))
465 (("/hurd/") (string-append out "/hurd/")))
467 (add-after 'patch-shebangs 'patch-libexec-shebangs
468 (lambda* (#:key inputs outputs #:allow-other-keys)
469 ;; XXX: Since the 'patch-shebangs' phase doesn't traverse
470 ;; /libexec, do it here.
471 (let* ((out (assoc-ref outputs "out"))
472 (bash (assoc-ref inputs "bash-minimal"))
473 (path (list (string-append bash "/bin"))))
474 (for-each (lambda (file)
475 (patch-shebang file path))
476 (find-files (string-append out "/libexec")))
478 (add-after 'install 'install-goodies
479 (lambda* (#:key inputs outputs #:allow-other-keys)
480 ;; Install additional goodies.
481 ;; TODO: Build & install *.msgids for rpctrace.
482 (let* ((out (assoc-ref outputs "out"))
483 (datadir (string-append out "/share/hurd")))
484 ;; Install the fancy UTF-8 motd.
485 (mkdir-p (string-append out "/etc"))
486 (copy-file "console/motd.UTF8"
487 (string-append out "/etc/motd"))
489 ;; Install the BDF font for use by the console client.
490 (copy-file (assoc-ref inputs "unifont")
492 (invoke "gunzip" "unifont.gz")
495 (string-append datadir "/vga-system.bdf"))
498 ,#~(list (string-append "LDFLAGS=-Wl,-rpath="
504 ;; This is needed to pass the configure check for
506 "ac_func_search_save_LIBS=-ltirpc"
507 "ac_cv_search_clnt_create=false"
509 (build-system gnu-build-system)
511 `(("glibc-hurd-headers" ,glibc/hurd-headers)
513 ("libgcrypt" ,libgcrypt) ;for /hurd/random
514 ("libdaemon" ,libdaemon) ;for /bin/console --daemonize
516 ("libpciaccess" ,libpciaccess)
519 ("libtirpc" ,libtirpc/hurd)
521 ;; Tools for the /libexec/* scripts.
522 ("bash-minimal" ,bash-minimal)
523 ("coreutils" ,coreutils)
526 ("util-linux" ,util-linux)))
528 `(("autoconf" ,autoconf)
529 ("automake" ,automake)
530 ("libgcrypt" ,libgcrypt) ;for 'libgcrypt-config'
531 ("pkg-config" ,pkg-config)
532 ("mig" ,(if (%current-target-system)
533 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
538 ("texinfo" ,texinfo-4)
539 ("dde-sources" ,dde-sources)))
540 (supported-systems %hurd-systems)
541 (home-page "https://www.gnu.org/software/hurd/hurd.html")
542 (synopsis "The kernel servers for the GNU operating system")
544 "The Hurd is the kernel for the GNU system, a replacement and
545 augmentation of standard Unix kernels. It is a collection of protocols for
546 system interaction (file systems, networks, authentication), and servers
550 (define-public netdde
551 (let ((commit "4a1016f130b6f2065d3f088325e5fb0b2997ae12")
555 ;; The version prefix corresponds to the version of Linux from which the
556 ;; drivers were taken.
557 (version (git-version "2.6.32.65" revision commit))
561 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
565 "1njv9dszq4lj05yq4v9j5v247hfghpzvvz4hzy0khjjr35mw7hr8"))
566 (file-name (git-file-name name commit))))
567 (build-system gnu-build-system)
570 (list (string-append "SHELL="
571 (search-input-file %build-inputs "/bin/bash"))
572 "PKGDIR=libdde_linux26"
573 ,@(if (%current-target-system)
574 (list "CC=i586-pc-gnu-gcc"
575 "LINK_PROGRAM=i586-pc-gnu-gcc")
578 ,#~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib"))
580 (modify-phases %standard-phases
582 (add-after 'unpack 'prepare-dde
583 (lambda* (#:key native-inputs inputs #:allow-other-keys)
584 (for-each make-file-writable (find-files "."))
585 (let ((dde (or (assoc-ref inputs "dde-sources")
586 (assoc-ref native-inputs "dde-sources"))))
587 (for-each (lambda (dir)
589 (string-append dde "/" dir ) dir))
590 '("libdde_linux26" "libddekit")))
591 (substitute* "libdde_linux26/mk/rel2abs.sh"
592 (("/bin/bash") (which "bash")))
594 (add-after 'patch-generated-file-shebangs 'build-libdde-linux26
595 (lambda* (#:key make-flags #:allow-other-keys)
596 (with-directory-excursion "libdde_linux26"
598 (delete "PKGDIR=libdde_linux26" make-flags)))))
599 (add-after 'build-libdde-linux26 'convert
600 (lambda* (#:key make-flags #:allow-other-keys)
601 (apply invoke "make" "convert" make-flags)))
603 (lambda* (#:key make-flags #:allow-other-keys)
604 ;; no-common can be dropped with GCC 10+ where this is the
606 (apply invoke "make" "CFLAGS=-fno-common" make-flags)))
608 (lambda* (#:key outputs #:allow-other-keys)
609 (install-file "netdde"
610 (string-append (assoc-ref outputs "out")
614 (list hurd libpciaccess zlib))
616 `(("coreutils" ,coreutils)
621 ("dde-sources" ,dde-sources)))
622 (supported-systems %hurd-systems)
623 (home-page "https://www.gnu.org/software/hurd/hurd.html")
624 (synopsis "Linux network drivers glued by the DDE layer")
626 "This package provides Linux 2.6 network drivers that can be embedded
627 in userland processes thanks to the DDE layer.")
628 ;; Some drivers are dually licensed with the options being GPLv2 or one
629 ;; of MPL/Expat/BSD-3 (dependent on the driver).