2020-04-01 14:18:23 +00:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
|
|
|
|
;;;
|
|
|
|
;;; 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)
|
|
|
|
#:use-module (guix utils)
|
|
|
|
#:use-module (gnu bootloader grub)
|
|
|
|
#: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-01 14:18:23 +00:00
|
|
|
#:use-module (gnu packages hurd)
|
|
|
|
#: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
|
|
|
|
(list hurd bash coreutils file findutils grep sed guile-3.0))
|
|
|
|
|
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
|
|
|
|
|
|
|
(define (for-hurd p)
|
|
|
|
(with-parameters ((%current-target-system "i586-pc-gnu")) p))
|
|
|
|
|
2020-04-01 14:18:23 +00:00
|
|
|
(define hurd-os
|
2020-04-08 06:04:52 +00:00
|
|
|
(directory-union "gnu+hurd"
|
|
|
|
(cons (with-parameters ((%current-system "i686-linux"))
|
|
|
|
gnumach)
|
|
|
|
(map for-hurd %base-packages/hurd))))
|
2020-04-01 14:18:23 +00:00
|
|
|
|
|
|
|
(define grub.cfg
|
|
|
|
(let ((hurd (with-parameters ((%current-target-system "i586-pc-gnu"))
|
|
|
|
hurd))
|
|
|
|
(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-08 06:04:52 +00:00
|
|
|
(define profile
|
|
|
|
(let ((packages (map for-hurd %base-packages/hurd)))
|
|
|
|
(computed-file
|
|
|
|
"profile"
|
|
|
|
#~(call-with-output-file #$output
|
|
|
|
(lambda (port)
|
|
|
|
(format port "
|
|
|
|
PATH=~a/bin:~a/sbin:~a/hurd
|
|
|
|
"
|
|
|
|
#+hurd-os #+hurd-os #+hurd-os))))))
|
|
|
|
|
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-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-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 06:04:52 +00:00
|
|
|
("/root/.profile" -> ,profile)
|
2020-04-05 11:51:56 +00:00
|
|
|
("/etc/fstab" -> ,fstab)
|
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")
|
|
|
|
|
|
|
|
("/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
|
|
|
|
#:inputs `(("system" ,hurd-os)
|
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 06:04:52 +00:00
|
|
|
("profile" ,profile)
|
2020-04-05 12:36:34 +00:00
|
|
|
("shadow" ,shadow))
|
2020-04-01 14:18:23 +00:00
|
|
|
#:copy-inputs? #t
|
|
|
|
#:os hurd-os
|
|
|
|
#: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
|