123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649 |
- (define-module (gnu system install)
- #:use-module (gnu)
- #:use-module (gnu system)
- #:use-module (gnu system setuid)
- #:use-module (gnu bootloader u-boot)
- #:use-module (guix gexp)
- #:use-module (guix store)
- #:use-module (guix monads)
- #:use-module (guix modules)
- #:use-module ((guix packages) #:select (package-version supported-package?))
- #:use-module (guix platform)
- #:use-module ((guix store) #:select (%store-prefix))
- #:use-module (guix utils)
- #:use-module (gnu installer)
- #:use-module (gnu system locale)
- #:use-module (gnu services avahi)
- #:use-module (gnu services dbus)
- #:use-module (gnu services networking)
- #:use-module (gnu services shepherd)
- #:use-module (gnu services ssh)
- #:use-module (gnu packages admin)
- #:use-module (gnu packages bash)
- #:use-module (gnu packages bootloaders)
- #:use-module (gnu packages certs)
- #:use-module (gnu packages compression)
- #:use-module (gnu packages fonts)
- #:use-module (gnu packages fontutils)
- #:use-module (gnu packages guile)
- #:use-module (gnu packages linux)
- #:use-module (gnu packages package-management)
- #:use-module (gnu packages texinfo)
- #:use-module (gnu packages xorg)
- #:use-module (ice-9 match)
- #:use-module (srfi srfi-26)
- #:export (installation-os
- a20-olinuxino-lime-installation-os
- a20-olinuxino-lime2-emmc-installation-os
- a20-olinuxino-micro-installation-os
- bananapi-m2-ultra-installation-os
- beaglebone-black-installation-os
- mx6cuboxi-installation-os
- nintendo-nes-classic-edition-installation-os
- novena-installation-os
- firefly-rk3399-installation-os
- pine64-plus-installation-os
- pinebook-installation-os
- rock64-installation-os
- rockpro64-installation-os
- rk3399-puma-installation-os
- wandboard-installation-os
- os-with-u-boot))
- (define %installation-node-names
-
-
-
- '(("de" . "Systeminstallation")
- ("en" . "System Installation")
- ("es" . "Instalación del sistema")
- ("fr" . "Installation du système")
- ("ru" . "Установка системы")))
- (define (log-to-info tty user)
- "Return a script that spawns the Info reader on the right section of the
- manual."
- (program-file "log-to-info"
- #~(let* ((tty (open-file #$(string-append "/dev/" tty)
- "r0+"))
- (locale (cadr (command-line)))
- (language (string-take locale
- (string-index locale #\_)))
- (infodir "/run/current-system/profile/share/info")
- (per-lang (string-append infodir "/guix." language
- ".info.gz"))
- (file (if (file-exists? per-lang)
- per-lang
- (string-append infodir "/guix.info")))
- (node (or (assoc-ref '#$%installation-node-names
- language)
- "System Installation")))
- (redirect-port tty (current-output-port))
- (redirect-port tty (current-error-port))
- (redirect-port tty (current-input-port))
- (let ((pw (getpwnam #$user)))
- (setgid (passwd:gid pw))
- (setuid (passwd:uid pw)))
-
- (setenv "PATH" (string-append #$gzip "/bin"))
-
-
- (catch #t
- (lambda ()
- (setlocale LC_ALL locale)
- (setenv "LC_ALL" locale))
- (lambda _
-
-
-
- (setlocale LC_ALL "en_US.utf8")
- (setenv "LC_ALL" "en_US.utf8")))
- (execl #$(file-append info-reader "/bin/info")
- "info" "-d" infodir "-f" file "-n" node))))
- (define (documentation-shepherd-service tty)
- (list (shepherd-service
- (provision (list (symbol-append 'term- (string->symbol tty))))
- (requirement '(user-processes host-name udev virtual-terminal))
- (start #~(lambda* (#:optional (locale "en_US.utf8"))
- (fork+exec-command
- (list #$(log-to-info tty "documentation") locale)
- #:environment-variables
- `("GUIX_LOCPATH=/run/current-system/locale"
- "TERM=linux"))))
- (stop #~(make-kill-destructor)))))
- (define %documentation-users
-
- (list (user-account (name "documentation")
- (system? #t)
- (group "nogroup")
- (home-directory "/var/empty"))))
- (define documentation-service-type
-
- (service-type (name 'documentation)
- (extensions
- (list (service-extension shepherd-root-service-type
- documentation-shepherd-service)
- (service-extension account-service-type
- (const %documentation-users))))
- (description "Run the Info reader on a tty.")))
- (define %backing-directory
-
- "/tmp/guix-inst")
- (define cow-store-service-type
- (shepherd-service-type
- 'cow-store
- (lambda _
- (define (import-module? module)
-
-
-
- (and (guix-module-name? module)
- (not (equal? module '(guix store deduplication)))))
- (shepherd-service
- (requirement '(root-file-system user-processes))
- (provision '(cow-store))
- (documentation
- "Make the store copy-on-write, with writes going to \
- the given target.")
-
- (auto-start? #f)
- (modules `((gnu build install)
- ,@%default-modules))
- (start
- (with-imported-modules (source-module-closure
- '((gnu build install))
- #:select? import-module?)
- #~(case-lambda
- ((target)
- (mount-cow-store target #$%backing-directory)
- target)
- (else
-
- #f))))
- (stop #~(lambda (target)
-
-
-
-
- (delete-file-recursively
- (string-append target #$%backing-directory))))))
- (description "Make the store copy-on-write, with writes going to \
- the given target.")))
- (define (cow-store-service)
- "Return a service that makes the store copy-on-write, such that writes go to
- the user's target storage device rather than on the RAM disk."
-
- (service cow-store-service-type 'mooooh!))
- (define (/etc/configuration-files _)
- "Return a list of tuples representing configuration templates to add to
- /etc."
- (define directory
- (computed-file "configuration-templates"
- (with-imported-modules '((guix build utils))
- #~(begin
- (mkdir #$output)
- (for-each (lambda (file target)
- (copy-file file
- (string-append #$output "/"
- target)))
- '(#$(local-file "examples/bare-bones.tmpl")
- #$(local-file "examples/beaglebone-black.tmpl")
- #$(local-file "examples/desktop.tmpl")
- #$(local-file "examples/lightweight-desktop.tmpl"))
- '("bare-bones.scm"
- "beaglebone-black.scm"
- "desktop.scm"
- "lightweight-desktop.scm"))
- #t))))
- `(("configuration" ,directory)))
- (define configuration-template-service-type
- (service-type (name 'configuration-template)
- (extensions
- (list (service-extension etc-service-type
- /etc/configuration-files)))
- (description "Install the operating system configuration file
- templates under @file{/etc/configuration}.")))
- (define %configuration-template-service
- (service configuration-template-service-type #t))
- (define %nscd-minimal-caches
-
- (list (nscd-cache (database 'hosts)
- (positive-time-to-live (* 3600 12))
-
-
-
- (negative-time-to-live 0)
- (persistent? #f)
- (max-database-size (* 5 (expt 2 20))))))
- (define (uvesafb-shepherd-service _)
- (list (shepherd-service
- (documentation "Load the uvesafb kernel module if needed.")
- (provision '(maybe-uvesafb))
- (requirement '(file-systems))
- (start #~(lambda ()
- (or (file-exists? "/dev/fb0")
- (invoke #+(file-append kmod "/bin/modprobe")
- "uvesafb"
- (string-append "v86d=" #$v86d "/sbin/v86d")
- "mode_option=1024x768"))))
- (respawn? #f)
- (one-shot? #t))))
- (define uvesafb-service-type
- (service-type
- (name 'uvesafb)
- (extensions
- (list (service-extension shepherd-root-service-type
- uvesafb-shepherd-service)))
- (description
- "Load the @code{uvesafb} kernel module with the right options.")
- (default-value #t)))
- (define* (%installation-services #:key (system (or (and=>
- (%current-target-system)
- platform-target->system)
- (%current-system))))
-
- (let ((motd (plain-file "motd" "
- \x1b[1;37mWelcome to the installation of GNU Guix!\x1b[0m
- \x1b[2m\
- Using this shell, you can carry out the installation process \"manually.\"
- Access documentation at any time by pressing Alt-F2.\x1b[0m
- ")))
- (define (normal-tty tty)
- (mingetty-service (mingetty-configuration (tty tty)
- (auto-login "root")
- (login-pause? #t))))
- (define bare-bones-os
- (load "examples/bare-bones.tmpl"))
- (append
-
- (list (service virtual-terminal-service-type)
- (service kmscon-service-type
- (kmscon-configuration
- (virtual-terminal "tty1")
- (login-program (installer-program))))
- (login-service (login-configuration
- (motd motd)))
-
-
-
- (service documentation-service-type "tty2")
-
- %configuration-template-service
-
- (normal-tty "tty3")
- (normal-tty "tty4")
- (normal-tty "tty5")
- (normal-tty "tty6")
-
- (syslog-service)
-
-
- (service avahi-service-type)
-
- (service guix-service-type
- (guix-configuration
-
-
-
- (authorize-key? #t)
-
-
- (guix (current-guix))))
-
-
-
- (udev-service #:rules (list lvm2 crda))
-
-
- (cow-store-service)
-
- (service console-font-service-type
- (map (match-lambda
- ("tty2"
-
-
- '("tty2" . "LatGrkCyr-8x16"))
- (tty
-
-
-
- `(,tty . "lat9u-16")))
- '("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
-
- (service gpm-service-type)
-
- (service openssh-service-type
- (openssh-configuration
- (port-number 22)
- (permit-root-login #t)
-
-
- (allow-empty-passwords? #f)
- (password-authentication? #t)
-
- (%auto-start? #f)))
-
-
- (nscd-service (nscd-configuration
- (caches %nscd-minimal-caches)))
-
-
- (service special-files-service-type
- `(("/bin/sh" ,(file-append bash "/bin/sh"))))
-
- (service static-networking-service-type
- (list %loopback-static-networking))
- (service wpa-supplicant-service-type)
- (dbus-service)
- (service connman-service-type
- (connman-configuration
- (disable-vpn? #t)))
-
-
-
-
- (service gc-root-service-type
- (append
- (list bare-bones-os
- glibc-utf8-locales
- texinfo
- guile-3.0)
- %default-locale-libcs)))
-
-
-
-
-
- `(,@(if (supported-package? v86d system)
- (list (service uvesafb-service-type))
- '())))))
- (define %issue
-
- "
- \x1b[1;37mThis is an installation image of the GNU system. Welcome.\x1b[0m
- \x1b[1;33mUse Alt-F2 for documentation.\x1b[0m
- ")
- (define installation-os
-
- (operating-system
- (host-name "gnu")
- (timezone "Europe/Paris")
- (locale "en_US.utf8")
- (name-service-switch %mdns-host-lookup-nss)
- (bootloader (bootloader-configuration
- (bootloader grub-bootloader)
- (targets '("/dev/sda"))))
- (label (string-append "GNU Guix installation "
- (or (getenv "GUIX_DISPLAYED_VERSION")
- (package-version guix))))
-
-
-
-
- (kernel-arguments '("quiet" "modprobe.blacklist=radeon,amdgpu"))
- (file-systems
-
-
- (cons* (file-system
- (mount-point "/")
- (device (file-system-label "Guix_image"))
- (type "ext4"))
-
-
-
-
-
-
- (file-system
- (mount-point "/tmp")
- (device "none")
- (type "tmpfs")
- (check? #f))
-
-
- (list %pseudo-terminal-file-system
- %shared-memory-file-system
- %efivars-file-system
- %immutable-store)))
- (users (list (user-account
- (name "guest")
- (group "users")
- (supplementary-groups '("wheel"))
- (password "")
- (comment "Guest of GNU"))))
- (issue %issue)
- (services (%installation-services))
-
-
- (setuid-programs (list (setuid-program
- (program (file-append shadow "/bin/passwd")))))
- (pam-services
-
- (base-pam-services #:allow-empty-passwords? #t))
- (packages (append
- (list glibc
- fontconfig
- font-dejavu font-gnu-unifont
- grub
- nss-certs)
- %base-packages-disk-utilities
- %base-packages))))
- (define* (os-with-u-boot os board #:key (bootloader-target "/dev/mmcblk0")
- (triplet "arm-linux-gnueabihf"))
- "Given OS, amend it with the u-boot bootloader for BOARD,
- installed to BOOTLOADER-TARGET (a drive), compiled for TRIPLET.
- If you want a serial console, make sure to specify one in your
- operating-system's kernel-arguments (\"console=ttyS0\" or similar)."
- (operating-system (inherit os)
- (bootloader (bootloader-configuration
- (bootloader (bootloader (inherit u-boot-bootloader)
- (package (make-u-boot-package board triplet))))
- (targets (list bootloader-target))))))
- (define* (embedded-installation-os bootloader bootloader-target tty
- #:key (extra-modules '()))
- "Return an installation os for embedded systems.
- The initrd gets the extra modules EXTRA-MODULES.
- A getty is provided on TTY.
- The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
- (operating-system
- (inherit installation-os)
- (bootloader (bootloader-configuration
- (bootloader bootloader)
- (targets (list bootloader-target))))
- (kernel linux-libre)
- (kernel-arguments
- (cons (string-append "console=" tty)
- (operating-system-user-kernel-arguments installation-os)))
- (initrd-modules (append extra-modules %base-initrd-modules))))
- (define beaglebone-black-installation-os
- (embedded-installation-os u-boot-beaglebone-black-bootloader
- "/dev/sda"
- "ttyO0"
- #:extra-modules
-
- '("omap_hsmmc")))
- (define a20-olinuxino-lime-installation-os
- (embedded-installation-os u-boot-a20-olinuxino-lime-bootloader
- "/dev/mmcblk0"
- "ttyS0"))
- (define a20-olinuxino-lime2-emmc-installation-os
- (embedded-installation-os u-boot-a20-olinuxino-lime2-bootloader
- "/dev/mmcblk1"
- "ttyS0"))
- (define a20-olinuxino-micro-installation-os
- (embedded-installation-os u-boot-a20-olinuxino-micro-bootloader
- "/dev/mmcblk0"
- "ttyS0"))
- (define bananapi-m2-ultra-installation-os
- (embedded-installation-os u-boot-bananapi-m2-ultra-bootloader
- "/dev/mmcblk1"
- "ttyS0"))
- (define firefly-rk3399-installation-os
- (embedded-installation-os u-boot-firefly-rk3399-bootloader
- "/dev/mmcblk0"
- "ttyS2"))
- (define mx6cuboxi-installation-os
- (embedded-installation-os u-boot-mx6cuboxi-bootloader
- "/dev/mmcblk0"
- "ttymxc0"))
- (define novena-installation-os
- (embedded-installation-os u-boot-novena-bootloader
- "/dev/mmcblk1"
- "ttymxc1"))
- (define nintendo-nes-classic-edition-installation-os
- (embedded-installation-os u-boot-nintendo-nes-classic-edition-bootloader
- "/dev/mmcblk0"
- "ttyS0"))
- (define pine64-plus-installation-os
- (embedded-installation-os u-boot-pine64-plus-bootloader
- "/dev/mmcblk0"
- "ttyS0"))
- (define pinebook-installation-os
- (embedded-installation-os u-boot-pinebook-bootloader
- "/dev/mmcblk0"
- "ttyS0"))
- (define rock64-installation-os
- (embedded-installation-os u-boot-rock64-rk3328-bootloader
- "/dev/mmcblk0"
- "ttyS2"))
- (define rockpro64-installation-os
- (embedded-installation-os u-boot-rockpro64-rk3399-bootloader
- "/dev/mmcblk0"
- "ttyS2"))
- (define rk3399-puma-installation-os
- (embedded-installation-os u-boot-puma-rk3399-bootloader
- "/dev/mmcblk0"
- "ttyS0"))
- (define wandboard-installation-os
- (embedded-installation-os u-boot-wandboard-bootloader
- "/dev/mmcblk0"
- "ttymxc0"))
- installation-os
|