install.scm 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2017, 2019, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
  5. ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
  6. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  7. ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  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. (define-module (gnu tests install)
  24. #:use-module (gnu)
  25. #:use-module (gnu bootloader extlinux)
  26. #:use-module (gnu image)
  27. #:use-module (gnu tests)
  28. #:use-module (gnu tests base)
  29. #:use-module (gnu system)
  30. #:use-module (gnu system image)
  31. #:use-module (gnu system install)
  32. #:use-module (gnu system vm)
  33. #:use-module ((gnu build marionette) #:select (qemu-command))
  34. #:use-module (gnu packages admin)
  35. #:use-module (gnu packages bootloaders)
  36. #:use-module (gnu packages commencement) ;for 'guile-final'
  37. #:use-module (gnu packages cryptsetup)
  38. #:use-module (gnu packages disk)
  39. #:use-module (gnu packages emacs)
  40. #:use-module (gnu packages emacs-xyz)
  41. #:use-module (gnu packages firmware)
  42. #:use-module (gnu packages linux)
  43. #:use-module (gnu packages ocr)
  44. #:use-module (gnu packages openbox)
  45. #:use-module (gnu packages package-management)
  46. #:use-module (gnu packages ratpoison)
  47. #:use-module (gnu packages suckless)
  48. #:use-module (gnu packages virtualization)
  49. #:use-module (gnu packages wm)
  50. #:use-module (gnu packages xorg)
  51. #:use-module (gnu services desktop)
  52. #:use-module (gnu services networking)
  53. #:use-module (gnu services xorg)
  54. #:use-module (guix store)
  55. #:use-module (guix monads)
  56. #:use-module (guix packages)
  57. #:use-module (guix grafts)
  58. #:use-module (guix gexp)
  59. #:use-module (guix utils)
  60. #:use-module (srfi srfi-1)
  61. #:export (%test-installed-os
  62. %test-installed-extlinux-os
  63. %test-iso-image-installer
  64. %test-separate-store-os
  65. %test-separate-home-os
  66. %test-raid-root-os
  67. %test-encrypted-root-os
  68. %test-encrypted-root-not-boot-os
  69. %test-btrfs-root-os
  70. %test-btrfs-root-on-subvolume-os
  71. %test-btrfs-raid-root-os
  72. %test-btrfs-raid10-root-os
  73. %test-btrfs-raid10-root-os-degraded
  74. %test-jfs-root-os
  75. %test-f2fs-root-os
  76. %test-xfs-root-os
  77. %test-lvm-separate-home-os
  78. %test-gui-installed-os
  79. %test-gui-uefi-installed-os
  80. %test-gui-installed-os-encrypted
  81. %test-gui-installed-desktop-os-encrypted))
  82. ;;; Commentary:
  83. ;;;
  84. ;;; Test the installation of Guix using the documented approach at the
  85. ;;; command line.
  86. ;;;
  87. ;;; Code:
  88. (define-os-with-source (%minimal-os %minimal-os-source)
  89. ;; The OS we want to install.
  90. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  91. (operating-system
  92. (host-name "liberigilo")
  93. (timezone "Europe/Paris")
  94. (locale "en_US.UTF-8")
  95. (bootloader (bootloader-configuration
  96. (bootloader grub-bootloader)
  97. (targets (list "/dev/vdb"))))
  98. (kernel-arguments '("console=ttyS0"))
  99. (file-systems (cons (file-system
  100. (device (file-system-label "my-root"))
  101. (mount-point "/")
  102. (type "ext4"))
  103. %base-file-systems))
  104. (users (cons (user-account
  105. (name "alice")
  106. (comment "Bob's sister")
  107. (group "users")
  108. (supplementary-groups '("wheel" "audio" "video")))
  109. %base-user-accounts))
  110. (services (cons (service marionette-service-type
  111. (marionette-configuration
  112. (imported-modules '((gnu services herd)
  113. (guix build utils)
  114. (guix combinators)))))
  115. %base-services))))
  116. (define (operating-system-add-packages os packages)
  117. "Append PACKAGES to OS packages list."
  118. (operating-system
  119. (inherit os)
  120. (packages (append packages (operating-system-packages os)))))
  121. (define-os-with-source (%minimal-extlinux-os
  122. %minimal-extlinux-os-source)
  123. (use-modules (gnu) (gnu tests) (gnu bootloader extlinux)
  124. (srfi srfi-1))
  125. (operating-system
  126. (host-name "liberigilo")
  127. (timezone "Europe/Paris")
  128. (locale "en_US.UTF-8")
  129. (bootloader (bootloader-configuration
  130. (bootloader extlinux-bootloader-gpt)
  131. (targets (list "/dev/vdb"))))
  132. (kernel-arguments '("console=ttyS0"))
  133. (file-systems (cons (file-system
  134. (device (file-system-label "my-root"))
  135. (mount-point "/")
  136. (type "ext4"))
  137. %base-file-systems))
  138. (services (cons (service marionette-service-type
  139. (marionette-configuration
  140. (imported-modules '((gnu services herd)
  141. (guix combinators)))))
  142. %base-services))))
  143. (define (operating-system-with-current-guix os)
  144. "Return a variant of OS that uses the current Guix."
  145. (operating-system
  146. (inherit os)
  147. (services (modify-services (operating-system-user-services os)
  148. (guix-service-type config =>
  149. (guix-configuration
  150. (inherit config)
  151. (guix (current-guix))))))))
  152. (define MiB (expt 2 20))
  153. (define %simple-installation-script
  154. ;; Shell script of a simple installation.
  155. "\
  156. . /etc/profile
  157. set -e -x
  158. guix --version
  159. export GUIX_BUILD_OPTIONS=--no-grafts
  160. guix build isc-dhcp
  161. parted --script /dev/vdb mklabel gpt \\
  162. mkpart primary ext2 1M 3M \\
  163. mkpart primary ext2 3M 1.6G \\
  164. set 1 boot on \\
  165. set 1 bios_grub on
  166. mkfs.ext4 -L my-root /dev/vdb2
  167. mount /dev/vdb2 /mnt
  168. df -h /mnt
  169. herd start cow-store /mnt
  170. mkdir /mnt/etc
  171. cp /etc/target-config.scm /mnt/etc/config.scm
  172. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  173. sync
  174. reboot\n")
  175. (define %extlinux-gpt-installation-script
  176. ;; Shell script of a simple installation.
  177. ;; As syslinux 6.0.3 does not handle 64bits ext4 partitions,
  178. ;; we make sure to pass -O '^64bit' to mkfs.
  179. "\
  180. . /etc/profile
  181. set -e -x
  182. guix --version
  183. export GUIX_BUILD_OPTIONS=--no-grafts
  184. guix build isc-dhcp
  185. parted --script /dev/vdb mklabel gpt \\
  186. mkpart ext2 1M 1.6G \\
  187. set 1 legacy_boot on
  188. mkfs.ext4 -L my-root -O '^64bit' /dev/vdb1
  189. mount /dev/vdb1 /mnt
  190. df -h /mnt
  191. herd start cow-store /mnt
  192. mkdir /mnt/etc
  193. cp /etc/target-config.scm /mnt/etc/config.scm
  194. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  195. sync
  196. reboot\n")
  197. (define (uefi-firmware system)
  198. "Return the appropriate QEMU OVMF UEFI firmware for the given SYSTEM."
  199. (cond
  200. ((string-prefix? "x86_64" system)
  201. (file-append ovmf "/share/firmware/ovmf_x64.bin"))
  202. ((string-prefix? "i686" system)
  203. (file-append ovmf "/share/firmware/ovmf_ia32.bin"))
  204. (else #f)))
  205. (define* (run-install target-os target-os-source
  206. #:key
  207. (script %simple-installation-script)
  208. (gui-test #f)
  209. (packages '())
  210. (os (marionette-operating-system
  211. (operating-system
  212. ;; Since the image has no network access, use the
  213. ;; current Guix so the store items we need are in
  214. ;; the image and add packages provided.
  215. (inherit (operating-system-with-current-guix
  216. installation-os))
  217. (kernel-arguments '("console=ttyS0")))
  218. #:imported-modules '((gnu services herd)
  219. (gnu installer tests)
  220. (guix combinators))))
  221. (uefi-support? #f)
  222. (installation-image-type 'efi-raw)
  223. (install-size 'guess)
  224. (target-size (* 2200 MiB))
  225. (number-of-disks 1))
  226. "Run SCRIPT (a shell script following the system installation procedure) in
  227. OS to install TARGET-OS. Return the VM disk images of TARGET-SIZE bytes
  228. containing the installed system. PACKAGES is a list of packages added to OS.
  229. NUMBER-OF-DISKS can be used to specify a number of disks different than one,
  230. such as for RAID systems."
  231. (mlet* %store-monad ((_ (set-grafting #f))
  232. (system (current-system))
  233. (uefi-firmware -> (and uefi-support?
  234. (uefi-firmware system)))
  235. ;; Since the installation system has no network access,
  236. ;; we cheat a little bit by adding TARGET to its GC
  237. ;; roots. This way, we know 'guix system init' will
  238. ;; succeed. Also add guile-final, which is pulled in
  239. ;; through provenance.drv and may not always be present.
  240. (target (operating-system-derivation target-os))
  241. (base-image -> (os->image
  242. (operating-system-with-gc-roots
  243. (operating-system-add-packages
  244. os packages)
  245. (list target guile-final))
  246. #:type (lookup-image-type-by-name
  247. installation-image-type)))
  248. (image ->
  249. (system-image
  250. (image
  251. (inherit base-image)
  252. (size install-size)
  253. ;; Don't provide substitutes; too big.
  254. (substitutable? #f)))))
  255. (define install
  256. (with-imported-modules '((guix build utils)
  257. (gnu build marionette))
  258. #~(begin
  259. (use-modules (guix build utils)
  260. (gnu build marionette)
  261. (srfi srfi-1))
  262. (set-path-environment-variable "PATH" '("bin")
  263. (list #$qemu-minimal))
  264. (mkdir-p #$output)
  265. (for-each (lambda (n)
  266. (system* "qemu-img" "create" "-f" "qcow2"
  267. (format #f "~a/disk~a.qcow2" #$output n)
  268. #$(number->string target-size)))
  269. (iota #$number-of-disks))
  270. (define marionette
  271. (make-marionette
  272. `(,(which #$(qemu-command system))
  273. "-no-reboot"
  274. "-m" "1200"
  275. ,@(if #$uefi-firmware
  276. '("-bios" #$uefi-firmware)
  277. '())
  278. #$@(cond
  279. ((eq? 'efi-raw installation-image-type)
  280. #~("-drive"
  281. ,(string-append "file=" #$image
  282. ",if=virtio,readonly")))
  283. ((eq? 'uncompressed-iso9660 installation-image-type)
  284. #~("-cdrom" #$image))
  285. (else
  286. (error
  287. "unsupported installation-image-type:"
  288. installation-image-type)))
  289. ,@(append-map
  290. (lambda (n)
  291. (list "-drive"
  292. (format #f "file=~a/disk~a.qcow2,if=virtio"
  293. #$output n)))
  294. (iota #$number-of-disks))
  295. ,@(if (file-exists? "/dev/kvm")
  296. '("-enable-kvm")
  297. '()))))
  298. (pk 'uname (marionette-eval '(uname) marionette))
  299. ;; Wait for tty1.
  300. (marionette-eval '(begin
  301. (use-modules (gnu services herd))
  302. (start 'term-tty1))
  303. marionette)
  304. (when #$(->bool script)
  305. (marionette-eval '(call-with-output-file "/etc/target-config.scm"
  306. (lambda (port)
  307. (write '#$target-os-source port)))
  308. marionette)
  309. ;; Run SCRIPT. It typically invokes 'reboot' as a last step and
  310. ;; thus normally gets killed with SIGTERM by PID 1.
  311. (let ((status (marionette-eval '(system #$script) marionette)))
  312. (exit (or (eof-object? status)
  313. (equal? (status:term-sig status) SIGTERM)
  314. (equal? (status:exit-val status) 0)))))
  315. (when #$(->bool gui-test)
  316. (wait-for-unix-socket "/var/guix/installer-socket"
  317. marionette)
  318. (format #t "installer socket ready~%")
  319. (force-output)
  320. (exit #$(and gui-test
  321. (gui-test #~marionette)))))))
  322. (mlet %store-monad ((images-dir (gexp->derivation "installation"
  323. install
  324. #:substitutable? #f))) ;too big
  325. (return (with-imported-modules '((guix build utils))
  326. #~(begin
  327. (use-modules (guix build utils))
  328. (find-files #$images-dir)))))))
  329. (define* (qemu-command* images #:key (uefi-support? #f) (memory-size 256))
  330. "Return as a monadic value the command to run QEMU with a writable overlay
  331. on top of IMAGES, a list of disk images. The QEMU VM has access to MEMORY-SIZE
  332. MiB of RAM."
  333. (mlet* %store-monad ((system (current-system))
  334. (uefi-firmware -> (and uefi-support?
  335. (uefi-firmware system))))
  336. (return #~(begin
  337. (use-modules (srfi srfi-1))
  338. `(,(string-append #$qemu-minimal "/bin/"
  339. #$(qemu-command system))
  340. "-snapshot" ;for the volatile, writable overlay
  341. ,@(if (file-exists? "/dev/kvm")
  342. '("-enable-kvm")
  343. '())
  344. ,@(if #$uefi-firmware
  345. '("-bios" #$uefi-firmware)
  346. '())
  347. "-no-reboot" "-m" #$(number->string memory-size)
  348. ,@(append-map (lambda (image)
  349. (list "-drive" (format #f "file=~a,if=virtio"
  350. image)))
  351. #$images))))))
  352. (define %test-installed-os
  353. (system-test
  354. (name "installed-os")
  355. (description
  356. "Test basic functionality of an OS installed like one would do by hand.
  357. This test is expensive in terms of CPU and storage usage since we need to
  358. build (current-guix) and then store a couple of full system images.")
  359. (value
  360. (mlet* %store-monad ((images (run-install %minimal-os %minimal-os-source))
  361. (command (qemu-command* images)))
  362. (run-basic-test %minimal-os command
  363. "installed-os")))))
  364. (define %test-installed-extlinux-os
  365. (system-test
  366. (name "installed-extlinux-os")
  367. (description
  368. "Test basic functionality of an OS booted with an extlinux bootloader. As
  369. per %test-installed-os, this test is expensive in terms of CPU and storage.")
  370. (value
  371. (mlet* %store-monad ((images (run-install %minimal-extlinux-os
  372. %minimal-extlinux-os-source
  373. #:packages
  374. (list syslinux)
  375. #:script
  376. %extlinux-gpt-installation-script))
  377. (command (qemu-command* images)))
  378. (run-basic-test %minimal-extlinux-os command
  379. "installed-extlinux-os")))))
  380. ;;;
  381. ;;; Installation through an ISO image.
  382. ;;;
  383. (define-os-with-source (%minimal-os-on-vda %minimal-os-on-vda-source)
  384. ;; The OS we want to install.
  385. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  386. (operating-system
  387. (host-name "liberigilo")
  388. (timezone "Europe/Paris")
  389. (locale "en_US.UTF-8")
  390. (bootloader (bootloader-configuration
  391. (bootloader grub-bootloader)
  392. (targets (list "/dev/vda"))))
  393. (kernel-arguments '("console=ttyS0"))
  394. (file-systems (cons (file-system
  395. (device (file-system-label "my-root"))
  396. (mount-point "/")
  397. (type "ext4"))
  398. %base-file-systems))
  399. (users (cons (user-account
  400. (name "alice")
  401. (comment "Bob's sister")
  402. (group "users")
  403. (supplementary-groups '("wheel" "audio" "video")))
  404. %base-user-accounts))
  405. (services (cons (service marionette-service-type
  406. (marionette-configuration
  407. (imported-modules '((gnu services herd)
  408. (guix build utils)
  409. (guix combinators)))))
  410. %base-services))))
  411. (define %simple-installation-script-for-/dev/vda
  412. ;; Shell script of a simple installation.
  413. "\
  414. . /etc/profile
  415. set -e -x
  416. guix --version
  417. export GUIX_BUILD_OPTIONS=--no-grafts
  418. guix build isc-dhcp
  419. parted --script /dev/vda mklabel gpt \\
  420. mkpart primary ext2 1M 3M \\
  421. mkpart primary ext2 3M 1.6G \\
  422. set 1 boot on \\
  423. set 1 bios_grub on
  424. mkfs.ext4 -L my-root /dev/vda2
  425. mount /dev/vda2 /mnt
  426. df -h /mnt
  427. herd start cow-store /mnt
  428. mkdir /mnt/etc
  429. cp /etc/target-config.scm /mnt/etc/config.scm
  430. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  431. sync
  432. reboot\n")
  433. (define %test-iso-image-installer
  434. (system-test
  435. (name "iso-image-installer")
  436. (description
  437. "")
  438. (value
  439. (mlet* %store-monad ((images (run-install
  440. %minimal-os-on-vda
  441. %minimal-os-on-vda-source
  442. #:script
  443. %simple-installation-script-for-/dev/vda
  444. #:installation-image-type
  445. 'uncompressed-iso9660))
  446. (command (qemu-command* images)))
  447. (run-basic-test %minimal-os-on-vda command name)))))
  448. ;;;
  449. ;;; Separate /home.
  450. ;;;
  451. (define-os-with-source (%separate-home-os %separate-home-os-source)
  452. ;; The OS we want to install.
  453. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  454. (operating-system
  455. (host-name "liberigilo")
  456. (timezone "Europe/Paris")
  457. (locale "en_US.utf8")
  458. (bootloader (bootloader-configuration
  459. (bootloader grub-bootloader)
  460. (targets '("/dev/vdb"))))
  461. (kernel-arguments '("console=ttyS0"))
  462. (file-systems (cons* (file-system
  463. (device (file-system-label "my-root"))
  464. (mount-point "/")
  465. (type "ext4"))
  466. (file-system
  467. (device "none")
  468. (mount-point "/home")
  469. (type "tmpfs"))
  470. %base-file-systems))
  471. (users (cons* (user-account
  472. (name "alice")
  473. (group "users"))
  474. (user-account
  475. (name "charlie")
  476. (group "users"))
  477. %base-user-accounts))
  478. (services (cons (service marionette-service-type
  479. (marionette-configuration
  480. (imported-modules '((gnu services herd)
  481. (guix combinators)))))
  482. %base-services))))
  483. (define %test-separate-home-os
  484. (system-test
  485. (name "separate-home-os")
  486. (description
  487. "Test basic functionality of an installed OS with a separate /home
  488. partition. In particular, home directories must be correctly created (see
  489. <https://bugs.gnu.org/21108>).")
  490. (value
  491. (mlet* %store-monad ((images (run-install %separate-home-os
  492. %separate-home-os-source
  493. #:script
  494. %simple-installation-script))
  495. (command (qemu-command* images)))
  496. (run-basic-test %separate-home-os command "separate-home-os")))))
  497. ;;;
  498. ;;; Separate /gnu/store partition.
  499. ;;;
  500. (define-os-with-source (%separate-store-os %separate-store-os-source)
  501. ;; The OS we want to install.
  502. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  503. (operating-system
  504. (host-name "liberigilo")
  505. (timezone "Europe/Paris")
  506. (locale "en_US.UTF-8")
  507. (bootloader (bootloader-configuration
  508. (bootloader grub-bootloader)
  509. (targets (list "/dev/vdb"))))
  510. (kernel-arguments '("console=ttyS0"))
  511. (file-systems (cons* (file-system
  512. (device (file-system-label "root-fs"))
  513. (mount-point "/")
  514. (type "ext4"))
  515. (file-system
  516. (device (file-system-label "store-fs"))
  517. (mount-point "/gnu")
  518. (type "ext4"))
  519. %base-file-systems))
  520. (users %base-user-accounts)
  521. (services (cons (service marionette-service-type
  522. (marionette-configuration
  523. (imported-modules '((gnu services herd)
  524. (guix combinators)))))
  525. %base-services))))
  526. (define %separate-store-installation-script
  527. ;; Installation with a separate /gnu partition.
  528. "\
  529. . /etc/profile
  530. set -e -x
  531. guix --version
  532. export GUIX_BUILD_OPTIONS=--no-grafts
  533. guix build isc-dhcp
  534. parted --script /dev/vdb mklabel gpt \\
  535. mkpart primary ext2 1M 3M \\
  536. mkpart primary ext2 3M 400M \\
  537. mkpart primary ext2 400M 2.1G \\
  538. set 1 boot on \\
  539. set 1 bios_grub on
  540. mkfs.ext4 -L root-fs /dev/vdb2
  541. mkfs.ext4 -L store-fs /dev/vdb3
  542. mount /dev/vdb2 /mnt
  543. mkdir /mnt/gnu
  544. mount /dev/vdb3 /mnt/gnu
  545. df -h /mnt
  546. df -h /mnt/gnu
  547. herd start cow-store /mnt
  548. mkdir /mnt/etc
  549. cp /etc/target-config.scm /mnt/etc/config.scm
  550. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  551. sync
  552. reboot\n")
  553. (define %test-separate-store-os
  554. (system-test
  555. (name "separate-store-os")
  556. (description
  557. "Test basic functionality of an OS installed like one would do by hand,
  558. where /gnu lives on a separate partition.")
  559. (value
  560. (mlet* %store-monad ((images (run-install %separate-store-os
  561. %separate-store-os-source
  562. #:script
  563. %separate-store-installation-script))
  564. (command (qemu-command* images)))
  565. (run-basic-test %separate-store-os command "separate-store-os")))))
  566. ;;;
  567. ;;; RAID root device.
  568. ;;;
  569. (define-os-with-source (%raid-root-os %raid-root-os-source)
  570. ;; An OS whose root partition is a RAID partition.
  571. (use-modules (gnu) (gnu tests))
  572. (operating-system
  573. (host-name "raidified")
  574. (timezone "Europe/Paris")
  575. (locale "en_US.utf8")
  576. (bootloader (bootloader-configuration
  577. (bootloader grub-bootloader)
  578. (targets (list "/dev/vdb"))))
  579. (kernel-arguments '("console=ttyS0"))
  580. ;; Add a kernel module for RAID-1 (aka. "mirror").
  581. (initrd-modules (cons "raid1" %base-initrd-modules))
  582. (mapped-devices (list (mapped-device
  583. (source (list "/dev/vda2" "/dev/vda3"))
  584. (target "/dev/md0")
  585. (type raid-device-mapping))))
  586. (file-systems (cons (file-system
  587. (device (file-system-label "root-fs"))
  588. (mount-point "/")
  589. (type "ext4")
  590. (dependencies mapped-devices))
  591. %base-file-systems))
  592. (users %base-user-accounts)
  593. (services (cons (service marionette-service-type
  594. (marionette-configuration
  595. (imported-modules '((gnu services herd)
  596. (guix combinators)))))
  597. %base-services))))
  598. (define %raid-root-installation-script
  599. ;; Installation with a separate /gnu partition. See
  600. ;; <https://raid.wiki.kernel.org/index.php/RAID_setup> for more on RAID and
  601. ;; mdadm.
  602. "\
  603. . /etc/profile
  604. set -e -x
  605. guix --version
  606. export GUIX_BUILD_OPTIONS=--no-grafts
  607. parted --script /dev/vdb mklabel gpt \\
  608. mkpart primary ext2 1M 3M \\
  609. mkpart primary ext2 3M 1.6G \\
  610. mkpart primary ext2 1.6G 3.2G \\
  611. set 1 boot on \\
  612. set 1 bios_grub on
  613. yes | mdadm --create /dev/md0 --verbose --level=mirror --raid-devices=2 \\
  614. /dev/vdb2 /dev/vdb3
  615. mkfs.ext4 -L root-fs /dev/md0
  616. mount /dev/md0 /mnt
  617. df -h /mnt
  618. herd start cow-store /mnt
  619. mkdir /mnt/etc
  620. cp /etc/target-config.scm /mnt/etc/config.scm
  621. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  622. sync
  623. reboot\n")
  624. (define %test-raid-root-os
  625. (system-test
  626. (name "raid-root-os")
  627. (description
  628. "Test functionality of an OS installed with a RAID root partition managed
  629. by 'mdadm'.")
  630. (value
  631. (mlet* %store-monad ((images (run-install %raid-root-os
  632. %raid-root-os-source
  633. #:script
  634. %raid-root-installation-script
  635. #:target-size (* 3200 MiB)))
  636. (command (qemu-command* images)))
  637. (run-basic-test %raid-root-os
  638. `(,@command) "raid-root-os")))))
  639. ;;;
  640. ;;; LUKS-encrypted root file system.
  641. ;;;
  642. (define-os-with-source (%encrypted-root-os %encrypted-root-os-source)
  643. ;; The OS we want to install.
  644. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  645. (operating-system
  646. (host-name "liberigilo")
  647. (timezone "Europe/Paris")
  648. (locale "en_US.UTF-8")
  649. (bootloader (bootloader-configuration
  650. (bootloader grub-bootloader)
  651. (targets '("/dev/vdb"))))
  652. ;; Note: Do not pass "console=ttyS0" so we can use our passphrase prompt
  653. ;; detection logic in 'enter-luks-passphrase'.
  654. (mapped-devices (list (mapped-device
  655. (source (uuid "12345678-1234-1234-1234-123456789abc"))
  656. (target "the-root-device")
  657. (type luks-device-mapping))))
  658. (file-systems (cons (file-system
  659. (device "/dev/mapper/the-root-device")
  660. (mount-point "/")
  661. (type "ext4"))
  662. %base-file-systems))
  663. (users (cons (user-account
  664. (name "charlie")
  665. (group "users")
  666. (supplementary-groups '("wheel" "audio" "video")))
  667. %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. (define %luks-passphrase
  674. ;; LUKS encryption passphrase used in tests.
  675. "thepassphrase")
  676. (define %encrypted-root-installation-script
  677. ;; Shell script of a simple installation.
  678. (string-append "\
  679. . /etc/profile
  680. set -e -x
  681. guix --version
  682. export GUIX_BUILD_OPTIONS=--no-grafts
  683. ls -l /run/current-system/gc-roots
  684. parted --script /dev/vdb mklabel gpt \\
  685. mkpart primary ext2 1M 3M \\
  686. mkpart primary ext2 3M 1.6G \\
  687. set 1 boot on \\
  688. set 1 bios_grub on
  689. echo -n " %luks-passphrase " | \\
  690. cryptsetup luksFormat --uuid=12345678-1234-1234-1234-123456789abc -q /dev/vdb2 -
  691. echo -n " %luks-passphrase " | \\
  692. cryptsetup open --type luks --key-file - /dev/vdb2 the-root-device
  693. mkfs.ext4 -L my-root /dev/mapper/the-root-device
  694. mount LABEL=my-root /mnt
  695. herd start cow-store /mnt
  696. mkdir /mnt/etc
  697. cp /etc/target-config.scm /mnt/etc/config.scm
  698. guix system build /mnt/etc/config.scm
  699. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  700. sync
  701. reboot\n"))
  702. (define (enter-luks-passphrase marionette)
  703. "Return a gexp to be inserted in the basic system test running on MARIONETTE
  704. to enter the LUKS passphrase."
  705. (let ((ocrad (file-append ocrad "/bin/ocrad")))
  706. #~(begin
  707. (define (passphrase-prompt? text)
  708. (string-contains (pk 'screen-text text) "Enter pass"))
  709. (define (bios-boot-screen? text)
  710. ;; Return true if TEXT corresponds to the boot screen, before GRUB's
  711. ;; menu.
  712. (string-prefix? "SeaBIOS" text))
  713. (test-assert "enter LUKS passphrase for GRUB"
  714. (begin
  715. ;; At this point we have no choice but to use OCR to determine
  716. ;; when the passphrase should be entered.
  717. (wait-for-screen-text #$marionette passphrase-prompt?
  718. #:ocrad #$ocrad)
  719. (marionette-type #$(string-append %luks-passphrase "\n")
  720. #$marionette)
  721. ;; Now wait until we leave the boot screen. This is necessary so
  722. ;; we can then be sure we match the "Enter passphrase" prompt from
  723. ;; 'cryptsetup', in the initrd.
  724. (wait-for-screen-text #$marionette (negate bios-boot-screen?)
  725. #:ocrad #$ocrad
  726. #:timeout 20)))
  727. (test-assert "enter LUKS passphrase for the initrd"
  728. (begin
  729. ;; XXX: Here we use OCR as well but we could instead use QEMU
  730. ;; '-serial stdio' and run it in an input pipe,
  731. (wait-for-screen-text #$marionette passphrase-prompt?
  732. #:ocrad #$ocrad
  733. #:timeout 60)
  734. (marionette-type #$(string-append %luks-passphrase "\n")
  735. #$marionette)
  736. ;; Take a screenshot for debugging purposes.
  737. (marionette-control (string-append "screendump " #$output
  738. "/post-initrd-passphrase.ppm")
  739. #$marionette))))))
  740. (define %test-encrypted-root-os
  741. (system-test
  742. (name "encrypted-root-os")
  743. (description
  744. "Test basic functionality of an OS installed like one would do by hand.
  745. This test is expensive in terms of CPU and storage usage since we need to
  746. build (current-guix) and then store a couple of full system images.")
  747. (value
  748. (mlet* %store-monad ((images (run-install %encrypted-root-os
  749. %encrypted-root-os-source
  750. #:script
  751. %encrypted-root-installation-script))
  752. (command (qemu-command* images)))
  753. (run-basic-test %encrypted-root-os command "encrypted-root-os"
  754. #:initialization enter-luks-passphrase)))))
  755. ;;;
  756. ;;; Separate /home on LVM
  757. ;;;
  758. ;; Since LVM support in guix currently doesn't allow root-on-LVM we use /home on LVM
  759. (define-os-with-source (%lvm-separate-home-os %lvm-separate-home-os-source)
  760. (use-modules (gnu) (gnu tests))
  761. (operating-system
  762. (host-name "separate-home-on-lvm")
  763. (timezone "Europe/Paris")
  764. (locale "en_US.utf8")
  765. (bootloader (bootloader-configuration
  766. (bootloader grub-bootloader)
  767. (targets (list "/dev/vdb"))))
  768. (kernel-arguments '("console=ttyS0"))
  769. (mapped-devices (list (mapped-device
  770. (source "vg0")
  771. (target "vg0-home")
  772. (type lvm-device-mapping))))
  773. (file-systems (cons* (file-system
  774. (device (file-system-label "root-fs"))
  775. (mount-point "/")
  776. (type "ext4"))
  777. (file-system
  778. (device "/dev/mapper/vg0-home")
  779. (mount-point "/home")
  780. (type "ext4")
  781. (dependencies mapped-devices))
  782. %base-file-systems))
  783. (users %base-user-accounts)
  784. (services (cons (service marionette-service-type
  785. (marionette-configuration
  786. (imported-modules '((gnu services herd)
  787. (guix combinators)))))
  788. %base-services))))
  789. (define %lvm-separate-home-installation-script
  790. "\
  791. . /etc/profile
  792. set -e -x
  793. guix --version
  794. export GUIX_BUILD_OPTIONS=--no-grafts
  795. parted --script /dev/vdb mklabel gpt \\
  796. mkpart primary ext2 1M 3M \\
  797. mkpart primary ext2 3M 1.6G \\
  798. mkpart primary 1.6G 3.2G \\
  799. set 1 boot on \\
  800. set 1 bios_grub on
  801. pvcreate /dev/vdb3
  802. vgcreate vg0 /dev/vdb3
  803. lvcreate -L 1.6G -n home vg0
  804. vgchange -ay
  805. mkfs.ext4 -L root-fs /dev/vdb2
  806. mkfs.ext4 /dev/mapper/vg0-home
  807. mount /dev/vdb2 /mnt
  808. mkdir /mnt/home
  809. mount /dev/mapper/vg0-home /mnt/home
  810. df -h /mnt /mnt/home
  811. herd start cow-store /mnt
  812. mkdir /mnt/etc
  813. cp /etc/target-config.scm /mnt/etc/config.scm
  814. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  815. sync
  816. reboot\n")
  817. (define %test-lvm-separate-home-os
  818. (system-test
  819. (name "lvm-separate-home-os")
  820. (description
  821. "Test functionality of an OS installed with a LVM /home partition")
  822. (value
  823. (mlet* %store-monad ((images (run-install %lvm-separate-home-os
  824. %lvm-separate-home-os-source
  825. #:script
  826. %lvm-separate-home-installation-script
  827. #:packages (list lvm2-static)
  828. #:target-size (* 3200 MiB)))
  829. (command (qemu-command* images)))
  830. (run-basic-test %lvm-separate-home-os
  831. `(,@command) "lvm-separate-home-os")))))
  832. ;;;
  833. ;;; LUKS-encrypted root file system and /boot in a non-encrypted partition.
  834. ;;;
  835. (define-os-with-source (%encrypted-root-not-boot-os
  836. %encrypted-root-not-boot-os-source)
  837. ;; The OS we want to install.
  838. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  839. (operating-system
  840. (host-name "bootroot")
  841. (timezone "Europe/Paris")
  842. (locale "en_US.UTF-8")
  843. (bootloader (bootloader-configuration
  844. (bootloader grub-bootloader)
  845. (targets (list "/dev/vdb"))))
  846. (mapped-devices (list (mapped-device
  847. (source
  848. (uuid "12345678-1234-1234-1234-123456789abc"))
  849. (target "root")
  850. (type luks-device-mapping))))
  851. (file-systems (cons* (file-system
  852. (device (file-system-label "my-boot"))
  853. (mount-point "/boot")
  854. (type "ext4"))
  855. (file-system
  856. (device "/dev/mapper/root")
  857. (mount-point "/")
  858. (type "ext4"))
  859. %base-file-systems))
  860. (users (cons (user-account
  861. (name "alice")
  862. (group "users")
  863. (supplementary-groups '("wheel" "audio" "video")))
  864. %base-user-accounts))
  865. (services (cons (service marionette-service-type
  866. (marionette-configuration
  867. (imported-modules '((gnu services herd)
  868. (guix combinators)))))
  869. %base-services))))
  870. (define %encrypted-root-not-boot-installation-script
  871. ;; Shell script for an installation with boot not encrypted but root
  872. ;; encrypted.
  873. (format #f "\
  874. . /etc/profile
  875. set -e -x
  876. guix --version
  877. export GUIX_BUILD_OPTIONS=--no-grafts
  878. ls -l /run/current-system/gc-roots
  879. parted --script /dev/vdb mklabel gpt \\
  880. mkpart primary ext2 1M 3M \\
  881. mkpart primary ext2 3M 50M \\
  882. mkpart primary ext2 50M 1.6G \\
  883. set 1 boot on \\
  884. set 1 bios_grub on
  885. echo -n \"~a\" | cryptsetup luksFormat --uuid=\"~a\" -q /dev/vdb3 -
  886. echo -n \"~a\" | cryptsetup open --type luks --key-file - /dev/vdb3 root
  887. mkfs.ext4 -L my-root /dev/mapper/root
  888. mkfs.ext4 -L my-boot /dev/vdb2
  889. mount LABEL=my-root /mnt
  890. mkdir /mnt/boot
  891. mount LABEL=my-boot /mnt/boot
  892. echo \"Checking mounts\"
  893. mount
  894. herd start cow-store /mnt
  895. mkdir /mnt/etc
  896. cp /etc/target-config.scm /mnt/etc/config.scm
  897. guix system build /mnt/etc/config.scm
  898. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  899. sync
  900. echo \"Debugging info\"
  901. blkid
  902. cat /mnt/boot/grub/grub.cfg
  903. reboot\n"
  904. %luks-passphrase "12345678-1234-1234-1234-123456789abc"
  905. %luks-passphrase))
  906. (define %test-encrypted-root-not-boot-os
  907. (system-test
  908. (name "encrypted-root-not-boot-os")
  909. (description
  910. "Test the manual installation on an OS with / in an encrypted partition
  911. but /boot on a different, non-encrypted partition. This test is expensive in
  912. terms of CPU and storage usage since we need to build (current-guix) and then
  913. store a couple of full system images.")
  914. (value
  915. (mlet* %store-monad
  916. ((images (run-install %encrypted-root-not-boot-os
  917. %encrypted-root-not-boot-os-source
  918. #:script
  919. %encrypted-root-not-boot-installation-script))
  920. (command (qemu-command* images)))
  921. (run-basic-test %encrypted-root-not-boot-os command
  922. "encrypted-root-not-boot-os"
  923. #:initialization enter-luks-passphrase)))))
  924. ;;;
  925. ;;; Btrfs root file system.
  926. ;;;
  927. (define-os-with-source (%btrfs-root-os %btrfs-root-os-source)
  928. ;; The OS we want to install.
  929. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  930. (operating-system
  931. (host-name "liberigilo")
  932. (timezone "Europe/Paris")
  933. (locale "en_US.UTF-8")
  934. (bootloader (bootloader-configuration
  935. (bootloader grub-bootloader)
  936. (targets (list "/dev/vdb"))))
  937. (kernel-arguments '("console=ttyS0"))
  938. (file-systems (cons (file-system
  939. (device (file-system-label "my-root"))
  940. (mount-point "/")
  941. (type "btrfs"))
  942. %base-file-systems))
  943. (users (cons (user-account
  944. (name "charlie")
  945. (group "users")
  946. (supplementary-groups '("wheel" "audio" "video")))
  947. %base-user-accounts))
  948. (services (cons (service marionette-service-type
  949. (marionette-configuration
  950. (imported-modules '((gnu services herd)
  951. (guix combinators)))))
  952. %base-services))))
  953. (define %btrfs-root-installation-script
  954. ;; Shell script of a simple installation.
  955. "\
  956. . /etc/profile
  957. set -e -x
  958. guix --version
  959. export GUIX_BUILD_OPTIONS=--no-grafts
  960. ls -l /run/current-system/gc-roots
  961. parted --script /dev/vdb mklabel gpt \\
  962. mkpart primary ext2 1M 3M \\
  963. mkpart primary ext2 3M 2G \\
  964. set 1 boot on \\
  965. set 1 bios_grub on
  966. mkfs.btrfs -L my-root /dev/vdb2
  967. mount /dev/vdb2 /mnt
  968. btrfs subvolume create /mnt/home
  969. herd start cow-store /mnt
  970. mkdir /mnt/etc
  971. cp /etc/target-config.scm /mnt/etc/config.scm
  972. guix system build /mnt/etc/config.scm
  973. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  974. sync
  975. reboot\n")
  976. (define %test-btrfs-root-os
  977. (system-test
  978. (name "btrfs-root-os")
  979. (description
  980. "Test basic functionality of an OS installed like one would do by hand.
  981. This test is expensive in terms of CPU and storage usage since we need to
  982. build (current-guix) and then store a couple of full system images.")
  983. (value
  984. (mlet* %store-monad ((images (run-install %btrfs-root-os
  985. %btrfs-root-os-source
  986. #:script
  987. %btrfs-root-installation-script))
  988. (command (qemu-command* images)))
  989. (run-basic-test %btrfs-root-os command "btrfs-root-os")))))
  990. ;;;
  991. ;;; Btrfs RAID-0 root file system.
  992. ;;;
  993. (define-os-with-source (%btrfs-raid-root-os %btrfs-raid-root-os-source)
  994. ;; An OS whose root partition is a RAID partition.
  995. (use-modules (gnu) (gnu tests))
  996. (operating-system
  997. (host-name "liberigilo")
  998. (timezone "Europe/Paris")
  999. (locale "en_US.utf8")
  1000. (bootloader (bootloader-configuration
  1001. (bootloader grub-bootloader)
  1002. (targets (list "/dev/vdb"))))
  1003. (kernel-arguments '("console=ttyS0"))
  1004. (file-systems (cons (file-system
  1005. (device (file-system-label "root-fs"))
  1006. (mount-point "/")
  1007. (type "btrfs"))
  1008. %base-file-systems))
  1009. (users %base-user-accounts)
  1010. (services (cons (service marionette-service-type
  1011. (marionette-configuration
  1012. (imported-modules '((gnu services herd)
  1013. (guix combinators)))))
  1014. %base-services))))
  1015. (define %btrfs-raid-root-installation-script
  1016. "\
  1017. . /etc/profile
  1018. set -e -x
  1019. guix --version
  1020. export GUIX_BUILD_OPTIONS=--no-grafts
  1021. parted --script /dev/vdb mklabel gpt \\
  1022. mkpart primary ext2 1M 3M \\
  1023. mkpart primary ext2 3M 1.4G \\
  1024. mkpart primary ext2 1.4G 2.8G \\
  1025. set 1 boot on \\
  1026. set 1 bios_grub on
  1027. mkfs.btrfs -L root-fs -d raid0 -m raid0 /dev/vdb2 /dev/vdb3
  1028. mount /dev/vdb2 /mnt
  1029. df -h /mnt
  1030. herd start cow-store /mnt
  1031. mkdir /mnt/etc
  1032. cp /etc/target-config.scm /mnt/etc/config.scm
  1033. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  1034. sync
  1035. reboot\n")
  1036. (define %test-btrfs-raid-root-os
  1037. (system-test
  1038. (name "btrfs-raid-root-os")
  1039. (description "Test functionality of an OS installed with a Btrfs
  1040. RAID-0 (stripe) root partition.")
  1041. (value
  1042. (mlet* %store-monad
  1043. ((images (run-install %btrfs-raid-root-os
  1044. %btrfs-raid-root-os-source
  1045. #:script %btrfs-raid-root-installation-script
  1046. #:target-size (* 2800 MiB)))
  1047. (command (qemu-command* images)))
  1048. (run-basic-test %btrfs-raid-root-os `(,@command) "btrfs-raid-root-os")))))
  1049. ;;;
  1050. ;;; Btrfs root file system on a subvolume.
  1051. ;;;
  1052. (define-os-with-source (%btrfs-root-on-subvolume-os
  1053. %btrfs-root-on-subvolume-os-source)
  1054. ;; The OS we want to install.
  1055. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  1056. (operating-system
  1057. (host-name "hurd")
  1058. (timezone "Europe/Paris")
  1059. (locale "en_US.UTF-8")
  1060. (bootloader (bootloader-configuration
  1061. (bootloader grub-bootloader)
  1062. (targets (list "/dev/vdb"))))
  1063. (kernel-arguments '("console=ttyS0"))
  1064. (file-systems (cons* (file-system
  1065. (device (file-system-label "btrfs-pool"))
  1066. (mount-point "/")
  1067. (options "subvol=rootfs,compress=zstd")
  1068. (type "btrfs"))
  1069. (file-system
  1070. (device (file-system-label "btrfs-pool"))
  1071. (mount-point "/home")
  1072. (options "subvol=homefs,compress=lzo")
  1073. (type "btrfs"))
  1074. %base-file-systems))
  1075. (users (cons (user-account
  1076. (name "charlie")
  1077. (group "users")
  1078. (supplementary-groups '("wheel" "audio" "video")))
  1079. %base-user-accounts))
  1080. (services (cons (service marionette-service-type
  1081. (marionette-configuration
  1082. (imported-modules '((gnu services herd)
  1083. (guix combinators)))))
  1084. %base-services))))
  1085. (define %btrfs-root-on-subvolume-installation-script
  1086. ;; Shell script of a simple installation.
  1087. "\
  1088. . /etc/profile
  1089. set -e -x
  1090. guix --version
  1091. export GUIX_BUILD_OPTIONS=--no-grafts
  1092. ls -l /run/current-system/gc-roots
  1093. parted --script /dev/vdb mklabel gpt \\
  1094. mkpart primary ext2 1M 3M \\
  1095. mkpart primary ext2 3M 2G \\
  1096. set 1 boot on \\
  1097. set 1 bios_grub on
  1098. # Setup the top level Btrfs file system with its subvolume.
  1099. mkfs.btrfs -L btrfs-pool /dev/vdb2
  1100. mount /dev/vdb2 /mnt
  1101. btrfs subvolume create /mnt/rootfs
  1102. btrfs subvolume create /mnt/homefs
  1103. umount /dev/vdb2
  1104. # Mount the subvolumes, ready for installation.
  1105. mount LABEL=btrfs-pool -o 'subvol=rootfs,compress=zstd' /mnt
  1106. mkdir /mnt/home
  1107. mount LABEL=btrfs-pool -o 'subvol=homefs,compress=zstd' /mnt/home
  1108. herd start cow-store /mnt
  1109. mkdir /mnt/etc
  1110. cp /etc/target-config.scm /mnt/etc/config.scm
  1111. guix system build /mnt/etc/config.scm
  1112. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  1113. sync
  1114. reboot\n")
  1115. (define %test-btrfs-root-on-subvolume-os
  1116. (system-test
  1117. (name "btrfs-root-on-subvolume-os")
  1118. (description
  1119. "Test basic functionality of an OS installed like one would do by hand.
  1120. This test is expensive in terms of CPU and storage usage since we need to
  1121. build (current-guix) and then store a couple of full system images.")
  1122. (value
  1123. (mlet* %store-monad
  1124. ((images (run-install %btrfs-root-on-subvolume-os
  1125. %btrfs-root-on-subvolume-os-source
  1126. #:script
  1127. %btrfs-root-on-subvolume-installation-script))
  1128. (command (qemu-command* images)))
  1129. (run-basic-test %btrfs-root-on-subvolume-os command
  1130. "btrfs-root-on-subvolume-os")))))
  1131. ;;;
  1132. ;;; Btrfs RAID10 root file system.
  1133. ;;;
  1134. (define-os-with-source (%btrfs-raid10-root-os
  1135. %btrfs-raid10-root-os-source)
  1136. ;; The OS we want to install.
  1137. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  1138. (operating-system
  1139. (host-name "hurd")
  1140. (timezone "Europe/Paris")
  1141. (locale "en_US.UTF-8")
  1142. (bootloader (bootloader-configuration
  1143. (bootloader grub-bootloader)
  1144. (targets (list "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde"))))
  1145. (kernel-arguments '("console=ttyS0"))
  1146. (file-systems (cons* (file-system
  1147. (device (uuid "16ff18e2-eb41-4324-8df5-80d3b53c411b"))
  1148. (mount-point "/")
  1149. (options "compress-force=zstd,degraded")
  1150. (type "btrfs"))
  1151. %base-file-systems))
  1152. (users (cons (user-account
  1153. (name "charlie")
  1154. (group "users")
  1155. (supplementary-groups '("wheel" "audio" "video")))
  1156. %base-user-accounts))
  1157. (services (cons (service marionette-service-type
  1158. (marionette-configuration
  1159. (imported-modules '((gnu services herd)
  1160. (guix combinators)))))
  1161. %base-services))))
  1162. (define %btrfs-raid10-root-installation-script
  1163. ;; Shell script of a simple installation.
  1164. "\
  1165. . /etc/profile
  1166. set -e -x
  1167. guix --version
  1168. export GUIX_BUILD_OPTIONS=--no-grafts
  1169. ls -l /run/current-system/gc-roots
  1170. for d in vdb vdc vdd vde; do
  1171. parted --script /dev/$d mklabel gpt \\
  1172. mkpart primary ext2 1M 2M \\
  1173. mkpart primary ext2 2M 100% \\
  1174. set 1 boot on \\
  1175. set 1 bios_grub on
  1176. done
  1177. # Create the RAID10 Btrfs array.
  1178. mkfs.btrfs -d raid10 -m raid1c4 /dev/{vdb2,vdc2,vdd2,vde2} \\
  1179. --uuid 16ff18e2-eb41-4324-8df5-80d3b53c411b
  1180. # Mount it, ready for installation.
  1181. mount UUID=16ff18e2-eb41-4324-8df5-80d3b53c411b -o compress-force=zstd /mnt
  1182. herd start cow-store /mnt
  1183. mkdir /mnt/etc
  1184. cp /etc/target-config.scm /mnt/etc/config.scm
  1185. guix system build /mnt/etc/config.scm
  1186. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  1187. sync
  1188. reboot\n")
  1189. (define %test-btrfs-raid10-root-images
  1190. (mlet %store-monad
  1191. ((images (run-install %btrfs-raid10-root-os
  1192. %btrfs-raid10-root-os-source
  1193. #:script
  1194. %btrfs-raid10-root-installation-script
  1195. #:number-of-disks 4
  1196. #:target-size (* 1100 MiB))))
  1197. (return images)))
  1198. (define %test-btrfs-raid10-root-os
  1199. (system-test
  1200. (name "btrfs-raid10-root-os")
  1201. (description
  1202. "Test basic functionality of an OS installed on top of a Btrfs RAID10 file
  1203. system spanning 4 disks. This test is expensive in terms of CPU and storage
  1204. usage since we need to build (current-guix) and then store a couple of full
  1205. system images.")
  1206. (value
  1207. (mlet* %store-monad
  1208. ((images %test-btrfs-raid10-root-images)
  1209. (command (qemu-command* images)))
  1210. (run-basic-test %btrfs-raid10-root-os command
  1211. "btrfs-raid10-root-os")))))
  1212. (define %test-btrfs-raid10-root-os-degraded
  1213. (system-test
  1214. (name "btrfs-raid10-root-os-degraded")
  1215. (description
  1216. "Test basic functionality of an OS installed on top of a Btrfs RAID10 file
  1217. system spanning 6 disks, degraded to 5 disks. This test is expensive in terms
  1218. of CPU and storage usage since we need to build (current-guix) and then store
  1219. a couple of full system images.")
  1220. (value
  1221. (mlet* %store-monad
  1222. ;; Drop the first image; this boots because the root file system uses
  1223. ;; the Btrfs "degraded" mount option.
  1224. ((images %test-btrfs-raid10-root-images)
  1225. (command (qemu-command* #~(cdr #$images))))
  1226. (run-basic-test %btrfs-raid10-root-os command
  1227. "btrfs-raid10-root-os")))))
  1228. ;;;
  1229. ;;; JFS root file system.
  1230. ;;;
  1231. (define-os-with-source (%jfs-root-os %jfs-root-os-source)
  1232. ;; The OS we want to install.
  1233. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  1234. (operating-system
  1235. (host-name "liberigilo")
  1236. (timezone "Europe/Paris")
  1237. (locale "en_US.UTF-8")
  1238. (bootloader (bootloader-configuration
  1239. (bootloader grub-bootloader)
  1240. (targets (list "/dev/vdb"))))
  1241. (kernel-arguments '("console=ttyS0"))
  1242. (file-systems (cons (file-system
  1243. (device (file-system-label "my-root"))
  1244. (mount-point "/")
  1245. (type "jfs"))
  1246. %base-file-systems))
  1247. (users (cons (user-account
  1248. (name "charlie")
  1249. (group "users")
  1250. (supplementary-groups '("wheel" "audio" "video")))
  1251. %base-user-accounts))
  1252. (services (cons (service marionette-service-type
  1253. (marionette-configuration
  1254. (imported-modules '((gnu services herd)
  1255. (guix combinators)))))
  1256. %base-services))))
  1257. (define %jfs-root-installation-script
  1258. ;; Shell script of a simple installation.
  1259. "\
  1260. . /etc/profile
  1261. set -e -x
  1262. guix --version
  1263. export GUIX_BUILD_OPTIONS=--no-grafts
  1264. ls -l /run/current-system/gc-roots
  1265. parted --script /dev/vdb mklabel gpt \\
  1266. mkpart primary ext2 1M 3M \\
  1267. mkpart primary ext2 3M 2G \\
  1268. set 1 boot on \\
  1269. set 1 bios_grub on
  1270. jfs_mkfs -L my-root -q /dev/vdb2
  1271. mount /dev/vdb2 /mnt
  1272. herd start cow-store /mnt
  1273. mkdir /mnt/etc
  1274. cp /etc/target-config.scm /mnt/etc/config.scm
  1275. guix system build /mnt/etc/config.scm
  1276. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  1277. sync
  1278. reboot\n")
  1279. (define %test-jfs-root-os
  1280. (system-test
  1281. (name "jfs-root-os")
  1282. (description
  1283. "Test basic functionality of an OS installed like one would do by hand.
  1284. This test is expensive in terms of CPU and storage usage since we need to
  1285. build (current-guix) and then store a couple of full system images.")
  1286. (value
  1287. (mlet* %store-monad ((images (run-install %jfs-root-os
  1288. %jfs-root-os-source
  1289. #:script
  1290. %jfs-root-installation-script))
  1291. (command (qemu-command* images)))
  1292. (run-basic-test %jfs-root-os command "jfs-root-os")))))
  1293. ;;;
  1294. ;;; F2FS root file system.
  1295. ;;;
  1296. (define-os-with-source (%f2fs-root-os %f2fs-root-os-source)
  1297. ;; The OS we want to install.
  1298. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  1299. (operating-system
  1300. (host-name "liberigilo")
  1301. (timezone "Europe/Paris")
  1302. (locale "en_US.UTF-8")
  1303. (bootloader (bootloader-configuration
  1304. (bootloader grub-bootloader)
  1305. (targets (list "/dev/vdb"))))
  1306. (kernel-arguments '("console=ttyS0"))
  1307. (file-systems (cons (file-system
  1308. (device (file-system-label "my-root"))
  1309. (mount-point "/")
  1310. (type "f2fs"))
  1311. %base-file-systems))
  1312. (users (cons (user-account
  1313. (name "charlie")
  1314. (group "users")
  1315. (supplementary-groups '("wheel" "audio" "video")))
  1316. %base-user-accounts))
  1317. (services (cons (service marionette-service-type
  1318. (marionette-configuration
  1319. (imported-modules '((gnu services herd)
  1320. (guix combinators)))))
  1321. %base-services))))
  1322. (define %f2fs-root-installation-script
  1323. ;; Shell script of a simple installation.
  1324. "\
  1325. . /etc/profile
  1326. set -e -x
  1327. guix --version
  1328. export GUIX_BUILD_OPTIONS=--no-grafts
  1329. ls -l /run/current-system/gc-roots
  1330. parted --script /dev/vdb mklabel gpt \\
  1331. mkpart primary ext2 1M 3M \\
  1332. mkpart primary ext2 3M 2G \\
  1333. set 1 boot on \\
  1334. set 1 bios_grub on
  1335. mkfs.f2fs -l my-root -q /dev/vdb2
  1336. mount /dev/vdb2 /mnt
  1337. herd start cow-store /mnt
  1338. mkdir /mnt/etc
  1339. cp /etc/target-config.scm /mnt/etc/config.scm
  1340. guix system build /mnt/etc/config.scm
  1341. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  1342. sync
  1343. reboot\n")
  1344. (define %test-f2fs-root-os
  1345. (system-test
  1346. (name "f2fs-root-os")
  1347. (description
  1348. "Test basic functionality of an OS installed like one would do by hand.
  1349. This test is expensive in terms of CPU and storage usage since we need to
  1350. build (current-guix) and then store a couple of full system images.")
  1351. (value
  1352. (mlet* %store-monad ((images (run-install %f2fs-root-os
  1353. %f2fs-root-os-source
  1354. #:script
  1355. %f2fs-root-installation-script))
  1356. (command (qemu-command* images)))
  1357. (run-basic-test %f2fs-root-os command "f2fs-root-os")))))
  1358. ;;;
  1359. ;;; XFS root file system.
  1360. ;;;
  1361. (define-os-with-source (%xfs-root-os %xfs-root-os-source)
  1362. ;; The OS we want to install.
  1363. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  1364. (operating-system
  1365. (host-name "liberigilo")
  1366. (timezone "Europe/Paris")
  1367. (locale "en_US.UTF-8")
  1368. (bootloader (bootloader-configuration
  1369. (bootloader grub-bootloader)
  1370. (targets (list "/dev/vdb"))))
  1371. (kernel-arguments '("console=ttyS0"))
  1372. (file-systems (cons (file-system
  1373. (device (file-system-label "my-root"))
  1374. (mount-point "/")
  1375. (type "xfs"))
  1376. %base-file-systems))
  1377. (users (cons (user-account
  1378. (name "charlie")
  1379. (group "users")
  1380. (supplementary-groups '("wheel" "audio" "video")))
  1381. %base-user-accounts))
  1382. (services (cons (service marionette-service-type
  1383. (marionette-configuration
  1384. (imported-modules '((gnu services herd)
  1385. (guix combinators)))))
  1386. %base-services))))
  1387. (define %xfs-root-installation-script
  1388. ;; Shell script of a simple installation.
  1389. "\
  1390. . /etc/profile
  1391. set -e -x
  1392. guix --version
  1393. export GUIX_BUILD_OPTIONS=--no-grafts
  1394. ls -l /run/current-system/gc-roots
  1395. parted --script /dev/vdb mklabel gpt \\
  1396. mkpart primary ext2 1M 3M \\
  1397. mkpart primary ext2 3M 2G \\
  1398. set 1 boot on \\
  1399. set 1 bios_grub on
  1400. mkfs.xfs -L my-root -q /dev/vdb2
  1401. mount /dev/vdb2 /mnt
  1402. herd start cow-store /mnt
  1403. mkdir /mnt/etc
  1404. cp /etc/target-config.scm /mnt/etc/config.scm
  1405. guix system build /mnt/etc/config.scm
  1406. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  1407. sync
  1408. reboot\n")
  1409. (define %test-xfs-root-os
  1410. (system-test
  1411. (name "xfs-root-os")
  1412. (description
  1413. "Test basic functionality of an OS installed like one would do by hand.
  1414. This test is expensive in terms of CPU and storage usage since we need to
  1415. build (current-guix) and then store a couple of full system images.")
  1416. (value
  1417. (mlet* %store-monad ((images (run-install %xfs-root-os
  1418. %xfs-root-os-source
  1419. #:script
  1420. %xfs-root-installation-script))
  1421. (command (qemu-command* images)))
  1422. (run-basic-test %xfs-root-os command "xfs-root-os")))))
  1423. ;;;
  1424. ;;; Installation through the graphical interface.
  1425. ;;;
  1426. (define %syslog-conf
  1427. ;; Syslog configuration that dumps to /dev/console, so we can see the
  1428. ;; installer's messages during the test.
  1429. (computed-file "syslog.conf"
  1430. #~(begin
  1431. (copy-file #$%default-syslog.conf #$output)
  1432. (chmod #$output #o644)
  1433. (let ((port (open-file #$output "a")))
  1434. (display "\n*.info /dev/console\n" port)
  1435. #t))))
  1436. (define (operating-system-with-console-syslog os)
  1437. "Return OS with a syslog service that writes to /dev/console."
  1438. (operating-system
  1439. (inherit os)
  1440. (services (modify-services (operating-system-user-services os)
  1441. (syslog-service-type config
  1442. =>
  1443. (syslog-configuration
  1444. (inherit config)
  1445. (config-file %syslog-conf)))))))
  1446. (define %root-password "foo")
  1447. (define* (gui-test-program marionette
  1448. #:key
  1449. (desktop? #f)
  1450. (encrypted? #f)
  1451. (uefi-support? #f)
  1452. (system (%current-system)))
  1453. #~(let ()
  1454. (define (screenshot file)
  1455. (marionette-control (string-append "screendump " file)
  1456. #$marionette))
  1457. (define-syntax-rule (marionette-eval* exp marionette)
  1458. (or (marionette-eval exp marionette)
  1459. (throw 'marionette-eval-failure 'exp)))
  1460. (setvbuf (current-output-port) 'none)
  1461. (setvbuf (current-error-port) 'none)
  1462. (marionette-eval* '(use-modules (gnu installer tests))
  1463. #$marionette)
  1464. ;; Arrange so that 'converse' prints debugging output to the console.
  1465. (marionette-eval* '(let ((console (open-output-file "/dev/console")))
  1466. (setvbuf console 'none)
  1467. (conversation-log-port console))
  1468. #$marionette)
  1469. ;; Tell the installer to not wait for the Connman "online" status.
  1470. (marionette-eval* '(call-with-output-file "/tmp/installer-assume-online"
  1471. (const #t))
  1472. #$marionette)
  1473. ;; Run 'guix system init' with '--no-grafts', to cope with the lack of
  1474. ;; network access.
  1475. (marionette-eval* '(call-with-output-file
  1476. "/tmp/installer-system-init-options"
  1477. (lambda (port)
  1478. (write '("--no-grafts" "--no-substitutes")
  1479. port)))
  1480. #$marionette)
  1481. (marionette-eval* '(define installer-socket
  1482. (open-installer-socket))
  1483. #$marionette)
  1484. (screenshot "installer-start.ppm")
  1485. (marionette-eval* '(choose-locale+keyboard installer-socket)
  1486. #$marionette)
  1487. (screenshot "installer-locale.ppm")
  1488. ;; Choose the host name that the "basic" test expects.
  1489. (marionette-eval* '(enter-host-name+passwords installer-socket
  1490. #:host-name "liberigilo"
  1491. #:root-password
  1492. #$%root-password
  1493. #:users
  1494. '(("alice" "pass1")
  1495. ("bob" "pass2")))
  1496. #$marionette)
  1497. (screenshot "installer-services.ppm")
  1498. (marionette-eval* '(choose-services installer-socket
  1499. #:choose-desktop-environment?
  1500. (const #$desktop?)
  1501. #:choose-network-service?
  1502. (const #f))
  1503. #$marionette)
  1504. (screenshot "installer-partitioning.ppm")
  1505. (marionette-eval* '(choose-partitioning installer-socket
  1506. #:encrypted? #$encrypted?
  1507. #:passphrase #$%luks-passphrase
  1508. #:uefi-support? #$uefi-support?)
  1509. #$marionette)
  1510. (screenshot "installer-run.ppm")
  1511. (unless #$encrypted?
  1512. ;; At this point, user partitions are formatted and the installer is
  1513. ;; waiting for us to start the final step: generating the
  1514. ;; configuration file, etc. Set a fixed UUID on the swap partition
  1515. ;; that matches what 'installation-target-os-for-gui-tests' expects.
  1516. (marionette-eval* '(invoke #$(file-append util-linux "/sbin/swaplabel")
  1517. "-U" "11111111-2222-3333-4444-123456789abc"
  1518. "/dev/vda2")
  1519. #$marionette))
  1520. (marionette-eval* '(start-installation installer-socket)
  1521. #$marionette)
  1522. ;; XXX: The grub-install process uses efibootmgr to add an UEFI Guix
  1523. ;; boot entry. The corresponding UEFI variable is stored in RAM, and
  1524. ;; possibly saved persistently on QEMU reboot in a NvVars file, see:
  1525. ;; https://lists.gnu.org/archive/html/qemu-discuss/2018-04/msg00045.html.
  1526. ;;
  1527. ;; As we are running QEMU with the no-reboot flag, this variable is
  1528. ;; never saved persistently, QEMU fails to boot the installed system and
  1529. ;; an UEFI shell is displayed instead.
  1530. ;;
  1531. ;; To make the installed UEFI system bootable, register Grub as the
  1532. ;; default UEFI boot entry, in the same way as if grub-install was
  1533. ;; invoked with the --removable option.
  1534. (when #$uefi-support?
  1535. (marionette-eval*
  1536. '(begin
  1537. (use-modules (ice-9 match))
  1538. (let ((targets (cond
  1539. ((string-prefix? "x86_64" #$system)
  1540. '("grubx64.efi" "BOOTX64.EFI"))
  1541. ((string-prefix? "i686" #$system)
  1542. '("grubia32.efi" "BOOTIA32.EFI"))
  1543. (else #f))))
  1544. (match targets
  1545. ((src dest)
  1546. (rename-file "/mnt/boot/efi/EFI/Guix"
  1547. "/mnt/boot/efi/EFI/BOOT")
  1548. (rename-file
  1549. (string-append "/mnt/boot/efi/EFI/BOOT/" src)
  1550. (string-append "/mnt/boot/efi/EFI/BOOT/" dest)))
  1551. (_ #f))))
  1552. #$marionette))
  1553. (marionette-eval* '(complete-installation installer-socket)
  1554. #$marionette)
  1555. (sync)
  1556. #t))
  1557. (define %extra-packages
  1558. ;; Packages needed when installing with an encrypted root.
  1559. (list isc-dhcp
  1560. lvm2-static cryptsetup-static e2fsck/static
  1561. loadkeys-static grub-efi fatfsck/static dosfstools))
  1562. (define installation-os-for-gui-tests
  1563. ;; Operating system that contains all of %EXTRA-PACKAGES, needed for the
  1564. ;; target OS, as well as syslog output redirected to the console so we can
  1565. ;; see what the installer is up to.
  1566. (marionette-operating-system
  1567. (operating-system
  1568. (inherit (operating-system-with-console-syslog
  1569. (operating-system-add-packages
  1570. (operating-system-with-current-guix
  1571. installation-os)
  1572. %extra-packages)))
  1573. (kernel-arguments '("console=ttyS0")))
  1574. #:imported-modules '((gnu services herd)
  1575. (gnu installer tests)
  1576. (guix combinators))))
  1577. (define* (installation-target-os-for-gui-tests
  1578. #:key
  1579. (encrypted? #f)
  1580. (uefi-support? #f))
  1581. (operating-system
  1582. (inherit %minimal-os-on-vda)
  1583. (file-systems `(,(file-system
  1584. (device (file-system-label "my-root"))
  1585. (mount-point "/")
  1586. (type "ext4"))
  1587. ,@(if uefi-support?
  1588. (list (file-system
  1589. (device (uuid "1234-ABCD" 'fat))
  1590. (mount-point "/boot/efi")
  1591. (type "vfat")))
  1592. '())
  1593. ,@%base-file-systems))
  1594. (users (append (list (user-account
  1595. (name "alice")
  1596. (comment "Bob's sister")
  1597. (group "users")
  1598. (supplementary-groups
  1599. '("wheel" "audio" "video")))
  1600. (user-account
  1601. (name "bob")
  1602. (comment "Alice's brother")
  1603. (group "users")
  1604. (supplementary-groups
  1605. '("wheel" "audio" "video"))))
  1606. %base-user-accounts))
  1607. ;; The installer does not create a swap device in guided mode with
  1608. ;; encryption support. The installer produces a UUID for the partition;
  1609. ;; this "UUID" is explicitly set in 'gui-test-program' to the value shown
  1610. ;; below.
  1611. (swap-devices
  1612. (if encrypted?
  1613. '()
  1614. (list
  1615. (swap-space
  1616. (target (uuid "11111111-2222-3333-4444-123456789abc"))))))
  1617. (services (cons* (service dhcp-client-service-type)
  1618. (service ntp-service-type)
  1619. (operating-system-user-services %minimal-os-on-vda)))))
  1620. (define* (installation-target-desktop-os-for-gui-tests
  1621. #:key (encrypted? #f))
  1622. (operating-system
  1623. (inherit (installation-target-os-for-gui-tests
  1624. #:encrypted? encrypted?))
  1625. (keyboard-layout (keyboard-layout "us" "altgr-intl"))
  1626. ;; Make sure that all the packages and services that may be used by the
  1627. ;; graphical installer are available.
  1628. (packages (append
  1629. (list openbox awesome i3-wm i3status
  1630. dmenu st ratpoison xterm
  1631. emacs emacs-exwm emacs-desktop-environment)
  1632. %base-packages))
  1633. (services
  1634. (append
  1635. (list (service gnome-desktop-service-type)
  1636. (service xfce-desktop-service-type)
  1637. (service mate-desktop-service-type)
  1638. (service enlightenment-desktop-service-type)
  1639. (set-xorg-configuration
  1640. (xorg-configuration
  1641. (keyboard-layout keyboard-layout)))
  1642. (service marionette-service-type
  1643. (marionette-configuration
  1644. (imported-modules '((gnu services herd)
  1645. (guix build utils)
  1646. (guix combinators))))))
  1647. %desktop-services))))
  1648. (define* (guided-installation-test name
  1649. #:key
  1650. (desktop? #f)
  1651. (encrypted? #f)
  1652. (uefi-support? #f)
  1653. target-os
  1654. (install-size 'guess)
  1655. (target-size (* 2200 MiB)))
  1656. (system-test
  1657. (name name)
  1658. (description
  1659. "Install an OS using the graphical installer and test it.")
  1660. (value
  1661. (mlet* %store-monad
  1662. ((images (run-install target-os '(this is unused)
  1663. #:script #f
  1664. #:os installation-os-for-gui-tests
  1665. #:uefi-support? uefi-support?
  1666. #:install-size install-size
  1667. #:target-size target-size
  1668. #:installation-image-type
  1669. 'uncompressed-iso9660
  1670. #:gui-test
  1671. (lambda (marionette)
  1672. (gui-test-program
  1673. marionette
  1674. #:desktop? desktop?
  1675. #:encrypted? encrypted?
  1676. #:uefi-support? uefi-support?))))
  1677. (command (qemu-command* images
  1678. #:uefi-support? uefi-support?
  1679. #:memory-size 512)))
  1680. (run-basic-test target-os command name
  1681. #:initialization (and encrypted? enter-luks-passphrase)
  1682. #:root-password %root-password
  1683. #:desktop? desktop?)))))
  1684. (define %test-gui-installed-os
  1685. (guided-installation-test
  1686. "gui-installed-os"
  1687. #:target-os (installation-target-os-for-gui-tests)))
  1688. ;; Test the UEFI installation of Guix System using the graphical installer.
  1689. (define %test-gui-uefi-installed-os
  1690. (guided-installation-test
  1691. "gui-uefi-installed-os"
  1692. #:uefi-support? #t
  1693. #:target-os (installation-target-os-for-gui-tests
  1694. #:uefi-support? #t)
  1695. #:target-size (* 3200 MiB)))
  1696. (define %test-gui-installed-os-encrypted
  1697. (guided-installation-test
  1698. "gui-installed-os-encrypted"
  1699. #:encrypted? #t
  1700. #:target-os (installation-target-os-for-gui-tests
  1701. #:encrypted? #t)))
  1702. ;; Building a desktop image is very time and space consuming. Install all
  1703. ;; desktop environments in a single test to reduce the overhead.
  1704. (define %test-gui-installed-desktop-os-encrypted
  1705. (guided-installation-test "gui-installed-desktop-os-encrypted"
  1706. #:desktop? #t
  1707. #:encrypted? #t
  1708. #:target-os
  1709. (installation-target-desktop-os-for-gui-tests
  1710. #:encrypted? #t)
  1711. ;; XXX: The disk-image size guess is too low. Use
  1712. ;; a constant value until this is fixed.
  1713. #:install-size (* 8000 MiB)
  1714. #:target-size (* 9000 MiB)))
  1715. ;;; install.scm ends here