1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu system hurd)
20 #:use-module (guix gexp)
21 #:use-module (guix utils)
22 #:use-module (gnu bootloader grub)
23 #:use-module (gnu packages base)
24 #:use-module (gnu packages cross-base)
25 #:use-module (gnu packages hurd)
26 #:use-module (gnu system vm)
27 #:export (cross-hurd-image))
31 ;;; This module provides tools to (cross-)build GNU/Hurd virtual machine
36 (define* (cross-hurd-image #:key (hurd hurd) (gnumach gnumach))
37 "Return a cross-built GNU/Hurd image."
39 (let-syntax ((for-hurd (syntax-rules ()
41 (list (with-parameters ((%current-target-system
44 (directory-union "gnu+hurd"
45 (cons (with-parameters ((%current-system "i686-linux"))
47 (for-hurd hurd coreutils grep sed)))))
50 (let ((hurd (with-parameters ((%current-target-system "i586-pc-gnu"))
52 (mach (with-parameters ((%current-system "i686-linux"))
54 (libc (cross-libc "i586-pc-gnu")))
55 (computed-file "grub.cfg"
56 #~(call-with-output-file #$output
60 search.file ~a/boot/gnumach
63 multiboot ~a/boot/gnumach root=device:hd0s1
64 module ~a/hurd/ext2fs.static ext2fs \\
65 --multiboot-command-line='${kernel-command-line}' \\
66 --host-priv-port='${host-port}' \\
67 --device-master-port='${device-port}' \\
68 --exec-server-task='${exec-task}' -T typed '${root}' \\
69 '$(task-create)' '$(task-resume)'
70 module ~a/lib/ld.so.1 exec ~a/hurd/exec '$(exec-task=task-create)'
77 "# This file was generated from your Guix configuration. Any changes
78 # will be lost upon reboot or reconfiguration.
80 /dev/hd0s1 / ext2 defaults
85 "root:x:0:0:root:/root:/bin/sh
95 (define hurd-directives
96 `((directory "/servers")
97 ,@(map (lambda (server)
98 `(file ,(string-append "/servers/" server)))
99 '("startup" "exec" "proc" "password"
100 "default-pager" "crash-dump-core"
102 ("/servers/crash" -> "crash-dump-core")
103 (directory "/servers/socket")
104 (file "/servers/socket/1")
105 (file "/servers/socket/2")
106 (file "/servers/socket/16")
107 ("/servers/socket/local" -> "1")
108 ("/servers/socket/inet" -> "2")
109 ("/servers/socket/inet6" -> "16")
110 (file "/etc/resolv.conf"
111 "nameserver 10.0.2.3\n")
113 ("/boot/grub.cfg" -> ,grub.cfg) ;XXX: not strictly needed
114 ("/hurd" -> ,(file-append (with-parameters ((%current-target-system
118 ("/etc/fstab" -> ,fstab)
119 ("/etc/passwd" -> ,passwd)
120 ("/etc/shadow" -> ,shadow)
121 ;; XXX can we instead, harmlessly set _PATH_TTYS (from glibc) in runttys.c?
122 ("/etc/ttys" -> ,(file-append (with-parameters ((%current-target-system
127 (qemu-image #:file-system-type "ext2"
128 #:file-system-options '("-o" "hurd")
130 #:inputs `(("system" ,hurd-os)
131 ("grub.cfg" ,grub.cfg)
137 #:bootcfg-drv grub.cfg
138 #:bootloader grub-bootloader
139 #:register-closures? #f
140 #:extra-directives hurd-directives))
142 ;; Return this thunk so one can type "guix build -f gnu/system/hurd.scm".