projects/guix·blob java-team · refs

895 lines · 36.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014-2022, 2024-2025 Ludovic Courtès <[email protected]>
3;;; Copyright © 2015 Mark H Weaver <[email protected]>
4;;; Copyright © 2016 Andreas Enge <[email protected]>
5;;; Copyright © 2017 Marius Bakke <[email protected]>
6;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <[email protected]>
7;;; Copyright © 2020, 2024 Florian Pelz <[email protected]>
8;;; Copyright © 2020 Efraim Flashner <[email protected]>
9;;; Copyright © 2022 Josselin Poiret <[email protected]>
10;;; Copyright © 2023 Herman Rimm <[email protected]>
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu system install)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (gnu)
30 #:use-module (gnu system)
31 #:use-module (gnu system privilege)
32 #:use-module (guix build-system trivial)
33 #:use-module (gnu bootloader)
34 #:use-module (gnu bootloader u-boot)
35 #:use-module (guix gexp)
36 #:use-module (guix store)
37 #:use-module (guix modules)
38 #:use-module ((guix packages) #:select (package-version supported-package?))
39 #:autoload (guix channels) (channel? channel-commit)
40 #:use-module (guix platform)
41 #:use-module (guix utils)
42 #:use-module (guix packages)
43 #:use-module ((guix channels)
44 #:select (%default-guix-channel
45 channel
46 channel-commit))
47 #:use-module (gnu installer)
48 #:use-module (gnu system locale)
49 #:use-module (gnu services avahi)
50 #:use-module (gnu services dbus)
51 #:use-module (gnu services networking)
52 #:use-module (gnu services shepherd)
53 #:use-module (gnu services ssh)
54 #:use-module (gnu packages admin)
55 #:use-module (gnu packages bash)
56 #:use-module (gnu packages bootloaders)
57 #:use-module (gnu packages compression)
58 #:use-module (gnu packages cryptsetup)
59 #:use-module (gnu packages disk)
60 #:use-module (gnu packages file-systems)
61 #:use-module (gnu packages fonts)
62 #:use-module (gnu packages fontutils)
63 #:use-module (gnu packages guile)
64 #:use-module (gnu packages linux)
65 #:use-module (gnu packages package-management)
66 #:use-module (gnu packages terminals)
67 #:use-module (gnu packages texinfo)
68 #:use-module (gnu packages xorg)
69 #:use-module (ice-9 match)
70 #:export (installation-os
71 make-installation-os
72 a20-olinuxino-lime-installation-os
73 a20-olinuxino-lime2-emmc-installation-os
74 a20-olinuxino-micro-installation-os
75 bananapi-m2-ultra-installation-os
76 am335x-evm-installation-os
77 beaglebone-black-installation-os
78 mx6cuboxi-installation-os
79 novena-installation-os
80 orangepi-r1-plus-lts-rk3328-installation-os
81 firefly-rk3399-installation-os
82 pine64-plus-installation-os
83 pinebook-installation-os
84 rock64-installation-os
85 rock-4c-plus-installation-os
86 rockpro64-installation-os
87 rk3399-puma-installation-os
88 wandboard-installation-os
89 os-with-u-boot))
90
91;;; Commentary:
92;;;
93;;; This module provides an 'operating-system' definition for use on images
94;;; for USB sticks etc., for the installation of the GNU system.
95;;;
96;;; Code:
97
98
99;;;
100;;; Documentation service.
101;;;
102
103(define %installation-node-names
104 ;; Translated name of the "System Installation" node of the manual. Ideally
105 ;; we'd extract it from the 'guix-manual' gettext domain, but that one is
106 ;; usually not available at run time, hence this hack.
107 '(("de" . "Systeminstallation")
108 ("en" . "System Installation")
109 ("es" . "Instalación del sistema")
110 ("fr" . "Installation du système")
111 ("it" . "Installazione del Sistema")
112 ("pt_BR" . "Instalação do sistema")
113 ("ru" . "Установка системы")
114 ("zh_CN" . "系统安装")))
115
116(define (log-to-info tty user)
117 "Return a script that spawns the Info reader on the right section of the
118manual."
119 (program-file "log-to-info"
120 #~(let* ((tty (open-file #$(string-append "/dev/" tty)
121 "r0+"))
122 (locale (cadr (command-line)))
123 (language (string-take locale
124 (string-index locale #\_)))
125 (with-region (string-take locale
126 (string-index
127 locale
128 (char-set #\. #\/ #\@))))
129 (infodir "/run/current-system/profile/share/info")
130 (per-lang (lambda (code)
131 (string-append infodir "/guix." code
132 ".info.gz")))
133 (file ((@ (srfi srfi-1) find) file-exists?
134 (list (per-lang with-region)
135 (per-lang language)
136 (string-append infodir
137 "/guix.info.gz"))))
138 (node (or (assoc-ref '#$%installation-node-names
139 with-region)
140 (assoc-ref '#$%installation-node-names
141 language)
142 "System Installation")))
143 (redirect-port tty (current-output-port))
144 (redirect-port tty (current-error-port))
145 (redirect-port tty (current-input-port))
146
147 (let ((pw (getpwnam #$user)))
148 (setgid (passwd:gid pw))
149 (setuid (passwd:uid pw)))
150
151 ;; 'gunzip' is needed to decompress the doc.
152 (setenv "PATH" (string-append #$gzip "/bin"))
153
154 ;; Change this process' locale so that command-line
155 ;; arguments to 'info' are properly encoded.
156 (catch #t
157 (lambda ()
158 (setlocale LC_ALL locale)
159 (setenv "LC_ALL" locale))
160 (lambda _
161 ;; Sometimes LOCALE itself is not available. In that
162 ;; case pick the one UTF-8 locale that's known to work
163 ;; instead of failing.
164 (setlocale LC_ALL "en_US.utf8")
165 (setenv "LC_ALL" "en_US.utf8")))
166
167 (execl #$(file-append info-reader "/bin/info")
168 "info" "-d" infodir "-f" file "-n" node))))
169
170(define (documentation-shepherd-service tty)
171 (list (shepherd-service
172 (provision (list (symbol-append 'term- (string->symbol tty))))
173 (requirement '(user-processes host-name udev virtual-terminal))
174 (start #~(lambda* (#:optional (locale "en_US.utf8"))
175 (fork+exec-command
176 (list #$(log-to-info tty "documentation") locale)
177 #:environment-variables
178 `("GUIX_LOCPATH=/run/current-system/locale"
179 "TERM=linux"))))
180 (stop #~(make-kill-destructor)))))
181
182(define %documentation-users
183 ;; User account for the Info viewer.
184 (list (user-account (name "documentation")
185 (system? #t)
186 (group "nogroup")
187 (home-directory "/var/empty"))))
188
189(define documentation-service-type
190 ;; Documentation viewer service.
191 (service-type (name 'documentation)
192 (extensions
193 (list (service-extension shepherd-root-service-type
194 documentation-shepherd-service)
195 (service-extension account-service-type
196 (const %documentation-users))))
197 (description "Run the Info reader on a tty.")))
198
199
200(define %backing-directory
201 ;; Sub-directory used as the backing store for copy-on-write.
202 "/tmp/guix-inst")
203
204(define cow-store-service-type
205 (shepherd-service-type
206 'cow-store
207 (lambda _
208 (define (import-module? module)
209 ;; Since we don't use deduplication support in 'populate-store', don't
210 ;; import (guix store deduplication) and its dependencies, which
211 ;; includes Guile-Gcrypt.
212 (and (guix-module-name? module)
213 (not (equal? module '(guix store deduplication)))))
214
215 (shepherd-service
216 (requirement '(root-file-system user-processes))
217 (provision '(cow-store))
218 (documentation
219 "Make the store copy-on-write, with writes going to \
220the given target.")
221
222 ;; This is meant to be explicitly started by the user.
223 (auto-start? #f)
224
225 (modules `((gnu build install)
226 ,@%default-modules))
227 (start
228 (with-imported-modules (source-module-closure
229 '((gnu build install))
230 #:select? import-module?)
231 #~(case-lambda
232 ((target)
233 (mount-cow-store target #$%backing-directory)
234 target)
235 (else
236 ;; Do nothing, and mark the service as stopped.
237 #f))))
238 (stop #~(lambda (target)
239 ;; Delete the temporary directory, but leave everything
240 ;; mounted as there may still be processes using it since
241 ;; 'user-processes' doesn't depend on us. The 'user-file-systems'
242 ;; service will unmount TARGET eventually.
243 (delete-file-recursively
244 (string-append target #$%backing-directory))))))
245 (description "Make the store copy-on-write, with writes going to \
246the given target.")))
247
248(define (cow-store-service)
249 "Return a service that makes the store copy-on-write, such that writes go to
250the user's target storage device rather than on the RAM disk."
251 ;; See <http://bugs.gnu.org/18061> for the initial report.
252 (service cow-store-service-type 'mooooh!))
253
254
255(define (/etc/configuration-files _)
256 "Return a list of tuples representing configuration templates to add to
257/etc."
258 (define directory
259 (computed-file "configuration-templates"
260 (with-imported-modules '((guix build utils))
261 #~(begin
262 (mkdir #$output)
263 (for-each (lambda (file target)
264 (copy-file file
265 (string-append #$output "/"
266 target)))
267 '(#$(local-file "examples/bare-bones.tmpl")
268 #$(local-file "examples/beaglebone-black.tmpl")
269 #$(local-file "examples/desktop.tmpl")
270 #$(local-file "examples/lightweight-desktop.tmpl"))
271 '("bare-bones.scm"
272 "beaglebone-black.scm"
273 "desktop.scm"
274 "lightweight-desktop.scm"))
275 #t))))
276
277 `(("configuration" ,directory)))
278
279(define configuration-template-service-type
280 (service-type (name 'configuration-template)
281 (extensions
282 (list (service-extension etc-service-type
283 /etc/configuration-files)))
284 (description "Install the operating system configuration file
285templates under @file{/etc/configuration}.")))
286
287(define %configuration-template-service
288 (service configuration-template-service-type #t))
289
290
291(define %nscd-minimal-caches
292 ;; Minimal in-memory caching policy for nscd.
293 (list (nscd-cache (database 'hosts)
294 (positive-time-to-live (* 3600 12))
295
296 ;; Do not cache lookup failures at all since they are
297 ;; quite likely (for instance when someone tries to ping a
298 ;; host before networking is functional.)
299 (negative-time-to-live 0)
300
301 (persistent? #f)
302 (max-database-size (* 5 (expt 2 20)))))) ;5 MiB
303
304
305;; These define a service to load the uvesafb kernel module with the
306;; appropriate options. The GUI installer needs it when the machine does not
307;; support Kernel Mode Setting. Otherwise kmscon is missing /dev/fb0.
308(define (uvesafb-shepherd-service _)
309 (define modprobe
310 (program-file "modprobe-wrapper"
311 #~(begin
312 ;; Use a wrapper because shepherd 0.9.3 won't let us
313 ;; pass environment variables to the child process:
314 ;; <https://issues.guix.gnu.org/60106>.
315 (setenv "LINUX_MODULE_DIRECTORY"
316 "/run/booted-system/kernel/lib/modules")
317 (apply execl #$(file-append kmod "/bin/modprobe")
318 "modprobe" (cdr (command-line))))))
319
320 (list (shepherd-service
321 (documentation "Load the uvesafb kernel module if needed.")
322 (provision '(maybe-uvesafb))
323 (requirement '(file-systems))
324 (start #~(lambda ()
325 (or (file-exists? "/dev/fb0")
326 (invoke #+modprobe
327 "uvesafb"
328 (string-append "v86d=" #$v86d "/sbin/v86d")
329 "mode_option=1024x768"))))
330 (respawn? #f)
331 (one-shot? #t))))
332
333(define uvesafb-service-type
334 (service-type
335 (name 'uvesafb)
336 (extensions
337 (list (service-extension shepherd-root-service-type
338 uvesafb-shepherd-service)))
339 (description
340 "Load the @code{uvesafb} kernel module with the right options.")
341 (default-value #t)))
342
343(define %installation-login-pam-service
344;; Custom 'login' pam.d rule. It is based on the original one,
345;; but includes possibility to print different motd. This motd
346;; is useful for headless consoles.
347 (let* ((unix (pam-entry
348 (control "required")
349 (module "pam_unix.so")))
350 (env (pam-entry ; to honor /etc/environment.
351 (control "required")
352 (module "pam_env.so")))
353 (motd (plain-file "motd" "
354\x1b[1;37mWelcome to the installation of GNU Guix!\x1b[0m
355
356\x1b[2m\
357Using this shell, you can carry out the installation process \"manually.\"
358Access documentation at any time by pressing Alt-F2.\x1b[0m
359"))
360 (console-motd (plain-file "console-motd" "
361\x1b[1;37mWelcome to the installation of GNU Guix!\x1b[0m
362
363You are in a headless console. If you can use a display, you should see the
364graphical installer on TTY1, it's opened by default. In case you cannot use a
365display, you can carry out the installation process in this shell \"manually\"
366or by starting the installer, using `guix-system-installer` command.
367
368\x1b[2mYou can access the Guix documentation using `info \"(guix)\"`.\x1b[0m
369"))
370 (show-motd (program-file "show-motd"
371 #~(begin
372 (use-modules (ice-9 textual-ports))
373
374 (call-with-input-file
375 (if (file-exists?
376 (string-append
377 "/tmp/console_"
378 (basename (getenv "PAM_TTY"))))
379 #$console-motd
380 #$motd)
381 (lambda (port)
382 (display (get-string-all port))))))))
383 (pam-service
384 (name "login")
385 (account (list unix))
386 (auth (list (pam-entry
387 (control "required")
388 (module "pam_unix.so")
389 (arguments '("nullok")))))
390 (password (list (pam-entry
391 (control "required")
392 (module "pam_unix.so")
393 (arguments '("sha512" "shadow")))))
394 (session `(,(pam-entry
395 (control "optional")
396 (module "pam_exec.so")
397 (arguments
398 (list "type=open_session" "stdout" show-motd)))
399 ,(pam-entry ;to fill in /proc/self/loginuid
400 (control "required")
401 (module "pam_loginuid.so"))
402 ,env ,unix)))))
403
404(define %installation-console-login
405;; Make a custom 'login' wrapper for execution in console
406;; terminal. It instructs pam.d login rule to print different
407;; motd.
408 (program-file
409 "login-with-motd"
410 #~(begin
411 (call-with-output-file
412 (string-append "/tmp/console_"
413 (basename (ttyname (current-output-port))))
414 (const #t))
415
416 (apply execlp
417 #$(file-append shadow "/bin/login")
418 (command-line)))))
419
420(define* (installer-command-package installer-program
421 #:key executable)
422 (package
423 (name executable)
424 (version "0")
425 (source #f)
426 (build-system trivial-build-system)
427 (arguments
428 (list #:builder (with-imported-modules '((guix build utils))
429 #~(begin
430 (use-modules (guix build utils))
431
432 (mkdir-p (string-append #$output "/bin"))
433
434 (symlink #$installer-program
435 (string-append #$output "/bin/" #$executable))))))
436 (home-page #f)
437 (synopsis "Provides the Guix System installer as run-guix-installer command")
438 (description "Provides the Guix System installer as run-guix-installer command.")
439 (license license:gpl3+)))
440
441(define* (%installation-services
442 #:key
443 (system (or (and=>
444 (%current-target-system)
445 platform-target->system)
446 (%current-system)))
447 (guix-for-system (current-guix)))
448 ;; List of services of the installation system.
449 (define (normal-tty tty)
450 (service mingetty-service-type
451 (mingetty-configuration (tty tty)
452 (auto-login "root")
453 (login-pause? #t))))
454
455 (define bare-bones-os
456 (load "examples/bare-bones.tmpl"))
457
458 (define installer
459 (installer-program
460 #:guix-for-installer guix-for-system))
461
462 (append
463 ;; Generic services
464 (list (service virtual-terminal-service-type)
465
466 (service kmscon-service-type
467 (kmscon-configuration
468 (kmscon kmscon-8)
469 (virtual-terminal "tty1")
470 (login-program installer)))
471
472 (simple-service 'installer-login
473 pam-root-service-type
474 (list %installation-login-pam-service))
475
476 ;; Documentation. The manual is in UTF-8, but
477 ;; 'console-font-service' sets up Unicode support and loads a font
478 ;; with all the useful glyphs like em dash and quotation marks.
479 (service documentation-service-type "tty2")
480
481 ;; Documentation add-on.
482 %configuration-template-service
483
484 ;; A bunch of 'root' ttys.
485 (normal-tty "tty3")
486 (normal-tty "tty4")
487 (normal-tty "tty5")
488 (normal-tty "tty6")
489
490 ;; The usual services.
491 (service shepherd-system-log-service-type)
492
493 ;; Use the Avahi daemon to discover substitute servers on the local
494 ;; network. It can be faster than fetching from remote servers.
495 (service avahi-service-type)
496
497 ;; Allow runninng the installer command on headless setups.
498 (simple-service 'installer-program-profile
499 profile-service-type
500 (list (installer-command-package
501 installer
502 #:executable "guix-system-installer")))
503
504 ;; The build daemon.
505 (service guix-service-type
506 (guix-configuration
507 ;; Register the default substitute server key(s) as
508 ;; trusted to allow the installation process to use
509 ;; substitutes by default.
510 (authorize-key? #t)
511
512 ;; Install and run the current Guix rather than an older
513 ;; snapshot.
514 (guix guix-for-system)))
515
516 ;; Start udev so that useful device nodes are available.
517 ;; Use device-mapper rules for cryptsetup & co; enable the CRDA for
518 ;; regulations-compliant WiFi access.
519 (service udev-service-type
520 (udev-configuration
521 (rules (list lvm2 crda))))
522
523 ;; Add the 'cow-store' service, which users have to start manually
524 ;; since it takes the installation directory as an argument.
525 (cow-store-service)
526
527 ;; Install Unicode support and a suitable font.
528 (service console-font-service-type
529 (map (match-lambda
530 ("tty2"
531 ;; Use a font that contains characters such as
532 ;; curly quotes as found in the manual.
533 '("tty2" . "LatGrkCyr-8x16"))
534 (tty
535 ;; Use a font that doesn't have more than 256
536 ;; glyphs so that we can use colors with varying
537 ;; brightness levels (see note in setfont(8)).
538 `(,tty . "lat9u-16")))
539 '("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
540
541 ;; To facilitate copy/paste.
542 (service gpm-service-type)
543
544 ;; Add an SSH server to facilitate remote installs.
545 (service openssh-service-type
546 (openssh-configuration
547 (port-number 22)
548 (permit-root-login #t)
549 ;; The root account is passwordless, so make sure
550 ;; a password is set before allowing logins.
551 (allow-empty-passwords? #f)
552 (password-authentication? #t)
553
554 ;; Don't start it upfront.
555 (%auto-start? #f)))
556
557 ;; Since this is running on a USB stick with a overlayfs as the root
558 ;; file system, use an appropriate cache configuration.
559 (service nscd-service-type
560 (nscd-configuration
561 (caches %nscd-minimal-caches)))
562
563 ;; Having /bin/sh is a good idea. In particular it allows Tramp
564 ;; connections to this system to work.
565 (service special-files-service-type
566 `(("/bin/sh" ,(file-append bash "/bin/sh"))))
567
568 ;; Loopback device, needed by OpenSSH notably.
569 (service static-networking-service-type
570 (list %loopback-static-networking))
571
572 (service wpa-supplicant-service-type)
573 (service dbus-root-service-type)
574 (service connman-service-type
575 (connman-configuration
576 (disable-vpn? #t)))
577
578 ;; Keep a reference to BARE-BONES-OS to make sure it can be
579 ;; installed without downloading/building anything. Also keep the
580 ;; things needed by 'profile-derivation' to minimize the amount of
581 ;; download.
582 (service gc-root-service-type
583 (append
584 (list bare-bones-os
585 (libc-utf8-locales-for-target system)
586 texinfo
587 guile-3.0)
588 %default-locale-libcs)))
589
590 ;; Specific system services
591
592 ;; AArch64 has a better detection of consoles, mainly because device
593 ;; trees are utilized. On x86_64, the detection is usually done
594 ;; through BIOS and consoles do not get registered to /proc/console.
595 ;; The only way they would is if the user used console linux argument.
596 `(,@(if (target-aarch64? system)
597 (list (service agetty-service-type
598 (agetty-configuration (tty #f)
599 (auto-login "root")
600 (login-pause? #t)
601 (login-program
602 %installation-console-login))))
603 '()))
604
605 ;; Machines without Kernel Mode Setting (those with many old and
606 ;; current AMD GPUs, SiS GPUs, ...) need uvesafb to show the GUI
607 ;; installer. Some may also need a kernel parameter like nomodeset
608 ;; or vga=793, but we leave that for the user to specify in GRUB.
609 `(,@(if (supported-package? v86d system)
610 (list (service uvesafb-service-type))
611 '()))))
612
613(define %issue
614 ;; Greeting.
615 "
616\x1b[1;37mThis is an installation image of the GNU system. Welcome.\x1b[0m
617
618\x1b[1;33mUse Alt-F2 for documentation.\x1b[0m
619")
620
621(define %installer-disk-utilities
622 ;; A well-rounded set of packages for interacting with disks, partitions and
623 ;; file systems, included with the Guix installation image.
624 (list parted gptfdisk ddrescue
625 ;; Use the static LVM2 because it's already pulled in by the installer.
626 lvm2-static
627 ;; We used to provide fdisk from GNU fdisk, but as of version 2.0.0a
628 ;; it pulls Guile 1.8, which takes unreasonable space; furthermore
629 ;; util-linux's fdisk is already available, in %base-packages-linux.
630 cryptsetup mdadm
631 dosfstools
632 btrfs-progs
633 e2fsprogs
634 f2fs-tools
635 jfsutils
636 xfsprogs))
637
638(define* (%installation-initrd-modules
639 #:key
640 (system (or (and=>
641 (%current-target-system)
642 platform-target->system)
643 (%current-system))))
644 ;; AArch64 currently lacks a lot of modules necessary
645 ;; for booting from USB sticks, hard disks or
646 ;; CDROMs. Those are built-in in x86_64 kernel.
647 `(,@(if (target-aarch64? system)
648 '("sr_mod" "sd_mod"
649 "usb_common" "usbcore"
650 ;; USB 3.0
651 "xhci_pci" "xhci_hcd"
652 "xhci_plat_hcd"
653 ;; More USB controllers
654 "dwc3" "dwc3_pci"
655 ;; Allwinner
656 "phy_sun4i_usb" "phy_sun50i_usb3"
657 ;; Qualcomm
658 "dwc3_qcom"
659 "phy_qcom_qmp_usb" "phy_qcom_qusb2"
660 "phy_qcom_snps_femto_v2" "phy_qcom_usb_hs"
661 "phy_qcom_usb_ss"
662 ;; Texas Instruments
663 "phy_tusb1210"
664 ;; Rockchip
665 "phy_rockchip_usb"
666 "phy_rockchip_inno_usb2" "phy_rockchip_typec"
667 ;; NXP i.MX
668 "phy_fsl_imx8mq_usb"
669 ;; Generic
670 "phy_generic"
671 ;; "thunderbolt" "typec_thunderbolt"
672 ;; USB 2.0
673 "dwc2"
674 "ehci_pci" "ehci_hcd"
675 "ehci_platform"
676 ;; USB 1.1
677 "ohci_pci" "ohci_hcd"
678 ;; SD cards
679 "mmc_hsq" "mmc_spi"
680 "mmc_core" "mmc_block"
681 "sdhci" "sdhci_pci"
682 "mmc_spi"
683 "sdhci_acpi"
684 ;; Platform specific SD card
685 "dw_mmc" "dw_mmc-pltfm" "dw_mmc-rockchip"
686 "sunxi_mmc" "sdhci_pltfm" "sdhci_msm"
687 "sdhci_of_arasan" "sdhci_of_esdhc" "sdhci_brcmstb"
688 "sdhci_tegra" "phy_rockchip_emmc"
689 "sdhci_esdhc_imx")
690 '())
691 ,@%base-initrd-modules))
692
693(define* (make-installation-os #:key
694 ;; Version displayed in the GRUB entry name.
695 (grub-displayed-version
696 (package-version guix))
697 ;; Whether to use efi-only installation.
698 ;; When #f, use hybrid grub that sets up
699 ;; both legacy boot and efi.
700 (efi-only? #f))
701 ;; The operating system used on installation images for USB sticks etc.
702 (operating-system
703 (host-name "gnu")
704 (timezone "Europe/Paris")
705 (locale "en_US.utf8")
706 (name-service-switch %mdns-host-lookup-nss)
707
708 (initrd-modules (%installation-initrd-modules))
709
710 (bootloader (if efi-only?
711 (bootloader-configuration
712 (bootloader grub-efi-bootloader)
713 (targets '("/boot/efi")))
714 (bootloader-configuration
715 (bootloader grub-bootloader)
716 (targets '("/dev/sda")))))
717 (label (string-append "GNU Guix installation " grub-displayed-version))
718
719 ;; XXX: The AMD Radeon driver is reportedly broken, which makes kmscon
720 ;; non-functional:
721 ;; <https://lists.gnu.org/archive/html/guix-devel/2019-03/msg00441.html>.
722 ;; Thus, blacklist it.
723 (kernel-arguments '("quiet" "modprobe.blacklist=radeon,amdgpu"))
724
725 (file-systems
726 ;; Note: the disk image build code overrides this root file system with
727 ;; the appropriate one.
728 (append %base-live-file-systems
729
730 ;; XXX: This should be %BASE-FILE-SYSTEMS but we don't need
731 ;; elogind's cgroup file systems.
732 (list %pseudo-terminal-file-system
733 %shared-memory-file-system
734 %efivars-file-system
735 %immutable-store)))
736
737 (users (list (user-account
738 (name "guest")
739 (group "users")
740 (supplementary-groups '("wheel")) ; allow use of sudo
741 (password "")
742 (comment "Guest of GNU"))))
743
744 (issue %issue)
745 (services (%installation-services))
746
747 ;; We don't need setuid programs, except for 'passwd', which can be handy
748 ;; if one is to allow remote SSH login to the machine being installed.
749 (privileged-programs (list (privileged-program
750 (program (file-append shadow "/bin/passwd"))
751 (setuid? #t))))
752
753 (pam-services
754 ;; Explicitly allow for empty passwords.
755 (base-pam-services #:allow-empty-passwords? #t))
756
757 (packages (append
758 (list glibc ; for 'tzselect' & co.
759 fontconfig
760 font-dejavu font-gnu-unifont
761
762 ;; Mostly so xrefs to its manual work.
763 (bootloader-package
764 (bootloader-configuration-bootloader bootloader)))
765 %installer-disk-utilities
766 %base-packages))))
767
768(define installation-os (make-installation-os))
769
770(define* (os-with-u-boot os board #:key (bootloader-target "/dev/mmcblk0")
771 (triplet "arm-linux-gnueabihf"))
772 "Given OS, amend it with the u-boot bootloader for BOARD,
773installed to BOOTLOADER-TARGET (a drive), compiled for TRIPLET.
774
775If you want a serial console, make sure to specify one in your
776operating-system's kernel-arguments (\"console=ttyS0\" or similar)."
777 (operating-system (inherit os)
778 (bootloader (bootloader-configuration
779 (bootloader (bootloader (inherit u-boot-bootloader)
780 (package (make-u-boot-package board triplet))))
781 (targets (list bootloader-target))))))
782
783(define* (embedded-installation-os bootloader bootloader-target tty
784 #:key (extra-modules '()))
785 "Return an installation os for embedded systems.
786The initrd gets the extra modules EXTRA-MODULES.
787A getty is provided on TTY.
788The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
789 (operating-system
790 (inherit installation-os)
791 (bootloader (bootloader-configuration
792 (bootloader bootloader)
793 (targets (list bootloader-target))))
794 (kernel linux-libre)
795 (kernel-arguments
796 (cons (string-append "console=" tty)
797 (operating-system-user-kernel-arguments installation-os)))
798 (initrd-modules (append extra-modules %base-initrd-modules))))
799
800(define am335x-evm-installation-os
801 (embedded-installation-os u-boot-am335x-evm-bootloader
802 "/dev/sda"
803 "ttyO0"
804 #:extra-modules
805 ;; This module is required to mount the sd card.
806 '("omap_hsmmc")))
807
808(define beaglebone-black-installation-os
809 (embedded-installation-os u-boot-beaglebone-black-bootloader
810 "/dev/sda"
811 "ttyO0"
812 #:extra-modules
813 ;; This module is required to mount the sd card.
814 '("omap_hsmmc")))
815
816
817(define a20-olinuxino-lime-installation-os
818 (embedded-installation-os u-boot-a20-olinuxino-lime-bootloader
819 "/dev/mmcblk0" ; SD card storage
820 "ttyS0"))
821
822(define a20-olinuxino-lime2-emmc-installation-os
823 (embedded-installation-os u-boot-a20-olinuxino-lime2-bootloader
824 "/dev/mmcblk1" ; eMMC storage
825 "ttyS0"))
826
827(define a20-olinuxino-micro-installation-os
828 (embedded-installation-os u-boot-a20-olinuxino-micro-bootloader
829 "/dev/mmcblk0" ; SD card storage
830 "ttyS0"))
831
832(define bananapi-m2-ultra-installation-os
833 (embedded-installation-os u-boot-bananapi-m2-ultra-bootloader
834 "/dev/mmcblk1" ; eMMC storage
835 "ttyS0"))
836
837(define firefly-rk3399-installation-os
838 (embedded-installation-os u-boot-firefly-rk3399-bootloader
839 "/dev/mmcblk0" ; SD card/eMMC (SD priority) storage
840 "ttyS2")) ; UART2 connected on the Pi2 bus
841
842(define mx6cuboxi-installation-os
843 (embedded-installation-os u-boot-mx6cuboxi-bootloader
844 "/dev/mmcblk0" ; SD card storage
845 "ttymxc0"))
846
847(define novena-installation-os
848 (embedded-installation-os u-boot-novena-bootloader
849 "/dev/mmcblk1" ; SD card storage
850 "ttymxc1"))
851
852(define orangepi-r1-plus-lts-rk3328-installation-os
853 (embedded-installation-os u-boot-orangepi-r1-plus-lts-rk3328-bootloader
854 "/dev/mmcblk0" ; SD card storage
855 "ttyS0"))
856
857(define pine64-plus-installation-os
858 (embedded-installation-os u-boot-pine64-plus-bootloader
859 "/dev/mmcblk0" ; SD card storage
860 "ttyS0"))
861
862(define pinebook-installation-os
863 (embedded-installation-os u-boot-pinebook-bootloader
864 "/dev/mmcblk0" ; SD card storage
865 "ttyS0"))
866
867(define rock64-installation-os
868 (embedded-installation-os u-boot-rock64-rk3328-bootloader
869 "/dev/mmcblk0" ; SD card/eMMC (SD priority) storage
870 "ttyS2")) ; UART2 connected on the Pi2 bus
871
872(define rock-4c-plus-installation-os
873 (embedded-installation-os u-boot-rock-4c-plus-rk3399-bootloader
874 "/dev/mmcblk0" ; SD card storage
875 "ttyS2")) ;; Default UART as per the Linux DTS.
876
877(define rockpro64-installation-os
878 (embedded-installation-os u-boot-rockpro64-rk3399-bootloader
879 "/dev/mmcblk0" ; SD card/eMMC (SD priority) storage
880 "ttyS2")) ; UART2 connected on the Pi2 bus
881
882(define rk3399-puma-installation-os
883 (embedded-installation-os u-boot-puma-rk3399-bootloader
884 "/dev/mmcblk0" ; SD card storage
885 "ttyS0"))
886
887(define wandboard-installation-os
888 (embedded-installation-os u-boot-wandboard-bootloader
889 "/dev/mmcblk0" ; SD card storage
890 "ttymxc0"))
891
892;; Return the default os here so 'guix system' can consume it directly.
893installation-os
894
895;;; install.scm ends here