1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
20 (define-module (test-system)
22 #:use-module ((gnu services) #:select (service-value))
23 #:use-module (guix store)
24 #:use-module (srfi srfi-1)
25 #:use-module (srfi srfi-64))
27 ;; Test the (gnu system) module.
31 (device (file-system-label "my-root"))
37 (host-name "komputilo")
38 (timezone "Europe/Berlin")
40 (bootloader (bootloader-configuration
41 (bootloader grub-bootloader)
43 (file-systems (cons %root-fs %base-file-systems))
45 (users %base-user-accounts)))
49 (source "/dev/foo") (target "my-luks-device")
50 (type luks-device-mapping)))
52 (define %os-with-mapped-device
54 (host-name "komputilo")
55 (timezone "Europe/Berlin")
57 (bootloader (bootloader-configuration
58 (bootloader grub-bootloader)
60 (mapped-devices (list %luks-device))
61 (file-systems (cons (file-system
63 (dependencies (list %luks-device)))
65 (users %base-user-accounts)))
70 (test-assert "operating-system-store-file-system"
71 ;; %BASE-FILE-SYSTEMS defines a bind-mount for /gnu/store, but this
72 ;; shouldn't be a problem.
74 (operating-system-store-file-system %os)))
76 (test-assert "operating-system-store-file-system, prefix"
77 (let* ((gnu (file-system
79 (mount-point (dirname (%store-prefix)))
83 (file-systems (cons* gnu %root-fs
84 %base-file-systems)))))
85 (eq? gnu (operating-system-store-file-system os))))
87 (test-assert "operating-system-store-file-system, store"
88 (let* ((gnu (file-system
90 (mount-point (%store-prefix))
94 (file-systems (cons* gnu %root-fs
95 %base-file-systems)))))
96 (eq? gnu (operating-system-store-file-system os))))
98 (test-equal "operating-system-user-mapped-devices"
100 (operating-system-user-mapped-devices %os-with-mapped-device))
102 (test-equal "operating-system-boot-mapped-devices"
104 (operating-system-boot-mapped-devices %os-with-mapped-device))
106 (test-equal "operating-system-boot-mapped-devices, implicit dependency"
109 ;; Here we expect the implicit dependency between "/" and
110 ;; "/dev/mapper/my-luks-device" to be found, in spite of the lack of a
111 ;; 'dependencies' field in the root file system.
112 (operating-system-boot-mapped-devices
114 (inherit %os-with-mapped-device)
115 (file-systems (cons (file-system
116 (device "/dev/mapper/my-luks-device")
119 %base-file-systems)))))
121 (test-equal "non-boot-file-system-service"
124 ;; Make sure that mapped devices with at least one needed-for-boot user are
125 ;; handled exclusively from the initrd. See <https://bugs.gnu.org/31889>.
126 (append-map file-system-dependencies
128 ((@@ (gnu system) non-boot-file-system-service)
130 (inherit %os-with-mapped-device)
133 (mount-point "/foo/bar")
136 (dependencies (list %luks-device)))
138 (device (file-system-label "my-root"))
141 (dependencies (list %luks-device))))))))))