1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu system hurd)
21 #:use-module (guix gexp)
22 #:use-module (guix profiles)
23 #:use-module (guix utils)
24 #:use-module (gnu bootloader grub)
25 #:use-module (gnu packages admin)
26 #:use-module (gnu packages base)
27 #:use-module (gnu packages bash)
28 #:use-module (gnu packages cross-base)
29 #:use-module (gnu packages file)
30 #:use-module (gnu packages guile)
31 #:use-module (gnu packages guile-xyz)
32 #:use-module (gnu packages hurd)
33 #:use-module (gnu packages less)
34 #:use-module (gnu system vm)
35 #:export (cross-hurd-image))
39 ;;; This module provides tools to (cross-)build GNU/Hurd virtual machine
44 ;; XXX: Surely this belongs in (guix profiles), but perhaps we need high-level
45 ;; <profile> objects so one can specify hooks, etc.?
46 (define-gexp-compiler (compile-manifest (manifest
47 (@@ (guix profiles) <manifest>))
49 "Lower MANIFEST as a profile."
50 (profile-derivation manifest
54 (define %base-packages/hurd
55 (list hurd bash coreutils file findutils grep sed
56 guile-3.0 guile-colorized guile-readline
57 net-base inetutils less which))
59 (define* (cross-hurd-image #:key (hurd hurd) (gnumach gnumach))
60 "Return a cross-built GNU/Hurd image."
62 (define (cross-built thing)
63 (with-parameters ((%current-target-system "i586-pc-gnu"))
66 (define (cross-built-entry entry)
69 (item (cross-built (manifest-entry-item entry)))
70 (dependencies (map cross-built-entry
71 (manifest-entry-dependencies entry)))))
73 (define system-profile
74 (map-manifest-entries cross-built-entry
75 (packages->manifest %base-packages/hurd)))
78 (let ((hurd (cross-built hurd))
79 (mach (with-parameters ((%current-system "i686-linux"))
81 (libc (cross-libc "i586-pc-gnu")))
82 (computed-file "grub.cfg"
83 #~(call-with-output-file #$output
87 search.file ~a/boot/gnumach
90 multiboot ~a/boot/gnumach root=device:hd0s1
91 module ~a/hurd/ext2fs.static ext2fs \\
92 --multiboot-command-line='${kernel-command-line}' \\
93 --host-priv-port='${host-port}' \\
94 --device-master-port='${device-port}' \\
95 --exec-server-task='${exec-task}' -T typed '${root}' \\
96 '$(task-create)' '$(task-resume)'
97 module ~a/lib/ld.so.1 exec ~a/hurd/exec '$(exec-task=task-create)'
104 "# This file was generated from your Guix configuration. Any changes
105 # will be lost upon reboot or reconfiguration.
107 /dev/hd0s1 / ext2 defaults
112 "root:x:0:0:root:/root:/bin/sh
113 guixbuilder:x:1:1:guixbuilder:/var/empty:/bin/no-sh
118 "guixbuild:x:1:guixbuilder
127 (plain-file "profile"
129 export PS1='\\u@\\h\\$ '
131 GUIX_PROFILE=\"/run/current-system/profile\"
132 . \"$GUIX_PROFILE/etc/profile\"
134 GUIX_PROFILE=\"$HOME/.guix-profile\"
135 if [ -f \"$GUIX_PROFILE/etc/profile\" ]; then
136 . \"$GUIX_PROFILE/etc/profile\"
139 (define hurd-directives
140 `((directory "/servers")
141 ,@(map (lambda (server)
142 `(file ,(string-append "/servers/" server)))
143 '("startup" "exec" "proc" "password"
144 "default-pager" "crash-dump-core"
146 ("/servers/crash" -> "crash-dump-core")
147 (directory "/servers/socket")
148 (file "/servers/socket/1")
149 (file "/servers/socket/2")
150 (file "/servers/socket/16")
151 ("/servers/socket/local" -> "1")
152 ("/servers/socket/inet" -> "2")
153 ("/servers/socket/inet6" -> "16")
155 ("/boot/grub.cfg" -> ,grub.cfg) ;XXX: not strictly needed
156 ("/hurd" -> ,(file-append (with-parameters ((%current-target-system
161 ;; TODO: Create those during activation, eventually.
166 (use-modules (ice-9 readline) (ice-9 colorized))
167 (activate-readline) (activate-colorized))))
169 (directory "/run/current-system")
170 ("/run/current-system/profile" -> ,system-profile)
171 ("/etc/profile" -> ,etc-profile)
172 ("/etc/fstab" -> ,fstab)
173 ("/etc/group" -> ,group)
174 ("/etc/passwd" -> ,passwd)
175 ("/etc/shadow" -> ,shadow)
176 (file "/etc/hostname" "guixygnu")
177 (file "/etc/resolv.conf"
178 "nameserver 10.0.2.3\n")
179 ("/etc/services" -> ,(file-append (with-parameters ((%current-target-system
183 ("/etc/protocols" -> ,(file-append (with-parameters ((%current-target-system
187 ("/etc/motd" -> ,(file-append (with-parameters ((%current-target-system
191 ("/etc/login" -> ,(file-append (with-parameters ((%current-target-system
197 ;; XXX can we instead, harmlessly set _PATH_TTYS (from glibc) in runttys.c?
198 ("/etc/ttys" -> ,(file-append (with-parameters ((%current-target-system
202 ("/bin/sh" -> ,(file-append (with-parameters ((%current-target-system
207 (qemu-image #:file-system-type "ext2"
208 #:file-system-options '("-o" "hurd")
210 #:inputs `(("system" ,system-profile)
211 ("grub.cfg" ,grub.cfg)
215 ("etc-profile" ,etc-profile)
219 #:bootcfg-drv grub.cfg
220 #:bootloader grub-bootloader
221 #:register-closures? #f
222 #:extra-directives hurd-directives))
224 ;; Return this thunk so one can type "guix build -f gnu/system/hurd.scm".