2020-04-01 14:18:23 +00:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
|
2020-04-08 07:46:40 +00:00
|
|
|
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2020-04-01 14:18:23 +00:00
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (gnu system hurd)
|
|
|
|
#:use-module (guix gexp)
|
2020-04-08 14:36:08 +00:00
|
|
|
#:use-module (guix profiles)
|
2020-04-01 14:18:23 +00:00
|
|
|
#:use-module (guix utils)
|
|
|
|
#:use-module (gnu bootloader grub)
|
2020-04-08 15:39:30 +00:00
|
|
|
#:use-module (gnu packages admin)
|
2020-04-01 14:18:23 +00:00
|
|
|
#:use-module (gnu packages base)
|
2020-04-05 15:16:30 +00:00
|
|
|
#:use-module (gnu packages bash)
|
2020-04-01 14:18:23 +00:00
|
|
|
#:use-module (gnu packages cross-base)
|
2020-04-08 06:04:52 +00:00
|
|
|
#:use-module (gnu packages file)
|
|
|
|
#:use-module (gnu packages guile)
|
2020-04-08 21:10:14 +00:00
|
|
|
#:use-module (gnu packages guile-xyz)
|
2020-04-01 14:18:23 +00:00
|
|
|
#:use-module (gnu packages hurd)
|
2020-04-14 08:16:21 +00:00
|
|
|
#:use-module (gnu packages less)
|
2020-04-01 14:18:23 +00:00
|
|
|
#:use-module (gnu system vm)
|
|
|
|
#:export (cross-hurd-image))
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;;
|
|
|
|
;;; This module provides tools to (cross-)build GNU/Hurd virtual machine
|
|
|
|
;;; images.
|
|
|
|
;;;
|
|
|
|
;;; Code:
|
|
|
|
|
2020-04-08 06:04:52 +00:00
|
|
|
(define %base-packages/hurd
|
2020-04-08 21:10:14 +00:00
|
|
|
(list hurd bash coreutils file findutils grep sed
|
|
|
|
guile-3.0 guile-colorized guile-readline
|
2020-04-14 08:16:21 +00:00
|
|
|
net-base inetutils less which))
|
2020-04-08 06:04:52 +00:00
|
|
|
|
2020-04-01 14:18:23 +00:00
|
|
|
(define* (cross-hurd-image #:key (hurd hurd) (gnumach gnumach))
|
|
|
|
"Return a cross-built GNU/Hurd image."
|
2020-04-08 06:04:52 +00:00
|
|
|
|
2020-04-08 14:36:08 +00:00
|
|
|
(define (cross-built thing)
|
|
|
|
(with-parameters ((%current-target-system "i586-pc-gnu"))
|
|
|
|
thing))
|
|
|
|
|
|
|
|
(define (cross-built-entry entry)
|
|
|
|
(manifest-entry
|
|
|
|
(inherit entry)
|
|
|
|
(item (cross-built (manifest-entry-item entry)))
|
|
|
|
(dependencies (map cross-built-entry
|
|
|
|
(manifest-entry-dependencies entry)))))
|
2020-04-08 06:04:52 +00:00
|
|
|
|
2020-04-08 14:36:08 +00:00
|
|
|
(define system-profile
|
2020-05-27 10:12:46 +00:00
|
|
|
(profile
|
|
|
|
(content
|
|
|
|
(map-manifest-entries cross-built-entry
|
|
|
|
(packages->manifest %base-packages/hurd)))))
|
2020-04-01 14:18:23 +00:00
|
|
|
|
|
|
|
(define grub.cfg
|
2020-04-08 14:36:08 +00:00
|
|
|
(let ((hurd (cross-built hurd))
|
2020-04-01 14:18:23 +00:00
|
|
|
(mach (with-parameters ((%current-system "i686-linux"))
|
|
|
|
gnumach))
|
|
|
|
(libc (cross-libc "i586-pc-gnu")))
|
|
|
|
(computed-file "grub.cfg"
|
|
|
|
#~(call-with-output-file #$output
|
|
|
|
(lambda (port)
|
|
|
|
(format port "
|
|
|
|
set timeout=2
|
|
|
|
search.file ~a/boot/gnumach
|
|
|
|
|
|
|
|
menuentry \"GNU\" {
|
|
|
|
multiboot ~a/boot/gnumach root=device:hd0s1
|
|
|
|
module ~a/hurd/ext2fs.static ext2fs \\
|
|
|
|
--multiboot-command-line='${kernel-command-line}' \\
|
|
|
|
--host-priv-port='${host-port}' \\
|
|
|
|
--device-master-port='${device-port}' \\
|
|
|
|
--exec-server-task='${exec-task}' -T typed '${root}' \\
|
|
|
|
'$(task-create)' '$(task-resume)'
|
|
|
|
module ~a/lib/ld.so.1 exec ~a/hurd/exec '$(exec-task=task-create)'
|
|
|
|
}\n"
|
|
|
|
#+mach #+mach #+hurd
|
|
|
|
#+libc #+hurd))))))
|
|
|
|
|
2020-04-05 06:39:20 +00:00
|
|
|
(define fstab
|
|
|
|
(plain-file "fstab"
|
2020-04-08 06:04:52 +00:00
|
|
|
"# This file was generated from your Guix configuration. Any changes
|
2020-04-05 06:39:20 +00:00
|
|
|
# will be lost upon reboot or reconfiguration.
|
|
|
|
|
|
|
|
/dev/hd0s1 / ext2 defaults
|
|
|
|
"))
|
|
|
|
|
2020-04-05 12:36:34 +00:00
|
|
|
(define passwd
|
|
|
|
(plain-file "passwd"
|
2020-04-08 06:04:52 +00:00
|
|
|
"root:x:0:0:root:/root:/bin/sh
|
2020-04-08 07:46:40 +00:00
|
|
|
guixbuilder:x:1:1:guixbuilder:/var/empty:/bin/no-sh
|
|
|
|
"))
|
|
|
|
|
|
|
|
(define group
|
|
|
|
(plain-file "group"
|
|
|
|
"guixbuild:x:1:guixbuilder
|
2020-04-08 06:04:52 +00:00
|
|
|
"))
|
2020-04-05 12:36:34 +00:00
|
|
|
|
|
|
|
(define shadow
|
|
|
|
(plain-file "shadow"
|
2020-04-08 06:04:52 +00:00
|
|
|
"root::0:0:0:0:::
|
|
|
|
"))
|
2020-04-05 12:36:34 +00:00
|
|
|
|
2020-04-08 14:36:08 +00:00
|
|
|
(define etc-profile
|
|
|
|
(plain-file "profile"
|
|
|
|
"\
|
|
|
|
export PS1='\\u@\\h\\$ '
|
|
|
|
|
|
|
|
GUIX_PROFILE=\"/run/current-system/profile\"
|
|
|
|
. \"$GUIX_PROFILE/etc/profile\"
|
|
|
|
|
|
|
|
GUIX_PROFILE=\"$HOME/.guix-profile\"
|
|
|
|
if [ -f \"$GUIX_PROFILE/etc/profile\" ]; then
|
|
|
|
. \"$GUIX_PROFILE/etc/profile\"
|
|
|
|
fi\n"))
|
|
|
|
|
2020-04-01 14:18:23 +00:00
|
|
|
(define hurd-directives
|
|
|
|
`((directory "/servers")
|
|
|
|
,@(map (lambda (server)
|
|
|
|
`(file ,(string-append "/servers/" server)))
|
|
|
|
'("startup" "exec" "proc" "password"
|
|
|
|
"default-pager" "crash-dump-core"
|
|
|
|
"kill" "suspend"))
|
|
|
|
("/servers/crash" -> "crash-dump-core")
|
|
|
|
(directory "/servers/socket")
|
|
|
|
(file "/servers/socket/1")
|
|
|
|
(file "/servers/socket/2")
|
|
|
|
(file "/servers/socket/16")
|
|
|
|
("/servers/socket/local" -> "1")
|
|
|
|
("/servers/socket/inet" -> "2")
|
|
|
|
("/servers/socket/inet6" -> "16")
|
|
|
|
(directory "/boot")
|
2020-04-08 06:04:52 +00:00
|
|
|
("/boot/grub.cfg" -> ,grub.cfg) ;XXX: not strictly needed
|
2020-04-01 14:18:23 +00:00
|
|
|
("/hurd" -> ,(file-append (with-parameters ((%current-target-system
|
|
|
|
"i586-pc-gnu"))
|
|
|
|
hurd)
|
2020-04-05 06:39:20 +00:00
|
|
|
"/hurd"))
|
2020-04-06 12:58:58 +00:00
|
|
|
|
|
|
|
;; TODO: Create those during activation, eventually.
|
|
|
|
(directory "/root")
|
2020-04-08 21:10:14 +00:00
|
|
|
(file "/root/.guile"
|
|
|
|
,(object->string
|
|
|
|
'(begin
|
|
|
|
(use-modules (ice-9 readline) (ice-9 colorized))
|
|
|
|
(activate-readline) (activate-colorized))))
|
2020-04-08 14:36:08 +00:00
|
|
|
(directory "/run")
|
|
|
|
(directory "/run/current-system")
|
|
|
|
("/run/current-system/profile" -> ,system-profile)
|
|
|
|
("/etc/profile" -> ,etc-profile)
|
2020-04-05 11:51:56 +00:00
|
|
|
("/etc/fstab" -> ,fstab)
|
2020-04-08 07:46:40 +00:00
|
|
|
("/etc/group" -> ,group)
|
2020-04-05 12:36:34 +00:00
|
|
|
("/etc/passwd" -> ,passwd)
|
|
|
|
("/etc/shadow" -> ,shadow)
|
2020-04-06 12:58:58 +00:00
|
|
|
(file "/etc/hostname" "guixygnu")
|
|
|
|
(file "/etc/resolv.conf"
|
|
|
|
"nameserver 10.0.2.3\n")
|
2020-04-08 15:39:30 +00:00
|
|
|
("/etc/services" -> ,(file-append (with-parameters ((%current-target-system
|
|
|
|
"i586-pc-gnu"))
|
|
|
|
net-base)
|
|
|
|
"/etc/services"))
|
|
|
|
("/etc/protocols" -> ,(file-append (with-parameters ((%current-target-system
|
|
|
|
"i586-pc-gnu"))
|
|
|
|
net-base)
|
|
|
|
"/etc/protocols"))
|
2020-04-06 12:58:58 +00:00
|
|
|
("/etc/motd" -> ,(file-append (with-parameters ((%current-target-system
|
|
|
|
"i586-pc-gnu"))
|
|
|
|
hurd)
|
|
|
|
"/etc/motd"))
|
|
|
|
("/etc/login" -> ,(file-append (with-parameters ((%current-target-system
|
2020-04-08 06:04:52 +00:00
|
|
|
"i586-pc-gnu"))
|
|
|
|
hurd)
|
2020-04-06 12:58:58 +00:00
|
|
|
"/etc/login"))
|
|
|
|
|
|
|
|
|
2020-04-05 11:51:56 +00:00
|
|
|
;; XXX can we instead, harmlessly set _PATH_TTYS (from glibc) in runttys.c?
|
|
|
|
("/etc/ttys" -> ,(file-append (with-parameters ((%current-target-system
|
2020-04-08 06:04:52 +00:00
|
|
|
"i586-pc-gnu"))
|
|
|
|
hurd)
|
|
|
|
"/etc/ttys"))
|
2020-04-05 15:16:30 +00:00
|
|
|
("/bin/sh" -> ,(file-append (with-parameters ((%current-target-system
|
|
|
|
"i586-pc-gnu"))
|
|
|
|
bash)
|
|
|
|
"/bin/sh"))))
|
2020-04-01 14:18:23 +00:00
|
|
|
|
|
|
|
(qemu-image #:file-system-type "ext2"
|
|
|
|
#:file-system-options '("-o" "hurd")
|
|
|
|
#:device-nodes 'hurd
|
2020-04-08 14:36:08 +00:00
|
|
|
#:inputs `(("system" ,system-profile)
|
2020-04-05 06:39:20 +00:00
|
|
|
("grub.cfg" ,grub.cfg)
|
2020-04-05 12:36:34 +00:00
|
|
|
("fstab" ,fstab)
|
|
|
|
("passwd" ,passwd)
|
2020-04-08 07:46:40 +00:00
|
|
|
("group" ,group)
|
2020-04-08 14:36:08 +00:00
|
|
|
("etc-profile" ,etc-profile)
|
2020-04-05 12:36:34 +00:00
|
|
|
("shadow" ,shadow))
|
2020-04-01 14:18:23 +00:00
|
|
|
#:copy-inputs? #t
|
2020-04-08 14:36:08 +00:00
|
|
|
#:os system-profile
|
2020-04-01 14:18:23 +00:00
|
|
|
#:bootcfg-drv grub.cfg
|
|
|
|
#:bootloader grub-bootloader
|
|
|
|
#:register-closures? #f
|
|
|
|
#:extra-directives hurd-directives))
|
|
|
|
|
|
|
|
;; Return this thunk so one can type "guix build -f gnu/system/hurd.scm".
|
|
|
|
cross-hurd-image
|