projects/guix·blob python-team · refs

2163 lines · 80.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016-2023, 2025 Ludovic Courtès <[email protected]>
3;;; Copyright © 2017, 2019, 2021 Tobias Geerinckx-Rice <[email protected]>
4;;; Copyright © 2020 Mathieu Othacehe <[email protected]>
5;;; Copyright © 2020 Danny Milosavljevic <[email protected]>
6;;; Copyright © 2020, 2024 Janneke Nieuwenhuizen <[email protected]>
7;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <[email protected]>
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24;;; Commentary:
25;;;
26;;; Test the installation of Guix using the documented approach at the
27;;; command line.
28;;;
29;;; Code:
30
31(define-module (gnu tests install)
32 #:use-module (gnu)
33 #:use-module (gnu bootloader extlinux)
34 #:use-module (gnu image)
35 #:use-module (gnu tests)
36 #:use-module (gnu tests base)
37 #:use-module (gnu system)
38 #:use-module (gnu system image)
39 #:use-module (gnu system install)
40 #:use-module (gnu system vm)
41 #:use-module ((gnu build marionette) #:select (qemu-command))
42 #:use-module (gnu packages admin)
43 #:use-module (gnu packages bootloaders)
44 #:use-module (gnu packages commencement) ;for 'guile-final'
45 #:use-module (gnu packages cpio)
46 #:use-module (gnu packages cryptsetup)
47 #:use-module (gnu packages disk)
48 #:use-module (gnu packages emacs)
49 #:use-module (gnu packages emacs-xyz)
50 #:use-module (gnu packages firmware)
51 #:use-module (gnu packages fonts)
52 #:use-module (gnu packages guile)
53 #:use-module (gnu packages linux)
54 #:use-module (gnu packages ocr)
55 #:use-module (gnu packages package-management)
56 #:use-module (gnu packages ratpoison)
57 #:use-module (gnu packages suckless)
58 #:use-module (gnu packages terminals)
59 #:use-module (gnu packages virtualization)
60 #:use-module (gnu packages window-management)
61 #:use-module (gnu packages xorg)
62 #:use-module (gnu services desktop)
63 #:use-module (gnu services networking)
64 #:use-module (gnu services shepherd)
65 #:use-module (gnu services xorg)
66 #:use-module (guix store)
67 #:use-module (guix monads)
68 #:use-module (guix packages)
69 #:use-module (guix grafts)
70 #:use-module (guix gexp)
71 #:use-module (guix utils)
72 #:use-module (srfi srfi-1)
73 #:export (%test-installed-os
74 %test-installed-extlinux-os
75 %test-iso-image-installer
76 %test-separate-store-os
77 %test-separate-home-os
78 %test-raid-root-os
79 %test-encrypted-root-os
80 %test-encrypted-root-extra-options-os
81 %test-encrypted-home-os
82 %test-encrypted-home-os-key-file
83 %test-encrypted-root-not-boot-os
84 %test-btrfs-root-os
85 %test-btrfs-root-on-subvolume-os
86 %test-btrfs-raid-root-os
87 %test-btrfs-raid10-root-os
88 %test-btrfs-raid10-root-os-degraded
89 %test-jfs-root-os
90 %test-f2fs-root-os
91 %test-xfs-root-os
92 %test-lvm-separate-home-os
93
94 %test-gui-installed-os
95 %test-gui-uefi-installed-os
96 %test-gui-installed-os-encrypted
97 %test-gui-installed-desktop-os-encrypted))
98
99(define-os-with-source (%minimal-os %minimal-os-source)
100 ;; The OS we want to install.
101 (use-modules (gnu) (gnu tests) (srfi srfi-1))
102
103 (operating-system
104 (host-name "liberigilo")
105 (timezone "Europe/Paris")
106 (locale "en_US.UTF-8")
107
108 (bootloader (bootloader-configuration
109 (bootloader grub-bootloader)
110 (targets (list "/dev/vdb"))))
111 (kernel-arguments '("console=ttyS0"))
112 (file-systems (cons (file-system
113 (device (file-system-label "my-root"))
114 (mount-point "/")
115 (type "ext4"))
116 %base-file-systems))
117 (users (cons (user-account
118 (name "alice")
119 (comment "Bob's sister")
120 (group "users")
121 (supplementary-groups '("wheel" "audio" "video")))
122 %base-user-accounts))
123 (services (cons (service marionette-service-type
124 (marionette-configuration
125 (imported-modules '((gnu services herd)
126 (guix build utils)
127 (guix combinators)))))
128 %base-services))))
129
130(define (operating-system-add-packages os packages)
131 "Append PACKAGES to OS packages list."
132 (operating-system
133 (inherit os)
134 (packages (append packages (operating-system-packages os)))))
135
136(define-os-with-source (%minimal-extlinux-os
137 %minimal-extlinux-os-source)
138 (use-modules (gnu) (gnu tests) (gnu bootloader extlinux)
139 (srfi srfi-1))
140
141 (operating-system
142 (host-name "liberigilo")
143 (timezone "Europe/Paris")
144 (locale "en_US.UTF-8")
145
146 (bootloader (bootloader-configuration
147 (bootloader extlinux-bootloader-gpt)
148 (targets (list "/dev/vdb"))))
149 (kernel-arguments '("console=ttyS0"))
150 (file-systems (cons (file-system
151 (device (file-system-label "my-root"))
152 (mount-point "/")
153 (type "ext4"))
154 %base-file-systems))
155 (services (cons (service marionette-service-type
156 (marionette-configuration
157 (imported-modules '((gnu services herd)
158 (guix combinators)))))
159 %base-services))))
160
161
162
163(define MiB (expt 2 20))
164
165(define %simple-installation-script
166 ;; Shell script of a simple installation.
167 "\
168. /etc/profile
169set -e -x
170guix --version
171
172export GUIX_BUILD_OPTIONS=--no-grafts
173guix build dhcpcd
174parted --script /dev/vdb mklabel gpt \\
175 mkpart primary ext2 1M 3M \\
176 mkpart primary ext2 3M 2G \\
177 set 1 boot on \\
178 set 1 bios_grub on
179mkfs.ext4 -L my-root /dev/vdb2
180mount /dev/vdb2 /mnt
181df -h /mnt
182herd start cow-store /mnt
183mkdir /mnt/etc
184cp /etc/target-config.scm /mnt/etc/config.scm
185guix system init /mnt/etc/config.scm /mnt --no-substitutes
186sync
187reboot\n")
188
189(define %extlinux-gpt-installation-script
190 ;; Shell script of a simple installation.
191 ;; As syslinux 6.0.3 does not handle 64bits ext4 partitions,
192 ;; we make sure to pass -O '^64bit' to mkfs.
193 "\
194. /etc/profile
195set -e -x
196guix --version
197
198export GUIX_BUILD_OPTIONS=--no-grafts
199guix build dhcpcd
200parted --script /dev/vdb mklabel gpt \\
201 mkpart primary ext2 1M 2G \\
202 set 1 legacy_boot on
203mkfs.ext4 -L my-root -O '^64bit' /dev/vdb1
204mount /dev/vdb1 /mnt
205df -h /mnt
206herd start cow-store /mnt
207mkdir /mnt/etc
208cp /etc/target-config.scm /mnt/etc/config.scm
209guix system init /mnt/etc/config.scm /mnt --no-substitutes
210sync
211reboot\n")
212
213(define (uefi-firmware system)
214 "Return the appropriate QEMU OVMF UEFI firmware for the given SYSTEM."
215 (cond
216 ((string-prefix? "x86_64" system)
217 (file-append ovmf-x86-64 "/share/firmware/ovmf_x64.bin"))
218 ((string-prefix? "i686" system)
219 (file-append ovmf-i686 "/share/firmware/ovmf_ia32.bin"))
220 ((string-prefix? "aarch64" system)
221 (file-append ovmf-aarch64 "/share/firmware/ovmf_aarch64.bin"))
222 (else #f)))
223
224(define* (run-install target-os target-os-source
225 #:key
226 (script %simple-installation-script)
227 (gui-test #f)
228 (packages '())
229 (os (marionette-operating-system
230 (operating-system
231 ;; Since the image has no network access, use the
232 ;; current Guix so the store items we need are in
233 ;; the image and add packages provided.
234 (inherit installation-os)
235 (kernel-arguments '("console=ttyS0")))
236 #:imported-modules '((gnu services herd)
237 (gnu installer tests)
238 (guix combinators))))
239 (uefi-support? #f)
240 (installation-image-type 'mbr-raw)
241 (install-size 'guess)
242 (target-size (* 2200 MiB))
243 (memory "1200")
244 (number-of-disks 1))
245 "Run SCRIPT (a shell script following the system installation procedure) in
246OS to install TARGET-OS. Return the VM disk images of TARGET-SIZE bytes
247containing the installed system. PACKAGES is a list of packages added to OS.
248NUMBER-OF-DISKS can be used to specify a number of disks different than one,
249such as for RAID systems. The VM running the installation is ran with -m
250MEMORY."
251 (mlet* %store-monad ((_ (set-grafting #f))
252 (system (current-system))
253
254 (uefi-firmware -> (and uefi-support?
255 (uefi-firmware system)))
256 ;; Since the installation system has no network access,
257 ;; we cheat a little bit by adding TARGET to its GC
258 ;; roots. This way, we know 'guix system init' will
259 ;; succeed. Also add guile-final, which is pulled in
260 ;; through provenance.drv and may not always be present.
261 (target (operating-system-derivation target-os))
262 (base-image -> (os->image
263 (operating-system-with-gc-roots
264 (operating-system-add-packages
265 os packages)
266 (list target guile-final))
267 #:type (lookup-image-type-by-name
268 installation-image-type)))
269 (image ->
270 (system-image
271 (image
272 (inherit base-image)
273 (size install-size)
274
275 ;; Don't provide substitutes; too big.
276 (substitutable? #f)))))
277 (define install
278 (with-imported-modules '((guix build utils)
279 (gnu build marionette))
280 #~(begin
281 (use-modules (guix build utils)
282 (gnu build marionette)
283 (srfi srfi-1))
284
285 (set-path-environment-variable "PATH" '("bin")
286 (list #$qemu-minimal))
287
288 (mkdir-p #$output)
289 (for-each (lambda (n)
290 (system* "qemu-img" "create" "-f" "qcow2"
291 (format #f "~a/disk~a.qcow2" #$output n)
292 #$(number->string target-size)))
293 (iota #$number-of-disks))
294
295 (define marionette
296 (make-marionette
297 `(,(which #$(qemu-command system))
298 ;; Neither of these architectures have a default machine.
299 ,@(if (or (string=? "aarch64-linux" #$system)
300 (string=? "armhf-linux" #$system))
301 '("-machine" "virt"
302 "-cpu" "host")
303 '())
304 "-no-reboot"
305 "-m" #$memory
306 ,@(if #$uefi-firmware
307 '("-bios" #$uefi-firmware)
308 '())
309 #$@(cond
310 ((eq? 'mbr-raw installation-image-type)
311 #~("-drive"
312 ,(string-append "file=" #$image
313 ",if=virtio,readonly")))
314 ((eq? 'uncompressed-iso9660 installation-image-type)
315 #~("-cdrom" #$image))
316 (else
317 (error
318 "unsupported installation-image-type:"
319 installation-image-type)))
320 ,@(append-map
321 (lambda (n)
322 (list "-drive"
323 (format #f "file=~a/disk~a.qcow2,if=virtio"
324 #$output n)))
325 (iota #$number-of-disks))
326 ,@(if (file-exists? "/dev/kvm")
327 '("-enable-kvm")
328 '()))))
329
330 (pk 'uname (marionette-eval '(uname) marionette))
331
332 ;; Wait for tty1.
333 (marionette-eval '(begin
334 (use-modules (gnu services herd))
335 (start-service 'term-tty1))
336 marionette)
337
338 (when #$(->bool script)
339 (marionette-eval '(call-with-output-file "/etc/target-config.scm"
340 (lambda (port)
341 (write '#$target-os-source port)))
342 marionette)
343
344 ;; Run SCRIPT. It typically invokes 'reboot' as a last step and
345 ;; thus normally gets killed with SIGTERM by PID 1.
346 (let ((status (marionette-eval '(system #$script) marionette)))
347 (exit (or (eof-object? status)
348 (equal? (status:term-sig status) SIGTERM)
349 (equal? (status:exit-val status) 0)))))
350
351 (when #$(->bool gui-test)
352 (wait-for-unix-socket "/var/guix/installer-socket"
353 marionette)
354 (format #t "installer socket ready~%")
355 (force-output)
356 (exit #$(and gui-test
357 (gui-test #~marionette)))))))
358
359 (mlet %store-monad ((images-dir (gexp->derivation "installation"
360 install
361 #:substitutable? #f))) ;too big
362 (return (with-imported-modules '((guix build utils))
363 #~(begin
364 (use-modules (guix build utils))
365 (find-files #$images-dir)))))))
366
367(define* (qemu-command* images #:key (uefi-support? #f) (memory-size 256))
368 "Return as a monadic value the command to run QEMU with a writable overlay
369on top of IMAGES, a list of disk images. The QEMU VM has access to MEMORY-SIZE
370MiB of RAM."
371 (mlet* %store-monad ((system (current-system))
372 (uefi-firmware -> (and uefi-support?
373 (uefi-firmware system))))
374 (return #~(begin
375 (use-modules (srfi srfi-1))
376 `(,(string-append #$qemu-minimal "/bin/"
377 #$(qemu-command system))
378 ;; Neither of these architectures have a default machine.
379 ,@(if (or (string=? "aarch64-linux" #$system)
380 (string=? "armhf-linux" #$system))
381 '("-machine" "virt"
382 "-cpu" "host")
383 '())
384 "-snapshot" ;for the volatile, writable overlay
385 ,@(if (file-exists? "/dev/kvm")
386 '("-enable-kvm")
387 '())
388 ,@(if #$uefi-firmware
389 '("-bios" #$uefi-firmware)
390 '())
391 "-no-reboot" "-m" #$(number->string memory-size)
392 ,@(append-map (lambda (image)
393 (list "-drive" (format #f "file=~a,if=virtio"
394 image)))
395 #$images))))))
396
397(define %test-installed-os
398 (system-test
399 (name "installed-os")
400 (description
401 "Test basic functionality of an OS installed like one would do by hand.
402This test is expensive in terms of CPU and storage usage since we need to
403build (current-guix) and then store a couple of full system images.")
404 (value
405 (mlet* %store-monad ((images (run-install %minimal-os %minimal-os-source))
406 (command (qemu-command* images)))
407 (run-basic-test %minimal-os command
408 "installed-os")))))
409
410(define %test-installed-extlinux-os
411 (system-test
412 (name "installed-extlinux-os")
413 (description
414 "Test basic functionality of an OS booted with an extlinux bootloader. As
415per %test-installed-os, this test is expensive in terms of CPU and storage.")
416 (value
417 (mlet* %store-monad ((images (run-install %minimal-extlinux-os
418 %minimal-extlinux-os-source
419 #:packages
420 (list syslinux)
421 #:script
422 %extlinux-gpt-installation-script))
423 (command (qemu-command* images)))
424 (run-basic-test %minimal-extlinux-os command
425 "installed-extlinux-os")))))
426
427
428;;;
429;;; Installation through an ISO image.
430;;;
431
432(define-os-with-source (%minimal-os-on-vda %minimal-os-on-vda-source)
433 ;; The OS we want to install.
434 (use-modules (gnu) (gnu tests) (srfi srfi-1))
435
436 (operating-system
437 (host-name "liberigilo")
438 (timezone "Europe/Paris")
439 (locale "en_US.UTF-8")
440
441 (bootloader (bootloader-configuration
442 (bootloader grub-bootloader)
443 (targets (list "/dev/vda"))))
444 (kernel-arguments '("console=ttyS0"))
445 (file-systems (cons (file-system
446 (device (file-system-label "my-root"))
447 (mount-point "/")
448 (type "ext4"))
449 %base-file-systems))
450 (users (cons (user-account
451 (name "alice")
452 (comment "Bob's sister")
453 (group "users")
454 (supplementary-groups '("wheel" "audio" "video")))
455 %base-user-accounts))
456 (services (cons (service marionette-service-type
457 (marionette-configuration
458 (imported-modules '((gnu services herd)
459 (guix build utils)
460 (guix combinators)))))
461 %base-services))))
462
463(define %simple-installation-script-for-/dev/vda
464 ;; Shell script of a simple installation.
465 "\
466. /etc/profile
467set -e -x
468guix --version
469
470export GUIX_BUILD_OPTIONS=--no-grafts
471guix build dhcpcd
472parted --script /dev/vda mklabel gpt \\
473 mkpart primary ext2 1M 3M \\
474 mkpart primary ext2 3M 2G \\
475 set 1 boot on \\
476 set 1 bios_grub on
477mkfs.ext4 -L my-root /dev/vda2
478mount /dev/vda2 /mnt
479df -h /mnt
480herd start cow-store /mnt
481mkdir /mnt/etc
482cp /etc/target-config.scm /mnt/etc/config.scm
483guix system init /mnt/etc/config.scm /mnt --no-substitutes
484sync
485reboot\n")
486
487(define %test-iso-image-installer
488 (system-test
489 (name "iso-image-installer")
490 (description
491 "")
492 (value
493 (mlet* %store-monad ((images (run-install
494 %minimal-os-on-vda
495 %minimal-os-on-vda-source
496 #:script
497 %simple-installation-script-for-/dev/vda
498 #:installation-image-type
499 'uncompressed-iso9660))
500 (command (qemu-command* images)))
501 (run-basic-test %minimal-os-on-vda command name)))))
502
503
504;;;
505;;; Separate /home.
506;;;
507
508(define-os-with-source (%separate-home-os %separate-home-os-source)
509 ;; The OS we want to install.
510 (use-modules (gnu) (gnu tests) (srfi srfi-1))
511
512 (operating-system
513 (host-name "liberigilo")
514 (timezone "Europe/Paris")
515 (locale "en_US.utf8")
516
517 (bootloader (bootloader-configuration
518 (bootloader grub-bootloader)
519 (targets '("/dev/vdb"))))
520 (kernel-arguments '("console=ttyS0"))
521 (file-systems (cons* (file-system
522 (device (file-system-label "my-root"))
523 (mount-point "/")
524 (type "ext4"))
525 (file-system
526 (device "none")
527 (mount-point "/home")
528 (type "tmpfs"))
529 %base-file-systems))
530 (users (cons* (user-account
531 (name "alice")
532 (group "users"))
533 (user-account
534 (name "charlie")
535 (group "users"))
536 %base-user-accounts))
537 (services (cons (service marionette-service-type
538 (marionette-configuration
539 (imported-modules '((gnu services herd)
540 (guix combinators)))))
541 %base-services))))
542
543(define %test-separate-home-os
544 (system-test
545 (name "separate-home-os")
546 (description
547 "Test basic functionality of an installed OS with a separate /home
548partition. In particular, home directories must be correctly created (see
549<https://bugs.gnu.org/21108>).")
550 (value
551 (mlet* %store-monad ((images (run-install %separate-home-os
552 %separate-home-os-source
553 #:script
554 %simple-installation-script))
555 (command (qemu-command* images)))
556 (run-basic-test %separate-home-os command "separate-home-os")))))
557
558
559;;;
560;;; Separate /gnu/store partition.
561;;;
562
563(define-os-with-source (%separate-store-os %separate-store-os-source)
564 ;; The OS we want to install.
565 (use-modules (gnu) (gnu tests) (srfi srfi-1))
566
567 (operating-system
568 (host-name "liberigilo")
569 (timezone "Europe/Paris")
570 (locale "en_US.UTF-8")
571
572 (bootloader (bootloader-configuration
573 (bootloader grub-bootloader)
574 (targets (list "/dev/vdb"))))
575 (kernel-arguments '("console=ttyS0"))
576 (file-systems (cons* (file-system
577 (device (file-system-label "root-fs"))
578 (mount-point "/")
579 (type "ext4"))
580 (file-system
581 (device (file-system-label "store-fs"))
582 (mount-point "/gnu")
583 (type "ext4"))
584 %base-file-systems))
585 (users %base-user-accounts)
586 (services (cons (service marionette-service-type
587 (marionette-configuration
588 (imported-modules '((gnu services herd)
589 (guix combinators)))))
590 %base-services))))
591
592(define %separate-store-installation-script
593 ;; Installation with a separate /gnu partition.
594 "\
595. /etc/profile
596set -e -x
597guix --version
598
599export GUIX_BUILD_OPTIONS=--no-grafts
600guix build dhcpcd
601parted --script /dev/vdb mklabel gpt \\
602 mkpart primary ext2 1M 3M \\
603 mkpart primary ext2 3M 400M \\
604 mkpart primary ext2 400M 2.4G \\
605 set 1 boot on \\
606 set 1 bios_grub on
607mkfs.ext4 -L root-fs /dev/vdb2
608mkfs.ext4 -L store-fs /dev/vdb3
609mount /dev/vdb2 /mnt
610mkdir /mnt/gnu
611mount /dev/vdb3 /mnt/gnu
612df -h /mnt
613df -h /mnt/gnu
614herd start cow-store /mnt
615mkdir /mnt/etc
616cp /etc/target-config.scm /mnt/etc/config.scm
617guix system init /mnt/etc/config.scm /mnt --no-substitutes
618sync
619reboot\n")
620
621(define %test-separate-store-os
622 (system-test
623 (name "separate-store-os")
624 (description
625 "Test basic functionality of an OS installed like one would do by hand,
626where /gnu lives on a separate partition.")
627 (value
628 (mlet* %store-monad ((images (run-install %separate-store-os
629 %separate-store-os-source
630 #:script
631 %separate-store-installation-script))
632 (command (qemu-command* images)))
633 (run-basic-test %separate-store-os command "separate-store-os")))))
634
635
636;;;
637;;; RAID root device.
638;;;
639
640(define-os-with-source (%raid-root-os %raid-root-os-source)
641 ;; An OS whose root partition is a RAID partition.
642 (use-modules (gnu) (gnu tests))
643
644 (operating-system
645 (host-name "raidified")
646 (timezone "Europe/Paris")
647 (locale "en_US.utf8")
648
649 (bootloader (bootloader-configuration
650 (bootloader grub-bootloader)
651 (targets (list "/dev/vdb"))))
652 (kernel-arguments '("console=ttyS0"))
653
654 ;; Add a kernel module for RAID-1 (aka. "mirror").
655 (initrd-modules (cons "raid1" %base-initrd-modules))
656
657 (mapped-devices (list (mapped-device
658 (source (list "/dev/vda2" "/dev/vda3"))
659 (target "/dev/md0")
660 (type raid-device-mapping))))
661 (file-systems (cons (file-system
662 (device (file-system-label "root-fs"))
663 (mount-point "/")
664 (type "ext4")
665 (dependencies mapped-devices))
666 %base-file-systems))
667 (users %base-user-accounts)
668 (services (cons (service marionette-service-type
669 (marionette-configuration
670 (imported-modules '((gnu services herd)
671 (guix combinators)))))
672 %base-services))))
673
674(define %raid-root-installation-script
675 ;; Installation with a separate /gnu partition. See
676 ;; <https://raid.wiki.kernel.org/index.php/RAID_setup> for more on RAID and
677 ;; mdadm.
678 "\
679. /etc/profile
680set -e -x
681guix --version
682
683export GUIX_BUILD_OPTIONS=--no-grafts
684parted --script /dev/vdb mklabel gpt \\
685 mkpart primary ext2 1M 3M \\
686 mkpart primary ext2 3M 2G \\
687 mkpart primary ext2 2G 4G \\
688 set 1 boot on \\
689 set 1 bios_grub on
690yes | mdadm --create /dev/md0 --verbose --level=mirror --raid-devices=2 \\
691 /dev/vdb2 /dev/vdb3
692mkfs.ext4 -L root-fs /dev/md0
693mount /dev/md0 /mnt
694df -h /mnt
695herd start cow-store /mnt
696mkdir /mnt/etc
697cp /etc/target-config.scm /mnt/etc/config.scm
698guix system init /mnt/etc/config.scm /mnt --no-substitutes
699sync
700reboot\n")
701
702(define %test-raid-root-os
703 (system-test
704 (name "raid-root-os")
705 (description
706 "Test functionality of an OS installed with a RAID root partition managed
707by 'mdadm'.")
708 (value
709 (mlet* %store-monad ((images (run-install %raid-root-os
710 %raid-root-os-source
711 #:script
712 %raid-root-installation-script
713 #:target-size (* 4100 MiB)))
714 (command (qemu-command* images)))
715 (run-basic-test %raid-root-os
716 `(,@command) "raid-root-os")))))
717
718
719;;;
720;;; LUKS-encrypted root file system.
721;;;
722
723(define-os-with-source (%encrypted-root-os %encrypted-root-os-source)
724 ;; The OS we want to install.
725 (use-modules (gnu) (gnu tests) (srfi srfi-1))
726
727 (operating-system
728 (host-name "liberigilo")
729 (timezone "Europe/Paris")
730 (locale "en_US.UTF-8")
731
732 (bootloader (bootloader-configuration
733 (bootloader grub-bootloader)
734 (targets '("/dev/vdb"))))
735
736 ;; Pass "console=ttyS0" so initrd messages (including luks-master-key
737 ;; diagnostics) are visible on serial. The GRUB passphrase prompt
738 ;; appears on VGA regardless and is detected via OCR.
739 (kernel-arguments '("console=ttyS0"))
740
741 (mapped-devices (list (mapped-device
742 (source (uuid "12345678-1234-1234-1234-123456789abc"))
743 (target "the-root-device")
744 (type luks-device-mapping))))
745 (file-systems (cons (file-system
746 (device "/dev/mapper/the-root-device")
747 (mount-point "/")
748 (type "ext4"))
749 %base-file-systems))
750 (users (cons (user-account
751 (name "charlie")
752 (group "users")
753 (supplementary-groups '("wheel" "audio" "video")))
754 %base-user-accounts))
755 (services (cons (service marionette-service-type
756 (marionette-configuration
757 (imported-modules '((gnu services herd)
758 (guix combinators)))))
759 %base-services))))
760
761(define %luks-passphrase
762 ;; LUKS encryption passphrase used in tests.
763 "thepassphrase")
764
765(define %encrypted-root-installation-script
766 ;; Shell script of a simple installation.
767 (string-append "\
768. /etc/profile
769set -e -x
770guix --version
771
772export GUIX_BUILD_OPTIONS=--no-grafts
773ls -l /run/current-system/gc-roots
774parted --script /dev/vdb mklabel gpt \\
775 mkpart primary ext2 1M 3M \\
776 mkpart primary ext2 3M 2G \\
777 set 1 boot on \\
778 set 1 bios_grub on
779echo -n " %luks-passphrase " | \\
780 cryptsetup luksFormat -i 1 --uuid=12345678-1234-1234-1234-123456789abc -q /dev/vdb2 -
781echo -n " %luks-passphrase " | \\
782 cryptsetup open --type luks --key-file - /dev/vdb2 the-root-device
783mkfs.ext4 -L my-root /dev/mapper/the-root-device
784mount LABEL=my-root /mnt
785herd start cow-store /mnt
786mkdir /mnt/etc
787cp /etc/target-config.scm /mnt/etc/config.scm
788guix system build /mnt/etc/config.scm
789guix system init /mnt/etc/config.scm /mnt --no-substitutes
790sync
791reboot\n"))
792
793(define (enter-luks-passphrase marionette)
794 "Return a gexp to be inserted in the basic system test running on MARIONETTE
795to enter the LUKS passphrase. Only the GRUB passphrase prompt is expected;
796the initrd reuses the master key passed by GRUB via (proc)/luks_script."
797 (let ((ocrad (file-append ocrad "/bin/ocrad")))
798 #~(begin
799 (define (passphrase-prompt? text)
800 (string-contains (pk 'screen-text text) "Enter pass"))
801
802 (test-assert "enter LUKS passphrase for GRUB"
803 (begin
804 ;; At this point we have no choice but to use OCR to determine
805 ;; when the passphrase should be entered.
806 (wait-for-screen-text #$marionette passphrase-prompt?
807 #:ocr #$ocrad)
808 (marionette-type #$(string-append %luks-passphrase "\n")
809 #$marionette)
810
811 ;; Take a screenshot for debugging purposes.
812 (marionette-control (string-append "screendump " #$output
813 "/post-grub-passphrase.ppm")
814 #$marionette))))))
815
816(define %test-encrypted-root-os
817 (system-test
818 (name "encrypted-root-os")
819 (description
820 "Test basic functionality of an OS installed like one would do by hand.
821This test is expensive in terms of CPU and storage usage since we need to
822build (current-guix) and then store a couple of full system images.")
823 (value
824 (mlet* %store-monad ((images (run-install %encrypted-root-os
825 %encrypted-root-os-source
826 #:script
827 %encrypted-root-installation-script))
828 (command (qemu-command* images)))
829 (run-basic-test %encrypted-root-os command "encrypted-root-os"
830 #:initialization enter-luks-passphrase)))))
831
832
833;;;
834;;; LUKS-encrypted root with extra options: --allow-discards,
835;;; --perf-no_read_workqueue and --perf-no_write_workqueue
836;;;
837
838;; Except for the 'mapped-devices' field, this is exactly the same as
839;; %encrypted-root-os.
840(define-os-with-source (%encrypted-root-extra-options-os
841 %encrypted-root-extra-options-os-source)
842 ;; The OS we want to install.
843 (use-modules (gnu) (gnu tests) (srfi srfi-1))
844
845 (operating-system
846 (host-name "liberigilo")
847 (timezone "Europe/Paris")
848 (locale "en_US.UTF-8")
849
850 (bootloader (bootloader-configuration
851 (bootloader grub-bootloader)
852 (targets '("/dev/vdb"))))
853
854 ;; Note: Do not pass "console=ttyS0" so we can use our passphrase prompt
855 ;; detection logic in 'enter-luks-passphrase'.
856
857 (mapped-devices (list (mapped-device
858 (source (uuid "12345678-1234-1234-1234-123456789abc"))
859 (target "the-root-device")
860 (type luks-device-mapping)
861 (arguments '(#:allow-discards? #t
862 #:extra-options
863 ("--perf-no_read_workqueue"
864 "--perf-no_write_workqueue"))))))
865 (file-systems (cons (file-system
866 (device "/dev/mapper/the-root-device")
867 (mount-point "/")
868 (type "ext4"))
869 %base-file-systems))
870 (users (cons (user-account
871 (name "charlie")
872 (group "users")
873 (supplementary-groups '("wheel" "audio" "video")))
874 %base-user-accounts))
875 (services (cons (service marionette-service-type
876 (marionette-configuration
877 (imported-modules '((gnu services herd)
878 (guix combinators)))))
879 %base-services))))
880
881(define %test-encrypted-root-extra-options-os
882 (system-test
883 (name "encrypted-root-extra-options-os")
884 (description
885 "Test basic functionality of an OS installed like one would do by hand,
886with an LUKS-encrypted root partition opened with extra options
887(--allow-discards, --perf-no_read_workqueue and --perf-no_write_workqueue).
888This test is expensive in terms of CPU and storage usage since we need to
889build (current-guix) and then store a couple of full system images.")
890 (value
891 (mlet* %store-monad ((images (run-install %encrypted-root-extra-options-os
892 %encrypted-root-extra-options-os-source
893 #:script
894 %encrypted-root-installation-script))
895 (command (qemu-command* images)))
896 (run-basic-test %encrypted-root-os command "encrypted-root-extra-options-os"
897 #:initialization enter-luks-passphrase)))))
898
899
900;;;
901;;; Separate /home on LVM
902;;;
903
904;; Since LVM support in guix currently doesn't allow root-on-LVM we use /home on LVM
905(define-os-with-source (%lvm-separate-home-os %lvm-separate-home-os-source)
906 (use-modules (gnu) (gnu tests))
907
908 (operating-system
909 (host-name "separate-home-on-lvm")
910 (timezone "Europe/Paris")
911 (locale "en_US.utf8")
912
913 (bootloader (bootloader-configuration
914 (bootloader grub-bootloader)
915 (targets (list "/dev/vdb"))))
916 (kernel-arguments '("console=ttyS0"))
917
918 (mapped-devices (list (mapped-device
919 (source "vg0")
920 (target "vg0-home")
921 (type lvm-device-mapping))))
922 (file-systems (cons* (file-system
923 (device (file-system-label "root-fs"))
924 (mount-point "/")
925 (type "ext4"))
926 (file-system
927 (device "/dev/mapper/vg0-home")
928 (mount-point "/home")
929 (type "ext4")
930 (dependencies mapped-devices))
931 %base-file-systems))
932 (users %base-user-accounts)
933 (services (cons (service marionette-service-type
934 (marionette-configuration
935 (imported-modules '((gnu services herd)
936 (guix combinators)))))
937 %base-services))))
938
939(define %lvm-separate-home-installation-script
940 "\
941. /etc/profile
942set -e -x
943guix --version
944
945export GUIX_BUILD_OPTIONS=--no-grafts
946parted --script /dev/vdb mklabel gpt \\
947 mkpart primary ext2 1M 3M \\
948 mkpart primary ext2 3M 2G \\
949 mkpart primary ext2 2G 4G \\
950 set 1 boot on \\
951 set 1 bios_grub on
952pvcreate /dev/vdb3
953vgcreate vg0 /dev/vdb3
954lvcreate -L 2G -n home vg0
955vgchange -ay
956mkfs.ext4 -L root-fs /dev/vdb2
957mkfs.ext4 /dev/mapper/vg0-home
958mount /dev/vdb2 /mnt
959mkdir /mnt/home
960mount /dev/mapper/vg0-home /mnt/home
961df -h /mnt /mnt/home
962herd start cow-store /mnt
963mkdir /mnt/etc
964cp /etc/target-config.scm /mnt/etc/config.scm
965guix system init /mnt/etc/config.scm /mnt --no-substitutes
966sync
967reboot\n")
968
969(define %test-lvm-separate-home-os
970 (system-test
971 (name "lvm-separate-home-os")
972 (description
973 "Test functionality of an OS installed with a LVM /home partition")
974 (value
975 (mlet* %store-monad ((images (run-install %lvm-separate-home-os
976 %lvm-separate-home-os-source
977 #:script
978 %lvm-separate-home-installation-script
979 #:packages (list lvm2-static)
980 #:target-size (* 4100 MiB)))
981 (command (qemu-command* images)))
982 (run-basic-test %lvm-separate-home-os
983 `(,@command) "lvm-separate-home-os")))))
984
985
986;;;
987;;; LUKS-encrypted /home, unencrypted root.
988;;;
989
990(define-os-with-source (%encrypted-home-os %encrypted-home-os-source)
991 (use-modules (gnu) (gnu tests))
992
993 (operating-system
994 (host-name "cipherhome")
995 (timezone "Europe/Paris")
996 (locale "en_US.utf8")
997
998 (bootloader (bootloader-configuration
999 (bootloader grub-bootloader)
1000 (targets (list "/dev/vdb"))))
1001
1002 ;; Note: Do not pass "console=ttyS0" so we can use our passphrase prompt
1003 ;; detection logic in 'enter-luks-passphrase'.
1004
1005 (mapped-devices (list (mapped-device
1006 (source (uuid "12345678-1234-1234-1234-123456789abc"))
1007 (target "the-home-device")
1008 (type luks-device-mapping))))
1009 (file-systems (cons* (file-system
1010 (device (file-system-label "root-fs"))
1011 (mount-point "/")
1012 (type "ext4"))
1013 (file-system
1014 (device (file-system-label "home-fs"))
1015 (mount-point "/home")
1016 (type "ext4")
1017 (dependencies mapped-devices))
1018 %base-file-systems))
1019 (users %base-user-accounts)
1020 (services (cons (service marionette-service-type
1021 (marionette-configuration
1022 (imported-modules '((gnu services herd)
1023 (guix combinators)))))
1024 %base-services))))
1025
1026(define %encrypted-home-installation-script
1027 (string-append "\
1028. /etc/profile
1029set -e -x
1030guix --version
1031
1032export GUIX_BUILD_OPTIONS=--no-grafts
1033parted --script /dev/vdb mklabel gpt \\
1034 mkpart primary ext2 1M 3M \\
1035 mkpart primary ext2 3M 2G \\
1036 mkpart primary ext2 2G 2.4G \\
1037 set 1 boot on \\
1038 set 1 bios_grub on
1039
1040echo -n " %luks-passphrase " | \\
1041 cryptsetup luksFormat -i 1 --uuid=12345678-1234-1234-1234-123456789abc -q /dev/vdb3 -
1042echo -n " %luks-passphrase " | \\
1043 cryptsetup open --type luks --key-file - /dev/vdb3 the-home-device
1044
1045mkfs.ext4 -L root-fs /dev/vdb2
1046mkfs.ext4 -L home-fs /dev/mapper/the-home-device
1047mount /dev/vdb2 /mnt
1048
1049# This script is used for both encrypted-home-os and encrypted-home-os-key-file
1050# tests. So we also add the keyfile here.
1051dd if=/dev/zero of=/key-file.bin bs=4096 count=1
1052( cd /mnt;
1053 echo /key-file.bin | cpio -oH newc > key-file.cpio
1054 chmod 0000 key-file.cpio
1055 mv /key-file.bin .
1056)
1057echo -n " %luks-passphrase " | \\
1058 cryptsetup luksAddKey --key-file - -i 1 /dev/vdb3 /mnt/key-file.bin
1059
1060mkdir /mnt/home
1061mount /dev/mapper/the-home-device /mnt/home
1062df -h /mnt /mnt/home
1063herd start cow-store /mnt
1064mkdir /mnt/etc
1065cp /etc/target-config.scm /mnt/etc/config.scm
1066guix system init /mnt/etc/config.scm /mnt --no-substitutes
1067sync
1068reboot\n"))
1069
1070(define (enter-luks-passphrase-for-home marionette)
1071 "Return a gexp to be inserted in the basic system test running on MARIONETTE
1072to enter the LUKS passphrase. Note that 'cryptsetup open' in this case is
1073launched as a shepherd service."
1074 (let ((ocrad (file-append ocrad "/bin/ocrad")))
1075 #~(begin
1076 (define (passphrase-prompt? text)
1077 (string-contains (pk 'screen-text text) "Enter pass"))
1078
1079 (test-assert "enter LUKS passphrase for the shepherd service"
1080 (begin
1081 ;; XXX: Here we use OCR as well but we could instead use QEMU
1082 ;; '-serial stdio' and run it in an input pipe,
1083 (wait-for-screen-text #$marionette passphrase-prompt?
1084 #:ocr #$ocrad
1085 #:timeout 120)
1086 (marionette-type #$(string-append %luks-passphrase "\n")
1087 #$marionette)
1088
1089 ;; Take a screenshot for debugging purposes.
1090 (marionette-control (string-append "screendump " #$output
1091 "/shepherd-passphrase.ppm")
1092 #$marionette))))))
1093
1094(define %test-encrypted-home-os
1095 (system-test
1096 (name "encrypted-home-os")
1097 (description
1098 "Test functionality of an OS installed with a LUKS /home partition")
1099 (value
1100 (mlet* %store-monad ((images (run-install %encrypted-home-os
1101 %encrypted-home-os-source
1102 #:script
1103 %encrypted-home-installation-script
1104 #:packages (list cpio)
1105 #:target-size
1106 (* 3000 MiB)))
1107 (command (qemu-command* images)))
1108 (run-basic-test %encrypted-home-os command "encrypted-home-os"
1109 #:initialization enter-luks-passphrase-for-home)))))
1110
1111
1112;;;
1113;;; LUKS-encrypted /home, unencrypted root. The unlock is done using a key
1114;;; file.
1115;;;
1116(define-os-with-source (%encrypted-home-os-key-file
1117 %encrypted-home-os-key-file-source)
1118 (use-modules (gnu) (gnu tests))
1119
1120 (operating-system
1121 (host-name "cipherhome")
1122 (timezone "Europe/Prague")
1123 (locale "en_US.utf8")
1124
1125 (bootloader (bootloader-configuration
1126 (bootloader grub-bootloader)
1127 (targets (list "/dev/vdb"))
1128 (extra-initrd "/key-file.cpio")))
1129 (kernel-arguments '("console=ttyS0"))
1130
1131 (mapped-devices (list (mapped-device
1132 (source (uuid "12345678-1234-1234-1234-123456789abc"))
1133 (target "the-home-device")
1134 (type luks-device-mapping)
1135 (arguments '(#:key-file "/key-file.bin")))))
1136 (file-systems (cons* (file-system
1137 (device (file-system-label "root-fs"))
1138 (mount-point "/")
1139 (type "ext4"))
1140 (file-system
1141 (device (file-system-label "home-fs"))
1142 (mount-point "/home")
1143 (type "ext4")
1144 (dependencies mapped-devices))
1145 %base-file-systems))
1146 (services (cons (service marionette-service-type
1147 (marionette-configuration
1148 (imported-modules '((gnu services herd)
1149 (guix combinators)))))
1150 %base-services))))
1151
1152(define %test-encrypted-home-os-key-file
1153 (system-test
1154 (name "encrypted-home-os-key-file")
1155 (description
1156 "Test functionality of an OS installed with a LUKS /home partition with
1157unlock done using a key file")
1158 (value
1159 (mlet* %store-monad ((images (run-install %encrypted-home-os-key-file
1160 %encrypted-home-os-key-file-source
1161 #:script
1162 %encrypted-home-installation-script
1163 #:packages (list cpio)
1164 #:target-size
1165 (* 3000 MiB)))
1166 (command (qemu-command* images)))
1167 (run-basic-test %encrypted-home-os-key-file
1168 command "encrypted-home-os-key-file")))))
1169
1170
1171;;;
1172;;; LUKS-encrypted root file system and /boot in a non-encrypted partition.
1173;;;
1174
1175(define-os-with-source (%encrypted-root-not-boot-os
1176 %encrypted-root-not-boot-os-source)
1177 ;; The OS we want to install.
1178 (use-modules (gnu) (gnu tests) (srfi srfi-1))
1179
1180 (operating-system
1181 (host-name "bootroot")
1182 (timezone "Europe/Paris")
1183 (locale "en_US.UTF-8")
1184
1185 (bootloader (bootloader-configuration
1186 (bootloader grub-bootloader)
1187 (targets (list "/dev/vdb"))))
1188
1189 (mapped-devices (list (mapped-device
1190 (source
1191 (uuid "12345678-1234-1234-1234-123456789abc"))
1192 (target "root")
1193 (type luks-device-mapping))))
1194 (file-systems (cons* (file-system
1195 (device (file-system-label "my-boot"))
1196 (mount-point "/boot")
1197 (type "ext4"))
1198 (file-system
1199 (device "/dev/mapper/root")
1200 (mount-point "/")
1201 (type "ext4"))
1202 %base-file-systems))
1203 (users (cons (user-account
1204 (name "alice")
1205 (group "users")
1206 (supplementary-groups '("wheel" "audio" "video")))
1207 %base-user-accounts))
1208 (services (cons (service marionette-service-type
1209 (marionette-configuration
1210 (imported-modules '((gnu services herd)
1211 (guix combinators)))))
1212 %base-services))))
1213
1214(define %encrypted-root-not-boot-installation-script
1215 ;; Shell script for an installation with boot not encrypted but root
1216 ;; encrypted.
1217 (format #f "\
1218. /etc/profile
1219set -e -x
1220guix --version
1221
1222export GUIX_BUILD_OPTIONS=--no-grafts
1223ls -l /run/current-system/gc-roots
1224parted --script /dev/vdb mklabel gpt \\
1225 mkpart primary ext2 1M 3M \\
1226 mkpart primary ext2 3M 50M \\
1227 mkpart primary ext2 50M 2G \\
1228 set 1 boot on \\
1229 set 1 bios_grub on
1230echo -n \"~a\" | cryptsetup luksFormat -i 1 --uuid=\"~a\" -q /dev/vdb3 -
1231echo -n \"~a\" | cryptsetup open --type luks --key-file - /dev/vdb3 root
1232mkfs.ext4 -L my-root /dev/mapper/root
1233mkfs.ext4 -L my-boot /dev/vdb2
1234mount LABEL=my-root /mnt
1235mkdir /mnt/boot
1236mount LABEL=my-boot /mnt/boot
1237echo \"Checking mounts\"
1238mount
1239herd start cow-store /mnt
1240mkdir /mnt/etc
1241cp /etc/target-config.scm /mnt/etc/config.scm
1242guix system build /mnt/etc/config.scm
1243guix system init /mnt/etc/config.scm /mnt --no-substitutes
1244sync
1245echo \"Debugging info\"
1246blkid
1247cat /mnt/boot/grub/grub.cfg
1248reboot\n"
1249 %luks-passphrase "12345678-1234-1234-1234-123456789abc"
1250 %luks-passphrase))
1251
1252(define %test-encrypted-root-not-boot-os
1253 (system-test
1254 (name "encrypted-root-not-boot-os")
1255 (description
1256 "Test the manual installation on an OS with / in an encrypted partition
1257but /boot on a different, non-encrypted partition. This test is expensive in
1258terms of CPU and storage usage since we need to build (current-guix) and then
1259store a couple of full system images.")
1260 (value
1261 (mlet* %store-monad
1262 ((images (run-install %encrypted-root-not-boot-os
1263 %encrypted-root-not-boot-os-source
1264 #:script
1265 %encrypted-root-not-boot-installation-script
1266 #:target-size
1267 (* 2100 MiB)))
1268 (command (qemu-command* images)))
1269 (run-basic-test %encrypted-root-not-boot-os command
1270 "encrypted-root-not-boot-os"
1271 #:initialization enter-luks-passphrase)))))
1272
1273
1274;;;
1275;;; Btrfs root file system.
1276;;;
1277
1278(define-os-with-source (%btrfs-root-os %btrfs-root-os-source)
1279 ;; The OS we want to install.
1280 (use-modules (gnu) (gnu tests) (srfi srfi-1))
1281
1282 (operating-system
1283 (host-name "liberigilo")
1284 (timezone "Europe/Paris")
1285 (locale "en_US.UTF-8")
1286
1287 (bootloader (bootloader-configuration
1288 (bootloader grub-bootloader)
1289 (targets (list "/dev/vdb"))))
1290 (kernel-arguments '("console=ttyS0"))
1291 (file-systems (cons (file-system
1292 (device (file-system-label "my-root"))
1293 (mount-point "/")
1294 (type "btrfs"))
1295 %base-file-systems))
1296 (users (cons (user-account
1297 (name "charlie")
1298 (group "users")
1299 (supplementary-groups '("wheel" "audio" "video")))
1300 %base-user-accounts))
1301 (services (cons (service marionette-service-type
1302 (marionette-configuration
1303 (imported-modules '((gnu services herd)
1304 (guix combinators)))))
1305 %base-services))))
1306
1307(define %btrfs-root-installation-script
1308 ;; Shell script of a simple installation.
1309 "\
1310. /etc/profile
1311set -e -x
1312guix --version
1313
1314export GUIX_BUILD_OPTIONS=--no-grafts
1315ls -l /run/current-system/gc-roots
1316parted --script /dev/vdb mklabel gpt \\
1317 mkpart primary ext2 1M 3M \\
1318 mkpart primary ext2 3M 2G \\
1319 set 1 boot on \\
1320 set 1 bios_grub on
1321mkfs.btrfs -L my-root /dev/vdb2
1322mount /dev/vdb2 /mnt
1323btrfs subvolume create /mnt/home
1324herd start cow-store /mnt
1325mkdir /mnt/etc
1326cp /etc/target-config.scm /mnt/etc/config.scm
1327guix system build /mnt/etc/config.scm
1328guix system init /mnt/etc/config.scm /mnt --no-substitutes
1329sync
1330reboot\n")
1331
1332(define %test-btrfs-root-os
1333 (system-test
1334 (name "btrfs-root-os")
1335 (description
1336 "Test basic functionality of an OS installed like one would do by hand.
1337This test is expensive in terms of CPU and storage usage since we need to
1338build (current-guix) and then store a couple of full system images.")
1339 (value
1340 (mlet* %store-monad ((images (run-install %btrfs-root-os
1341 %btrfs-root-os-source
1342 #:script
1343 %btrfs-root-installation-script))
1344 (command (qemu-command* images)))
1345 (run-basic-test %btrfs-root-os command "btrfs-root-os")))))
1346
1347
1348
1349;;;
1350;;; Btrfs RAID-0 root file system.
1351;;;
1352(define-os-with-source (%btrfs-raid-root-os %btrfs-raid-root-os-source)
1353 ;; An OS whose root partition is a RAID partition.
1354 (use-modules (gnu) (gnu tests))
1355
1356 (operating-system
1357 (host-name "liberigilo")
1358 (timezone "Europe/Paris")
1359 (locale "en_US.utf8")
1360
1361 (bootloader (bootloader-configuration
1362 (bootloader grub-bootloader)
1363 (targets (list "/dev/vdb"))))
1364 (kernel-arguments '("console=ttyS0"))
1365
1366 (file-systems (cons (file-system
1367 (device (file-system-label "root-fs"))
1368 (mount-point "/")
1369 (type "btrfs"))
1370 %base-file-systems))
1371 (users %base-user-accounts)
1372 (services (cons (service marionette-service-type
1373 (marionette-configuration
1374 (imported-modules '((gnu services herd)
1375 (guix combinators)))))
1376 %base-services))))
1377
1378(define %btrfs-raid-root-installation-script
1379 "\
1380. /etc/profile
1381set -e -x
1382guix --version
1383
1384export GUIX_BUILD_OPTIONS=--no-grafts
1385parted --script /dev/vdb mklabel gpt \\
1386 mkpart primary ext2 1M 3M \\
1387 mkpart primary ext2 3M 2G \\
1388 mkpart primary ext2 2G 4G \\
1389 set 1 boot on \\
1390 set 1 bios_grub on
1391mkfs.btrfs -L root-fs -d raid0 -m raid0 /dev/vdb2 /dev/vdb3
1392mount /dev/vdb2 /mnt
1393df -h /mnt
1394herd start cow-store /mnt
1395mkdir /mnt/etc
1396cp /etc/target-config.scm /mnt/etc/config.scm
1397guix system init /mnt/etc/config.scm /mnt --no-substitutes
1398sync
1399reboot\n")
1400
1401(define %test-btrfs-raid-root-os
1402 (system-test
1403 (name "btrfs-raid-root-os")
1404 (description "Test functionality of an OS installed with a Btrfs
1405RAID-0 (stripe) root partition.")
1406 (value
1407 (mlet* %store-monad
1408 ((images (run-install %btrfs-raid-root-os
1409 %btrfs-raid-root-os-source
1410 #:script %btrfs-raid-root-installation-script
1411 #:target-size (* 4100 MiB)))
1412 (command (qemu-command* images)))
1413 (run-basic-test %btrfs-raid-root-os `(,@command) "btrfs-raid-root-os")))))
1414
1415
1416;;;
1417;;; Btrfs root file system on a subvolume.
1418;;;
1419
1420(define-os-with-source (%btrfs-root-on-subvolume-os
1421 %btrfs-root-on-subvolume-os-source)
1422 ;; The OS we want to install.
1423 (use-modules (gnu) (gnu tests) (srfi srfi-1))
1424
1425 (operating-system
1426 (host-name "hurd")
1427 (timezone "Europe/Paris")
1428 (locale "en_US.UTF-8")
1429 (bootloader (bootloader-configuration
1430 (bootloader grub-bootloader)
1431 (targets (list "/dev/vdb"))))
1432 (kernel-arguments '("console=ttyS0"))
1433 (file-systems (cons* (file-system
1434 (device (file-system-label "btrfs-pool"))
1435 (mount-point "/")
1436 (options "subvol=rootfs,compress=zstd")
1437 (type "btrfs"))
1438 (file-system
1439 (device (file-system-label "btrfs-pool"))
1440 (mount-point "/home")
1441 (options "subvol=homefs,compress=lzo")
1442 (type "btrfs"))
1443 %base-file-systems))
1444 (users (cons (user-account
1445 (name "charlie")
1446 (group "users")
1447 (supplementary-groups '("wheel" "audio" "video")))
1448 %base-user-accounts))
1449 (services (cons (service marionette-service-type
1450 (marionette-configuration
1451 (imported-modules '((gnu services herd)
1452 (guix combinators)))))
1453 %base-services))))
1454
1455(define %btrfs-root-on-subvolume-installation-script
1456 ;; Shell script of a simple installation.
1457 "\
1458. /etc/profile
1459set -e -x
1460guix --version
1461
1462export GUIX_BUILD_OPTIONS=--no-grafts
1463ls -l /run/current-system/gc-roots
1464parted --script /dev/vdb mklabel gpt \\
1465 mkpart primary ext2 1M 3M \\
1466 mkpart primary ext2 3M 2G \\
1467 set 1 boot on \\
1468 set 1 bios_grub on
1469
1470# Setup the top level Btrfs file system with its subvolume.
1471mkfs.btrfs -L btrfs-pool /dev/vdb2
1472mount /dev/vdb2 /mnt
1473btrfs subvolume create /mnt/rootfs
1474btrfs subvolume create /mnt/homefs
1475umount /dev/vdb2
1476
1477# Mount the subvolumes, ready for installation.
1478mount LABEL=btrfs-pool -o 'subvol=rootfs,compress=zstd' /mnt
1479mkdir /mnt/home
1480mount LABEL=btrfs-pool -o 'subvol=homefs,compress=zstd' /mnt/home
1481
1482herd start cow-store /mnt
1483mkdir /mnt/etc
1484cp /etc/target-config.scm /mnt/etc/config.scm
1485guix system build /mnt/etc/config.scm
1486guix system init /mnt/etc/config.scm /mnt --no-substitutes
1487sync
1488reboot\n")
1489
1490(define %test-btrfs-root-on-subvolume-os
1491 (system-test
1492 (name "btrfs-root-on-subvolume-os")
1493 (description
1494 "Test basic functionality of an OS installed like one would do by hand.
1495This test is expensive in terms of CPU and storage usage since we need to
1496build (current-guix) and then store a couple of full system images.")
1497 (value
1498 (mlet* %store-monad
1499 ((images (run-install %btrfs-root-on-subvolume-os
1500 %btrfs-root-on-subvolume-os-source
1501 #:script
1502 %btrfs-root-on-subvolume-installation-script))
1503 (command (qemu-command* images)))
1504 (run-basic-test %btrfs-root-on-subvolume-os command
1505 "btrfs-root-on-subvolume-os")))))
1506
1507
1508;;;
1509;;; Btrfs RAID10 root file system.
1510;;;
1511
1512(define-os-with-source (%btrfs-raid10-root-os
1513 %btrfs-raid10-root-os-source)
1514 ;; The OS we want to install.
1515 (use-modules (gnu) (gnu tests) (srfi srfi-1))
1516
1517 (operating-system
1518 (host-name "hurd")
1519 (timezone "Europe/Paris")
1520 (locale "en_US.UTF-8")
1521 (bootloader (bootloader-configuration
1522 (bootloader grub-bootloader)
1523 (targets (list "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde"))))
1524 (kernel-arguments '("console=ttyS0"))
1525 (file-systems (cons* (file-system
1526 (device (uuid "16ff18e2-eb41-4324-8df5-80d3b53c411b"))
1527 (mount-point "/")
1528 (options "compress-force=zstd,degraded")
1529 (type "btrfs"))
1530 %base-file-systems))
1531 (users (cons (user-account
1532 (name "charlie")
1533 (group "users")
1534 (supplementary-groups '("wheel" "audio" "video")))
1535 %base-user-accounts))
1536 (services (cons (service marionette-service-type
1537 (marionette-configuration
1538 (imported-modules '((gnu services herd)
1539 (guix combinators)))))
1540 %base-services))))
1541
1542(define %btrfs-raid10-root-installation-script
1543 ;; Shell script of a simple installation.
1544 "\
1545. /etc/profile
1546set -e -x
1547guix --version
1548
1549export GUIX_BUILD_OPTIONS=--no-grafts
1550ls -l /run/current-system/gc-roots
1551for d in vdb vdc vdd vde; do
1552 parted --script /dev/$d mklabel gpt \\
1553 mkpart primary ext2 1M 2M \\
1554 mkpart primary ext2 2M 100% \\
1555 set 1 boot on \\
1556 set 1 bios_grub on
1557done
1558
1559# Create the RAID10 Btrfs array.
1560mkfs.btrfs -d raid10 -m raid1c4 /dev/{vdb2,vdc2,vdd2,vde2} \\
1561 --uuid 16ff18e2-eb41-4324-8df5-80d3b53c411b
1562
1563# Mount it, ready for installation.
1564mount UUID=16ff18e2-eb41-4324-8df5-80d3b53c411b -o compress-force=zstd /mnt
1565
1566herd start cow-store /mnt
1567mkdir /mnt/etc
1568cp /etc/target-config.scm /mnt/etc/config.scm
1569guix system build /mnt/etc/config.scm
1570guix system init /mnt/etc/config.scm /mnt --no-substitutes
1571sync
1572reboot\n")
1573
1574(define %test-btrfs-raid10-root-images
1575 (mlet %store-monad
1576 ((images (run-install %btrfs-raid10-root-os
1577 %btrfs-raid10-root-os-source
1578 #:script
1579 %btrfs-raid10-root-installation-script
1580 #:number-of-disks 4
1581 #:target-size (* 1100 MiB))))
1582 (return images)))
1583
1584(define %test-btrfs-raid10-root-os
1585 (system-test
1586 (name "btrfs-raid10-root-os")
1587 (description
1588 "Test basic functionality of an OS installed on top of a Btrfs RAID10 file
1589system spanning 4 disks. This test is expensive in terms of CPU and storage
1590usage since we need to build (current-guix) and then store a couple of full
1591system images.")
1592 (value
1593 (mlet* %store-monad
1594 ((images %test-btrfs-raid10-root-images)
1595 (command (qemu-command* images)))
1596 (run-basic-test %btrfs-raid10-root-os command
1597 "btrfs-raid10-root-os")))))
1598
1599(define %test-btrfs-raid10-root-os-degraded
1600 (system-test
1601 (name "btrfs-raid10-root-os-degraded")
1602 (description
1603 "Test basic functionality of an OS installed on top of a Btrfs RAID10 file
1604system spanning 6 disks, degraded to 5 disks. This test is expensive in terms
1605of CPU and storage usage since we need to build (current-guix) and then store
1606a couple of full system images.")
1607 (value
1608 (mlet* %store-monad
1609 ;; Drop the first image; this boots because the root file system uses
1610 ;; the Btrfs "degraded" mount option.
1611 ((images %test-btrfs-raid10-root-images)
1612 (command (qemu-command* #~(cdr #$images))))
1613 (run-basic-test %btrfs-raid10-root-os command
1614 "btrfs-raid10-root-os")))))
1615
1616
1617;;;
1618;;; JFS root file system.
1619;;;
1620
1621(define-os-with-source (%jfs-root-os %jfs-root-os-source)
1622 ;; The OS we want to install.
1623 (use-modules (gnu) (gnu tests) (srfi srfi-1))
1624
1625 (operating-system
1626 (host-name "liberigilo")
1627 (timezone "Europe/Paris")
1628 (locale "en_US.UTF-8")
1629
1630 (bootloader (bootloader-configuration
1631 (bootloader grub-bootloader)
1632 (targets (list "/dev/vdb"))))
1633 (kernel-arguments '("console=ttyS0"))
1634 (file-systems (cons (file-system
1635 (device (file-system-label "my-root"))
1636 (mount-point "/")
1637 (type "jfs"))
1638 %base-file-systems))
1639 (users (cons (user-account
1640 (name "charlie")
1641 (group "users")
1642 (supplementary-groups '("wheel" "audio" "video")))
1643 %base-user-accounts))
1644 (services (cons (service marionette-service-type
1645 (marionette-configuration
1646 (imported-modules '((gnu services herd)
1647 (guix combinators)))))
1648 %base-services))))
1649
1650(define %jfs-root-installation-script
1651 ;; Shell script of a simple installation.
1652 "\
1653. /etc/profile
1654set -e -x
1655guix --version
1656
1657export GUIX_BUILD_OPTIONS=--no-grafts
1658ls -l /run/current-system/gc-roots
1659parted --script /dev/vdb mklabel gpt \\
1660 mkpart primary ext2 1M 3M \\
1661 mkpart primary ext2 3M 2G \\
1662 set 1 boot on \\
1663 set 1 bios_grub on
1664jfs_mkfs -L my-root -q /dev/vdb2
1665mount /dev/vdb2 /mnt
1666herd start cow-store /mnt
1667mkdir /mnt/etc
1668cp /etc/target-config.scm /mnt/etc/config.scm
1669guix system build /mnt/etc/config.scm
1670guix system init /mnt/etc/config.scm /mnt --no-substitutes
1671sync
1672reboot\n")
1673
1674(define %test-jfs-root-os
1675 (system-test
1676 (name "jfs-root-os")
1677 (description
1678 "Test basic functionality of an OS installed like one would do by hand.
1679This test is expensive in terms of CPU and storage usage since we need to
1680build (current-guix) and then store a couple of full system images.")
1681 (value
1682 (mlet* %store-monad ((images (run-install %jfs-root-os
1683 %jfs-root-os-source
1684 #:script
1685 %jfs-root-installation-script))
1686 (command (qemu-command* images)))
1687 (run-basic-test %jfs-root-os command "jfs-root-os")))))
1688
1689
1690;;;
1691;;; F2FS root file system.
1692;;;
1693
1694(define-os-with-source (%f2fs-root-os %f2fs-root-os-source)
1695 ;; The OS we want to install.
1696 (use-modules (gnu) (gnu tests) (srfi srfi-1))
1697
1698 (operating-system
1699 (host-name "liberigilo")
1700 (timezone "Europe/Paris")
1701 (locale "en_US.UTF-8")
1702
1703 (bootloader (bootloader-configuration
1704 (bootloader grub-bootloader)
1705 (targets (list "/dev/vdb"))))
1706 (kernel-arguments '("console=ttyS0"))
1707 (file-systems (cons (file-system
1708 (device (file-system-label "my-root"))
1709 (mount-point "/")
1710 (type "f2fs"))
1711 %base-file-systems))
1712 (users (cons (user-account
1713 (name "charlie")
1714 (group "users")
1715 (supplementary-groups '("wheel" "audio" "video")))
1716 %base-user-accounts))
1717 (services (cons (service marionette-service-type
1718 (marionette-configuration
1719 (imported-modules '((gnu services herd)
1720 (guix combinators)))))
1721 %base-services))))
1722
1723(define %f2fs-root-installation-script
1724 ;; Shell script of a simple installation.
1725 "\
1726. /etc/profile
1727set -e -x
1728guix --version
1729
1730export GUIX_BUILD_OPTIONS=--no-grafts
1731ls -l /run/current-system/gc-roots
1732parted --script /dev/vdb mklabel gpt \\
1733 mkpart primary ext2 1M 3M \\
1734 mkpart primary ext2 3M 2G \\
1735 set 1 boot on \\
1736 set 1 bios_grub on
1737mkfs.f2fs -l my-root -q /dev/vdb2
1738mount /dev/vdb2 /mnt
1739herd start cow-store /mnt
1740mkdir /mnt/etc
1741cp /etc/target-config.scm /mnt/etc/config.scm
1742guix system build /mnt/etc/config.scm
1743guix system init /mnt/etc/config.scm /mnt --no-substitutes
1744sync
1745reboot\n")
1746
1747(define %test-f2fs-root-os
1748 (system-test
1749 (name "f2fs-root-os")
1750 (description
1751 "Test basic functionality of an OS installed like one would do by hand.
1752This test is expensive in terms of CPU and storage usage since we need to
1753build (current-guix) and then store a couple of full system images.")
1754 (value
1755 (mlet* %store-monad ((images (run-install %f2fs-root-os
1756 %f2fs-root-os-source
1757 #:script
1758 %f2fs-root-installation-script))
1759 (command (qemu-command* images)))
1760 (run-basic-test %f2fs-root-os command "f2fs-root-os")))))
1761
1762
1763;;;
1764;;; XFS root file system.
1765;;;
1766
1767(define-os-with-source (%xfs-root-os %xfs-root-os-source)
1768 ;; The OS we want to install.
1769 (use-modules (gnu) (gnu tests) (srfi srfi-1))
1770
1771 (operating-system
1772 (host-name "liberigilo")
1773 (timezone "Europe/Paris")
1774 (locale "en_US.UTF-8")
1775
1776 (bootloader (bootloader-configuration
1777 (bootloader grub-bootloader)
1778 (targets (list "/dev/vdb"))))
1779 (kernel-arguments '("console=ttyS0"))
1780 (file-systems (cons (file-system
1781 (device (file-system-label "my-root"))
1782 (mount-point "/")
1783 (type "xfs"))
1784 %base-file-systems))
1785 (users (cons (user-account
1786 (name "charlie")
1787 (group "users")
1788 (supplementary-groups '("wheel" "audio" "video")))
1789 %base-user-accounts))
1790 (services (cons (service marionette-service-type
1791 (marionette-configuration
1792 (imported-modules '((gnu services herd)
1793 (guix combinators)))))
1794 %base-services))))
1795
1796(define %xfs-root-installation-script
1797 ;; Shell script of a simple installation.
1798 "\
1799. /etc/profile
1800set -e -x
1801guix --version
1802
1803export GUIX_BUILD_OPTIONS=--no-grafts
1804ls -l /run/current-system/gc-roots
1805parted --script /dev/vdb mklabel gpt \\
1806 mkpart primary ext2 1M 3M \\
1807 mkpart primary ext2 3M 2G \\
1808 set 1 boot on \\
1809 set 1 bios_grub on
1810mkfs.xfs -L my-root -q /dev/vdb2
1811mount /dev/vdb2 /mnt
1812herd start cow-store /mnt
1813mkdir /mnt/etc
1814cp /etc/target-config.scm /mnt/etc/config.scm
1815guix system build /mnt/etc/config.scm
1816guix system init /mnt/etc/config.scm /mnt --no-substitutes
1817sync
1818reboot\n")
1819
1820(define %test-xfs-root-os
1821 (system-test
1822 (name "xfs-root-os")
1823 (description
1824 "Test basic functionality of an OS installed like one would do by hand.
1825This test is expensive in terms of CPU and storage usage since we need to
1826build (current-guix) and then store a couple of full system images.")
1827 (value
1828 (mlet* %store-monad ((images (run-install %xfs-root-os
1829 %xfs-root-os-source
1830 #:script
1831 %xfs-root-installation-script))
1832 (command (qemu-command* images)))
1833 (run-basic-test %xfs-root-os command "xfs-root-os")))))
1834
1835
1836;;;
1837;;; Installation through the graphical interface.
1838;;;
1839
1840(define %root-password "foo")
1841
1842(define* (gui-test-program marionette
1843 #:key
1844 (desktop? #f)
1845 (encrypted? #f)
1846 (uefi-support? #f)
1847 (system (%current-system)))
1848 #~(let ()
1849 (define (screenshot file)
1850 (marionette-control (string-append "screendump " file)
1851 #$marionette))
1852
1853 (define-syntax-rule (marionette-eval* exp marionette)
1854 (or (marionette-eval exp marionette)
1855 (throw 'marionette-eval-failure 'exp)))
1856
1857 (setvbuf (current-output-port) 'none)
1858 (setvbuf (current-error-port) 'none)
1859
1860 (marionette-eval* '(use-modules (gnu installer tests)
1861 (guix build utils))
1862 #$marionette)
1863
1864 ;; Arrange so that 'converse' prints debugging output to the console.
1865 (marionette-eval* '(let ((console (open-output-file "/dev/console")))
1866 (setvbuf console 'none)
1867 (conversation-log-port console))
1868 #$marionette)
1869
1870 ;; Tell the installer to not wait for the Connman "online" status.
1871 (marionette-eval* '(call-with-output-file "/tmp/installer-assume-online"
1872 (const #t))
1873 #$marionette)
1874
1875 ;; Run 'guix system init' with '--no-grafts', to cope with the lack of
1876 ;; network access.
1877 (marionette-eval* '(call-with-output-file
1878 "/tmp/installer-system-init-options"
1879 (lambda (port)
1880 (write '("--no-grafts" "--no-substitutes")
1881 port)))
1882 #$marionette)
1883
1884 (marionette-eval* '(define installer-socket
1885 (open-installer-socket))
1886 #$marionette)
1887 (screenshot "installer-start.ppm")
1888
1889 (marionette-eval* '(choose-locale+keyboard
1890 installer-socket
1891 #:timezone '("Europe" "Paris"))
1892 #$marionette)
1893 (screenshot "installer-locale.ppm")
1894
1895 ;; Choose the host name that the "basic" test expects.
1896 (marionette-eval* '(enter-host-name+passwords installer-socket
1897 #:host-name "liberigilo"
1898 #:root-password
1899 #$%root-password
1900 #:users
1901 '(("alice" "pass1")
1902 ("bob" "pass2")))
1903 #$marionette)
1904 (screenshot "installer-services.ppm")
1905
1906 (when #$(target-x86?)
1907 (marionette-eval* '(choose-kernel installer-socket) #$marionette)
1908 (screenshot "installer-kernel.ppm"))
1909
1910 (marionette-eval* '(choose-services installer-socket
1911 #:choose-desktop-environment?
1912 (const #$desktop?)
1913 #:choose-network-service?
1914 (const #f))
1915 #$marionette)
1916 (screenshot "installer-partitioning.ppm")
1917
1918 (marionette-eval* '(choose-partitioning installer-socket
1919 #:encrypted? #$encrypted?
1920 #:passphrase #$%luks-passphrase
1921 #:uefi-support? #$uefi-support?)
1922 #$marionette)
1923 (screenshot "installer-run.ppm")
1924
1925 (unless #$encrypted?
1926 ;; At this point, user partitions are formatted and the installer is
1927 ;; waiting for us to start the final step: generating the
1928 ;; configuration file, etc. Set a fixed UUID on the swap partition
1929 ;; that matches what 'installation-target-os-for-gui-tests' expects.
1930 (marionette-eval* '(invoke #$(file-append util-linux "/sbin/swaplabel")
1931 "-U" "11111111-2222-3333-4444-123456789abc"
1932 "/dev/vda2")
1933 #$marionette))
1934
1935 (marionette-eval* '(start-installation installer-socket)
1936 #$marionette)
1937
1938 ;; XXX: The grub-install process uses efibootmgr to add an UEFI Guix
1939 ;; boot entry. The corresponding UEFI variable is stored in RAM, and
1940 ;; possibly saved persistently on QEMU reboot in a NvVars file, see:
1941 ;; https://lists.gnu.org/archive/html/qemu-discuss/2018-04/msg00045.html.
1942 ;;
1943 ;; As we are running QEMU with the no-reboot flag, this variable is
1944 ;; never saved persistently, QEMU fails to boot the installed system and
1945 ;; an UEFI shell is displayed instead.
1946 ;;
1947 ;; To make the installed UEFI system bootable, register Grub as the
1948 ;; default UEFI boot entry, in the same way as if grub-install was
1949 ;; invoked with the --removable option.
1950 (when #$uefi-support?
1951 (marionette-eval*
1952 '(begin
1953 (use-modules (ice-9 match))
1954 (let ((targets (cond
1955 ((string-prefix? "x86_64" #$system)
1956 '("grubx64.efi" "BOOTX64.EFI"))
1957 ((string-prefix? "i686" #$system)
1958 '("grubia32.efi" "BOOTIA32.EFI"))
1959 (else #f))))
1960 (match targets
1961 ((src dest)
1962 (rename-file "/mnt/boot/efi/EFI/Guix"
1963 "/mnt/boot/efi/EFI/BOOT")
1964 (rename-file
1965 (string-append "/mnt/boot/efi/EFI/BOOT/" src)
1966 (string-append "/mnt/boot/efi/EFI/BOOT/" dest)))
1967 (_ #f))))
1968 #$marionette))
1969
1970 (marionette-eval* '(complete-installation installer-socket)
1971 #$marionette)
1972 (sync)
1973 #t))
1974
1975(define %extra-encrypted-packages
1976 ;; Packages needed when installing with an encrypted root.
1977 (list dhcpcd
1978 lvm2-static cryptsetup-static e2fsck/static
1979 loadkeys-static grub-efi fatfsck/static dosfstools))
1980
1981(define %extra-desktop-packages
1982 ;; Packages needed when using a desktop system containing fonts
1983 ;; in the base system.
1984 (list font-google-noto
1985 font-google-noto-emoji
1986 font-sarasa-gothic
1987 ;; These are used for profile hooks
1988 mkfontscale
1989 mkfontdir))
1990
1991(define %extra-mandb-packages
1992 ;; Packages needed for building man pages during profile hook
1993 (list guile-gdbm-ffi
1994 guile-zlib
1995 guile-zstd))
1996
1997(define installation-os-for-gui-tests
1998 ;; Operating system that contains all of %EXTRA-PACKAGES, needed for the
1999 ;; target OS, as well as syslog output redirected to the console so we can
2000 ;; see what the installer is up to.
2001 (marionette-operating-system
2002 (operating-system
2003 (inherit (operating-system-with-console-syslog
2004 (operating-system-add-packages
2005 installation-os
2006 (append %extra-encrypted-packages
2007 %extra-mandb-packages
2008 %extra-desktop-packages))))
2009 (kernel-arguments '("console=ttyS0")))
2010 #:imported-modules '((gnu services herd)
2011 (gnu installer tests)
2012 (guix combinators))))
2013
2014(define* (installation-target-os-for-gui-tests
2015 #:key
2016 (encrypted? #f)
2017 (uefi-support? #f))
2018 (operating-system
2019 (inherit %minimal-os-on-vda)
2020 (file-systems `(,(file-system
2021 (device (file-system-label "my-root"))
2022 (mount-point "/")
2023 (type "ext4"))
2024 ,@(if uefi-support?
2025 (list (file-system
2026 (device (uuid "1234-ABCD" 'fat))
2027 (mount-point "/boot/efi")
2028 (type "vfat")))
2029 '())
2030 ,@%base-file-systems))
2031 (users (append (list (user-account
2032 (name "alice")
2033 (comment "Bob's sister")
2034 (group "users")
2035 (supplementary-groups
2036 '("wheel" "audio" "video")))
2037 (user-account
2038 (name "bob")
2039 (comment "Alice's brother")
2040 (group "users")
2041 (supplementary-groups
2042 '("wheel" "audio" "video"))))
2043 %base-user-accounts))
2044 ;; The installer does not create a swap device in guided mode with
2045 ;; encryption support. The installer produces a UUID for the partition;
2046 ;; this "UUID" is explicitly set in 'gui-test-program' to the value shown
2047 ;; below.
2048 (swap-devices
2049 (if encrypted?
2050 '()
2051 (list
2052 (swap-space
2053 (target (uuid "11111111-2222-3333-4444-123456789abc"))))))
2054 (services (cons* (service dhcpcd-service-type)
2055 (service ntp-service-type)
2056 (operating-system-user-services %minimal-os-on-vda)))))
2057
2058(define* (installation-target-desktop-os-for-gui-tests
2059 #:key (encrypted? #f))
2060 (operating-system
2061 (inherit (installation-target-os-for-gui-tests
2062 #:encrypted? encrypted?))
2063 (keyboard-layout (keyboard-layout "us" "altgr-intl"))
2064
2065 ;; Make sure that all the packages and services that may be used by the
2066 ;; graphical installer are available.
2067 (packages (append
2068 (list icewm openbox awesome i3-wm i3status
2069 dmenu st ratpoison xterm
2070 emacs emacs-exwm emacs-desktop-environment
2071 sway wmenu foot)
2072 %base-packages))
2073 (services
2074 (append
2075 (list (service gnome-desktop-service-type)
2076 (service xfce-desktop-service-type)
2077 (service mate-desktop-service-type)
2078 (service plasma-desktop-service-type)
2079 (set-xorg-configuration
2080 (xorg-configuration
2081 (keyboard-layout keyboard-layout)))
2082 (service marionette-service-type
2083 (marionette-configuration
2084 (imported-modules '((gnu services herd)
2085 (guix build utils)
2086 (guix combinators))))))
2087 %desktop-services))))
2088
2089(define* (guided-installation-test name
2090 #:key
2091 (desktop? #f)
2092 (encrypted? #f)
2093 (uefi-support? #f)
2094 target-os
2095 (installer-memory "2048")
2096 (install-size 'guess)
2097 (target-size (* 2200 MiB)))
2098 (system-test
2099 (name name)
2100 (description
2101 "Install an OS using the graphical installer and test it.")
2102 (value
2103 (mlet* %store-monad
2104 ((images (run-install target-os '(this is unused)
2105 #:script #f
2106 #:os installation-os-for-gui-tests
2107 #:uefi-support? uefi-support?
2108 #:install-size install-size
2109 #:target-size target-size
2110 #:memory installer-memory
2111 #:installation-image-type
2112 'uncompressed-iso9660
2113 #:gui-test
2114 (lambda (marionette)
2115 (gui-test-program
2116 marionette
2117 #:desktop? desktop?
2118 #:encrypted? encrypted?
2119 #:uefi-support? uefi-support?))))
2120 (command (qemu-command* images
2121 #:uefi-support? uefi-support?
2122 #:memory-size 512)))
2123 (run-basic-test target-os command name
2124 #:initialization (and encrypted? enter-luks-passphrase)
2125 #:root-password %root-password
2126 #:desktop? desktop?)))))
2127
2128(define %test-gui-installed-os
2129 (guided-installation-test
2130 "gui-installed-os"
2131 #:target-os (installation-target-os-for-gui-tests)))
2132
2133;; Test the UEFI installation of Guix System using the graphical installer.
2134(define %test-gui-uefi-installed-os
2135 (guided-installation-test
2136 "gui-uefi-installed-os"
2137 #:uefi-support? #t
2138 #:target-os (installation-target-os-for-gui-tests
2139 #:uefi-support? #t)
2140 #:target-size (* 4100 MiB)))
2141
2142(define %test-gui-installed-os-encrypted
2143 (guided-installation-test
2144 "gui-installed-os-encrypted"
2145 #:encrypted? #t
2146 #:target-os (installation-target-os-for-gui-tests
2147 #:encrypted? #t)))
2148
2149;; Building a desktop image is very time and space consuming. Install all
2150;; desktop environments in a single test to reduce the overhead.
2151(define %test-gui-installed-desktop-os-encrypted
2152 (guided-installation-test "gui-installed-desktop-os-encrypted"
2153 #:desktop? #t
2154 #:encrypted? #t
2155 #:target-os
2156 (installation-target-desktop-os-for-gui-tests
2157 #:encrypted? #t)
2158 ;; XXX: The disk-image size guess is too low. Use
2159 ;; a constant value until this is fixed.
2160 #:install-size (* 15000 MiB)
2161 #:target-size (* 15000 MiB)))
2162
2163;;; install.scm ends here