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 profiles)
22 #:use-module (guix utils)
23 #:use-module (gnu bootloader grub)
24 #:use-module (gnu packages admin)
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages bash)
27 #:use-module (gnu packages cross-base)
28 #:use-module (gnu packages file)
29 #:use-module (gnu packages guile)
30 #:use-module (gnu packages guile-xyz)
31 #:use-module (gnu packages hurd)
32 #:use-module (gnu system vm)
33 #:export (cross-hurd-image))
37 ;;; This module provides tools to (cross-)build GNU/Hurd virtual machine
42 ;; XXX: Surely this belongs in (guix profiles), but perhaps we need high-level
43 ;; <profile> objects so one can specify hooks, etc.?
44 (define-gexp-compiler (compile-manifest (manifest
45 (@@ (guix profiles) <manifest>))
47 "Lower MANIFEST as a profile."
48 (profile-derivation manifest
52 (define %base-packages/hurd
53 (list hurd bash coreutils file findutils grep sed
54 guile-3.0 guile-colorized guile-readline
57 (define* (cross-hurd-image #:key (hurd hurd) (gnumach gnumach))
58 "Return a cross-built GNU/Hurd image."
60 (define (cross-built thing)
61 (with-parameters ((%current-target-system "i586-pc-gnu"))
64 (define (cross-built-entry entry)
67 (item (cross-built (manifest-entry-item entry)))
68 (dependencies (map cross-built-entry
69 (manifest-entry-dependencies entry)))))
71 (define system-profile
72 (map-manifest-entries cross-built-entry
73 (packages->manifest %base-packages/hurd)))
76 (let ((hurd (cross-built hurd))
77 (mach (with-parameters ((%current-system "i686-linux"))
79 (libc (cross-libc "i586-pc-gnu")))
80 (computed-file "grub.cfg"
81 #~(call-with-output-file #$output
85 search.file ~a/boot/gnumach
88 multiboot ~a/boot/gnumach root=device:hd0s1
89 module ~a/hurd/ext2fs.static ext2fs \\
90 --multiboot-command-line='${kernel-command-line}' \\
91 --host-priv-port='${host-port}' \\
92 --device-master-port='${device-port}' \\
93 --exec-server-task='${exec-task}' -T typed '${root}' \\
94 '$(task-create)' '$(task-resume)'
95 module ~a/lib/ld.so.1 exec ~a/hurd/exec '$(exec-task=task-create)'
102 "# This file was generated from your Guix configuration. Any changes
103 # will be lost upon reboot or reconfiguration.
105 /dev/hd0s1 / ext2 defaults
110 "root:x:0:0:root:/root:/bin/sh
119 (plain-file "profile"
121 export PS1='\\u@\\h\\$ '
123 GUIX_PROFILE=\"/run/current-system/profile\"
124 . \"$GUIX_PROFILE/etc/profile\"
126 GUIX_PROFILE=\"$HOME/.guix-profile\"
127 if [ -f \"$GUIX_PROFILE/etc/profile\" ]; then
128 . \"$GUIX_PROFILE/etc/profile\"
131 (define hurd-directives
132 `((directory "/servers")
133 ,@(map (lambda (server)
134 `(file ,(string-append "/servers/" server)))
135 '("startup" "exec" "proc" "password"
136 "default-pager" "crash-dump-core"
138 ("/servers/crash" -> "crash-dump-core")
139 (directory "/servers/socket")
140 (file "/servers/socket/1")
141 (file "/servers/socket/2")
142 (file "/servers/socket/16")
143 ("/servers/socket/local" -> "1")
144 ("/servers/socket/inet" -> "2")
145 ("/servers/socket/inet6" -> "16")
147 ("/boot/grub.cfg" -> ,grub.cfg) ;XXX: not strictly needed
148 ("/hurd" -> ,(file-append (with-parameters ((%current-target-system
153 ;; TODO: Create those during activation, eventually.
158 (use-modules (ice-9 readline) (ice-9 colorized))
159 (activate-readline) (activate-colorized))))
161 (directory "/run/current-system")
162 ("/run/current-system/profile" -> ,system-profile)
163 ("/etc/profile" -> ,etc-profile)
164 ("/etc/fstab" -> ,fstab)
165 ("/etc/passwd" -> ,passwd)
166 ("/etc/shadow" -> ,shadow)
167 (file "/etc/hostname" "guixygnu")
168 (file "/etc/resolv.conf"
169 "nameserver 10.0.2.3\n")
170 ("/etc/services" -> ,(file-append (with-parameters ((%current-target-system
174 ("/etc/protocols" -> ,(file-append (with-parameters ((%current-target-system
178 ("/etc/motd" -> ,(file-append (with-parameters ((%current-target-system
182 ("/etc/login" -> ,(file-append (with-parameters ((%current-target-system
188 ;; XXX can we instead, harmlessly set _PATH_TTYS (from glibc) in runttys.c?
189 ("/etc/ttys" -> ,(file-append (with-parameters ((%current-target-system
193 ("/bin/sh" -> ,(file-append (with-parameters ((%current-target-system
198 (qemu-image #:file-system-type "ext2"
199 #:file-system-options '("-o" "hurd")
201 #:inputs `(("system" ,system-profile)
202 ("grub.cfg" ,grub.cfg)
205 ("etc-profile" ,etc-profile)
209 #:bootcfg-drv grub.cfg
210 #:bootloader grub-bootloader
211 #:register-closures? #f
212 #:extra-directives hurd-directives))
214 ;; Return this thunk so one can type "guix build -f gnu/system/hurd.scm".