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>
9 ;;; This file is part of GNU Guix.
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.
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.
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/>.
24 (define-module (gnu packages hurd)
25 #:use-module (guix licenses)
26 #:use-module (guix download)
27 #:use-module (guix packages)
28 #:use-module (gnu packages)
29 #:use-module (guix gexp)
30 #:use-module (guix utils)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system trivial)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages flex)
35 #:use-module (gnu packages gnupg)
36 #:use-module (gnu packages bison)
37 #:use-module (gnu packages libdaemon)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages base)
42 #:use-module (gnu packages bash)
43 #:use-module (gnu packages texinfo)
44 #:use-module (gnu packages xorg) ; libpciaccess
45 #:use-module (guix git-download)
46 #:export (hurd-system?
50 (define (hurd-triplet? triplet)
51 (and (string-suffix? "-gnu" triplet)
52 (not (string-contains triplet "linux"))))
54 (define (hurd-target?)
55 "Return true if the cross-compilation target or the current system is
57 (or (and=> (%current-target-system) hurd-triplet?)
58 (and (not (%current-target-system))
59 (and=> (%current-system) hurd-triplet?))))
61 (define (hurd-system?)
62 "Return true if the current system is the Hurd."
63 (and=> (%current-system) hurd-triplet?))
65 (define (hurd-source-url version)
66 (string-append "mirror://gnu/hurd/hurd-"
69 (define-public gnumach-headers
70 (let ((commit "097f9cf735ffa1212b828682ad92f0f6c5f1c552")
73 (name "gnumach-headers")
74 (version (git-version "1.8" revision commit))
79 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
81 (file-name (git-file-name "gnumach" version))
84 "0q36z7k02bykrld90zaxbhyzxlmwlqqs4divgir6ix38zsp6icqk"))))
85 (build-system gnu-build-system)
88 (modify-phases %standard-phases
91 (invoke "make" "install-data")))
94 ;; GNU Mach supports only IA32 currently, so cheat so that we can at
95 ;; least install its headers.
96 ,@(if (%current-target-system)
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")))
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")
111 "Headers of the GNU Mach kernel.")
121 (uri (string-append "mirror://gnu/mig/mig-"
125 "1gyda8sq6b379nx01hkpbd85lz39irdvz2b9wbr63gicicx8i706"))))
126 (build-system gnu-build-system)
127 ;; Flex is needed both at build and run time.
128 (inputs `(("gnumach-headers" ,gnumach-headers)
133 (arguments `(#:tests? #f))
134 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/mig/gnu_mig.html")
135 (synopsis "Mach 3.0 interface generator for the Hurd")
137 "GNU MIG is the GNU distribution of the Mach 3.0 interface generator
138 MIG, as maintained by the GNU Hurd developers for the GNU project.
139 You need this tool to compile the GNU Mach and GNU Hurd distributions,
140 and to compile the GNU C library for the Hurd. Also, you will need it
141 for other software in the GNU system that uses Mach-based inter-process
145 (define-public hurd-headers
146 ;; Resort to a post-0.9 snapshot that provides the 'file_utimens' and
147 ;; 'file_exec_paths' RPCs that glibc 2.28 expects.
149 (commit "91a51672ff4cfe1f1a0712b4c542ded3081c825b"))
151 (name "hurd-headers")
152 (version (git-version "0.9" revision commit))
156 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
160 "16k9wkahz9wasviijz53n6i13nmiwa9fs64ikf1jqh8rl60hw7cz"))
161 (file-name (git-file-name name version))))
162 (build-system gnu-build-system)
165 ("autoconf" ,autoconf)
166 ("automake" ,automake)))
169 (modify-phases %standard-phases
172 (invoke "make" "install-headers" "no_deps=t")))
175 #:configure-flags '( ;; Pretend we're on GNU/Hurd; 'configure' wants
177 ,@(if (%current-target-system)
179 '("--host=i586-pc-gnu"))
181 ;; Reduce set of dependencies.
188 ;; Skip the clnt_create check because it expects
189 ;; a working glibc causing a circular dependency.
190 "ac_cv_search_clnt_create=no"
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")
201 (home-page "https://www.gnu.org/software/hurd/hurd.html")
202 (synopsis "GNU Hurd headers")
204 "This package provides C headers of the GNU Hurd, used to build the GNU C
205 Library and other user programs.")
208 (define-public hurd-minimal
209 (package (inherit hurd-headers)
210 (name "hurd-minimal")
211 (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers)))
213 (substitute-keyword-arguments (package-arguments hurd-headers)
215 '(modify-phases %standard-phases
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"))
230 ;; Install <assert-backtrace.h> & co.
231 (invoke "make" "-Clibshouldbeinlibc"
232 "../include/assert-backtrace.h")
235 (invoke "make" "-Clibihash" "libihash.a")))))))
236 (home-page "https://www.gnu.org/software/hurd/hurd.html")
237 (synopsis "GNU Hurd libraries")
239 "This package provides libihash, needed to build the GNU C
240 Library for GNU/Hurd.")
243 (define-public hurd-core-headers
245 (name "hurd-core-headers")
246 (version (package-version hurd-headers))
248 (build-system trivial-build-system)
250 '(#:modules ((guix build union))
252 (use-modules (ice-9 match)
255 (((names . directories) ...)
256 (union-build (assoc-ref %outputs "out")
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")
264 "This package contains the union of the Mach and Hurd headers and the
265 Hurd-minimal package which are needed for both glibc and GCC.")
266 (home-page (package-home-page hurd-headers))
267 (license (package-license hurd-headers))))
269 (define-public gnumach
271 (inherit gnumach-headers)
274 (substitute-keyword-arguments (package-arguments gnumach-headers)
275 ((#:configure-flags flags ''())
276 `(cons "--enable-kdb" ,flags)) ;enable kernel debugger
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)
289 ("autoconf" ,autoconf)
290 ("automake" ,automake)
291 ("texinfo" ,texinfo-4)))
292 (supported-systems (cons "i686-linux" %hurd-systems))
293 (synopsis "Microkernel of the GNU system")
295 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
298 ;; GNU Unifont, <http://gnu.org/s/unifont>.
299 ;; Used the the VGA driver of the Hurd's console client.
303 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
306 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
308 (define (hurd-rc-script)
309 "Return a script to be installed as /libexec/rc in the 'hurd' package. The
310 script takes care of installing the relevant passive translators on the first
311 boot, since this cannot be done from GNU/Linux."
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"))))
325 (with-imported-modules '((guix build utils))
327 (use-modules (guix build utils)
330 ;; "@HURD@" is a placeholder.
331 (setenv "PATH" "@HURD@/bin")
333 (define (translated? node)
334 ;; Return true if a translator is installed on NODE.
335 (with-output-to-port (%make-void-port "w")
337 (with-error-to-port (%make-void-port "w")
339 (zero? (system* "showtrans" "-s" node)))))))
341 (for-each (match-lambda
343 (unless (translated? node)
344 (mkdir-p (dirname node))
345 (apply invoke "settrans" "-c" node command))))
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"))))
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)))
359 ;; This is the current tip of the dde branch
360 (let ((commit "ac1c7eb7a8b24b7469bed5365be38a968d59a136"))
364 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
368 "1vryinbg75xpydfrv9dbgfnds6knlh8l8bk2rxp32y9dc58z0692"))
369 (file-name (git-file-name "dde" commit)))))
374 (version (package-version hurd-headers))
375 (source (origin (inherit (package-source hurd-headers))
376 (patches (search-patches "hurd-cross.patch"))))
379 (modify-phases %standard-phases
380 (add-after 'unpack 'prepare-dde
381 (lambda* (#:key native-inputs inputs #:allow-other-keys)
382 (substitute* "Makefile"
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)
390 (string-append dde "/" dir ) dir))
391 '("libmachdev" "libmachdevdde" "libddekit")))
393 (add-before 'build 'pre-build
395 ;; Don't change the ownership of any file at this time.
396 (substitute* '("daemons/Makefile" "utils/Makefile")
397 (("-o root -m 4755") ""))
399 (add-before 'build 'set-file-names
400 (lambda* (#:key inputs outputs #:allow-other-keys)
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")
409 (string-append out "/bin/login"))
410 (("/bin/bash") (string-append bash "/bin/bash")))
411 (substitute* '("startup/startup.c" "init/init.c" "config/ttys")
413 (string-append out "/libexec/")))
414 (substitute* "daemons/console-run.c"
416 (string-append out "/hurd/")))
418 (substitute* '("daemons/runsystem.sh"
419 "daemons/runsystem.hurd.sh"
422 (string-append "PATH=" out "/bin:" out "/sbin:"
424 sed "/bin:" grep "/bin:"
425 util-linux "/bin\n"))
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/")))
432 (substitute* "daemons/runsystem.sh"
434 (string-append "export PATH\n"
436 fsysopts / --writable
438 # MAKEDEV relies on pipes so this needs to be set up.
439 settrans -c /servers/socket/1 /hurd/pflocal
441 (cd /dev; MAKEDEV -D /dev std vcs tty{1,2,3,4,5,6})\n")))
443 (substitute* "daemons/runsystem.hurd.sh"
446 fsysopts / --writable\n"))
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")))
459 (add-after 'install 'install-goodies
460 (lambda* (#:key inputs outputs #:allow-other-keys)
461 ;; Install additional goodies.
462 ;; TODO: Build & install *.msgids for rpctrace.
463 (let* ((out (assoc-ref outputs "out"))
464 (datadir (string-append out "/share/hurd")))
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"))
470 ;; Install the BDF font for use by the console client.
471 (copy-file (assoc-ref inputs "unifont")
473 (invoke "gunzip" "unifont.gz")
476 (string-append datadir "/vga-system.bdf"))
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")))
488 #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
493 "--without-parted")))
494 (build-system gnu-build-system)
496 `(("glibc-hurd-headers" ,glibc/hurd-headers)
497 ("hurd-rc" ,(hurd-rc-script))
499 ("libgcrypt" ,libgcrypt) ;for /hurd/random
500 ("libdaemon" ,libdaemon) ;for /bin/console --daemonize
502 ("libpciaccess" ,libpciaccess)
504 ;; Tools for the /libexec/* scripts.
505 ("bash-minimal" ,bash-minimal)
506 ("coreutils" ,coreutils)
509 ("util-linux" ,util-linux)))
511 `(("autoconf" ,autoconf)
512 ("automake" ,automake)
513 ("libgcrypt" ,libgcrypt) ;for 'libgcrypt-config'
514 ("pkg-config" ,pkg-config)
515 ("mig" ,(if (%current-target-system)
516 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
520 (arguments `(#:system "i686-linux")))
523 ("texinfo" ,texinfo-4)
524 ("dde-sources" ,dde-sources)))
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")
529 "The Hurd is the kernel for the GNU system, a replacement and
530 augmentation of standard Unix kernels. It is a collection of protocols for
531 system interaction (file systems, networks, authentication), and servers