scripts: system: Accept <image> records as input.
[jackhill/guix/guix.git] / gnu / system / images / hurd.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
3 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
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.
11 ;;;
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.
16 ;;;
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/>.
19
20 (define-module (gnu system images hurd)
21 #:use-module (guix gexp)
22 #:use-module (gnu bootloader)
23 #:use-module (gnu bootloader grub)
24 #:use-module (gnu image)
25 #:use-module (gnu packages ssh)
26 #:use-module (gnu services)
27 #:use-module (gnu services ssh)
28 #:use-module (gnu system)
29 #:use-module (gnu system file-systems)
30 #:use-module (gnu system hurd)
31 #:use-module (gnu system image)
32 #:use-module (srfi srfi-26)
33 #:export (hurd-barebones-os
34 hurd-disk-image
35 hurd-image-type
36 hurd-qcow2-image-type
37 hurd-barebones-disk-image
38 hurd-barebones-qcow2-image))
39
40 (define hurd-barebones-os
41 (operating-system
42 (inherit %hurd-default-operating-system)
43 (bootloader (bootloader-configuration
44 (bootloader grub-minimal-bootloader)
45 (target "/dev/sdX")))
46 (file-systems (cons (file-system
47 (device (file-system-label "my-root"))
48 (mount-point "/")
49 (type "ext2"))
50 %base-file-systems))
51 (host-name "guixygnu")
52 (timezone "Europe/Amsterdam")
53 (packages (cons openssh-sans-x %base-packages/hurd))
54 (services (cons (service openssh-service-type
55 (openssh-configuration
56 (openssh openssh-sans-x)
57 (use-pam? #f)
58 (port-number 2222)
59 (permit-root-login #t)
60 (allow-empty-passwords? #t)
61 (password-authentication? #t)))
62 %base-services/hurd))))
63
64 (define hurd-initialize-root-partition
65 #~(lambda* (#:rest args)
66 (apply initialize-root-partition
67 (append args
68 (list #:make-device-nodes make-hurd-device-nodes
69 ;; XXX Creating a db.sqlite with journal_mode=WAL
70 ;; yields "unable to open database file" on GNU/Hurd
71 ;; for an sqlite with the hurd-locking-mode.patch;
72 ;; see <https://bugs.gnu.org/42151>.
73 #:wal-mode? #f)))))
74
75 (define hurd-disk-image
76 (image
77 (format 'disk-image)
78 (target "i586-pc-gnu")
79 (partitions
80 (list (partition
81 (size 'guess)
82 (offset root-offset)
83 (label root-label)
84 (file-system "ext2")
85 (file-system-options '("-o" "hurd" "-O" "ext_attr"))
86 (flags '(boot))
87 (initializer hurd-initialize-root-partition))))))
88
89 (define hurd-image-type
90 (image-type
91 (name 'hurd-raw)
92 (constructor (cut image-with-os hurd-disk-image <>))))
93
94 (define hurd-qcow2-image-type
95 (image-type
96 (name 'hurd-qcow2)
97 (constructor (lambda (os)
98 (image
99 (inherit hurd-disk-image)
100 (format 'compressed-qcow2)
101 (operating-system os))))))
102
103 (define hurd-barebones-disk-image
104 (image
105 (inherit
106 (os->image hurd-barebones-os #:type hurd-image-type))
107 (name 'hurd-barebones-disk-image)))
108
109 (define hurd-barebones-qcow2-image
110 (image
111 (inherit
112 (os->image hurd-barebones-os #:type hurd-qcow2-image-type))
113 (name 'hurd-barebones.qcow2)))
114
115 ;; Return the default image.
116 hurd-barebones-qcow2-image