2013-09-11 20:36:50 +00:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2020-01-03 11:16:52 +00:00
|
|
|
|
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
|
2016-10-28 10:07:18 +00:00
|
|
|
|
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
|
2017-05-11 07:12:44 +00:00
|
|
|
|
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
|
2020-05-23 17:09:14 +00:00
|
|
|
|
;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
|
2023-05-23 14:03:53 +00:00
|
|
|
|
;;; Copyright © 2019, 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
|
2020-12-21 12:02:01 +00:00
|
|
|
|
;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
|
2020-02-19 20:35:46 +00:00
|
|
|
|
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
2020-06-09 12:16:59 +00:00
|
|
|
|
;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de>
|
2022-05-25 04:32:54 +00:00
|
|
|
|
;;; Copyright © 2022 Karl Hallsby <karl@hallsby.com>
|
2022-06-18 05:18:35 +00:00
|
|
|
|
;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
2013-09-11 20:36:50 +00:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2017-05-15 20:24:18 +00:00
|
|
|
|
(define-module (gnu bootloader grub)
|
2020-09-26 10:54:00 +00:00
|
|
|
|
#:use-module (guix build union)
|
2013-09-11 20:36:50 +00:00
|
|
|
|
#:use-module (guix records)
|
2020-09-26 10:54:00 +00:00
|
|
|
|
#:use-module (guix store)
|
|
|
|
|
#:use-module (guix utils)
|
2014-04-28 21:40:24 +00:00
|
|
|
|
#:use-module (guix gexp)
|
2014-11-12 13:28:36 +00:00
|
|
|
|
#:use-module (gnu artwork)
|
2017-05-15 20:24:18 +00:00
|
|
|
|
#:use-module (gnu bootloader)
|
2017-09-06 07:28:28 +00:00
|
|
|
|
#:use-module (gnu system uuid)
|
2018-05-18 11:43:07 +00:00
|
|
|
|
#:use-module (gnu system file-systems)
|
2019-03-17 21:37:53 +00:00
|
|
|
|
#:use-module (gnu system keyboard)
|
2019-11-02 17:18:45 +00:00
|
|
|
|
#:use-module (gnu system locale)
|
2020-01-06 14:14:09 +00:00
|
|
|
|
#:use-module (gnu packages bootloaders)
|
2016-10-24 22:58:26 +00:00
|
|
|
|
#:autoload (gnu packages gtk) (guile-cairo guile-rsvg)
|
2019-03-17 21:37:53 +00:00
|
|
|
|
#:autoload (gnu packages xorg) (xkeyboard-config)
|
2013-09-11 20:36:50 +00:00
|
|
|
|
#:use-module (ice-9 match)
|
2015-08-09 22:45:49 +00:00
|
|
|
|
#:use-module (ice-9 regex)
|
2013-09-11 20:36:50 +00:00
|
|
|
|
#:use-module (srfi srfi-1)
|
2020-02-19 20:59:06 +00:00
|
|
|
|
#:use-module (srfi srfi-2)
|
2020-05-17 21:53:50 +00:00
|
|
|
|
#:export (grub-theme
|
2014-11-08 14:07:18 +00:00
|
|
|
|
grub-theme?
|
2020-05-17 21:53:50 +00:00
|
|
|
|
grub-theme-image
|
|
|
|
|
grub-theme-resolution
|
2014-11-08 14:07:18 +00:00
|
|
|
|
grub-theme-color-normal
|
|
|
|
|
grub-theme-color-highlight
|
2020-05-17 21:53:50 +00:00
|
|
|
|
grub-theme-gfxmode
|
2014-11-08 14:07:18 +00:00
|
|
|
|
|
2022-05-25 04:32:54 +00:00
|
|
|
|
install-grub-efi-removable
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
make-grub-efi-netboot-installer
|
2020-09-26 10:54:00 +00:00
|
|
|
|
|
2017-05-15 20:24:18 +00:00
|
|
|
|
grub-bootloader
|
|
|
|
|
grub-efi-bootloader
|
2022-05-25 04:32:54 +00:00
|
|
|
|
grub-efi-removable-bootloader
|
2022-06-18 05:18:35 +00:00
|
|
|
|
grub-efi32-bootloader
|
2020-09-26 10:54:00 +00:00
|
|
|
|
grub-efi-netboot-bootloader
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
grub-efi-netboot-removable-bootloader
|
2017-07-20 23:06:48 +00:00
|
|
|
|
grub-mkrescue-bootloader
|
2020-03-08 20:17:27 +00:00
|
|
|
|
grub-minimal-bootloader
|
2014-05-18 19:58:01 +00:00
|
|
|
|
|
2017-05-15 20:24:18 +00:00
|
|
|
|
grub-configuration))
|
2013-09-11 20:36:50 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;;
|
|
|
|
|
;;; Configuration of GNU GRUB.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2020-05-28 02:44:28 +00:00
|
|
|
|
(define* (normalize-file file mount-point store-directory-prefix)
|
|
|
|
|
"Strip MOUNT-POINT and prepend STORE-DIRECTORY-PREFIX, if any, to FILE, a
|
2019-07-14 11:50:23 +00:00
|
|
|
|
G-expression or other lowerable object denoting a file name."
|
|
|
|
|
|
|
|
|
|
(define (strip-mount-point mount-point file)
|
|
|
|
|
(if mount-point
|
|
|
|
|
(if (string=? mount-point "/")
|
|
|
|
|
file
|
|
|
|
|
#~(let ((file #$file))
|
|
|
|
|
(if (string-prefix? #$mount-point file)
|
|
|
|
|
(substring #$file #$(string-length mount-point))
|
|
|
|
|
file)))
|
|
|
|
|
file))
|
|
|
|
|
|
2020-05-28 02:44:28 +00:00
|
|
|
|
(define (prepend-store-directory-prefix store-directory-prefix file)
|
|
|
|
|
(if store-directory-prefix
|
|
|
|
|
#~(string-append #$store-directory-prefix #$file)
|
2019-07-14 11:50:23 +00:00
|
|
|
|
file))
|
|
|
|
|
|
2020-05-28 02:44:28 +00:00
|
|
|
|
(prepend-store-directory-prefix store-directory-prefix
|
|
|
|
|
(strip-mount-point mount-point file)))
|
2019-07-14 11:50:23 +00:00
|
|
|
|
|
|
|
|
|
|
2016-09-14 14:13:24 +00:00
|
|
|
|
|
2014-11-08 14:07:18 +00:00
|
|
|
|
(define-record-type* <grub-theme>
|
2020-05-17 21:53:50 +00:00
|
|
|
|
;; Default theme contributed by Felipe López.
|
2014-11-08 14:07:18 +00:00
|
|
|
|
grub-theme make-grub-theme
|
|
|
|
|
grub-theme?
|
2020-05-17 21:53:50 +00:00
|
|
|
|
(image grub-theme-image
|
|
|
|
|
(default (file-append %artwork-repository
|
|
|
|
|
"/grub/GuixSD-fully-black-4-3.svg")))
|
|
|
|
|
(resolution grub-theme-resolution
|
|
|
|
|
(default '(1024 . 768)))
|
2014-11-08 14:07:18 +00:00
|
|
|
|
(color-normal grub-theme-color-normal
|
2020-05-17 21:53:50 +00:00
|
|
|
|
(default '((fg . light-gray) (bg . black))))
|
2014-11-08 14:07:18 +00:00
|
|
|
|
(color-highlight grub-theme-color-highlight
|
2020-05-17 21:53:50 +00:00
|
|
|
|
(default '((fg . yellow) (bg . black))))
|
|
|
|
|
(gfxmode grub-theme-gfxmode
|
2019-12-30 10:25:40 +00:00
|
|
|
|
(default '("auto")))) ;list of string
|
2014-11-08 14:07:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Background image & themes.
|
|
|
|
|
;;;
|
|
|
|
|
|
2017-05-15 20:24:18 +00:00
|
|
|
|
(define (bootloader-theme config)
|
2020-05-17 21:53:50 +00:00
|
|
|
|
"Return user defined theme in CONFIG if defined or a default theme
|
2017-05-15 20:24:18 +00:00
|
|
|
|
otherwise."
|
2020-05-17 21:53:50 +00:00
|
|
|
|
(or (bootloader-configuration-theme config) (grub-theme)))
|
2017-05-15 20:24:18 +00:00
|
|
|
|
|
2020-05-17 21:53:50 +00:00
|
|
|
|
(define* (image->png image #:key width height)
|
|
|
|
|
"Build a PNG of HEIGHT x WIDTH from IMAGE if its file suffix is \".svg\".
|
|
|
|
|
Otherwise the picture in IMAGE is just copied."
|
2018-11-15 12:32:07 +00:00
|
|
|
|
(computed-file "grub-image.png"
|
|
|
|
|
(with-imported-modules '((gnu build svg))
|
|
|
|
|
(with-extensions (list guile-rsvg guile-cairo)
|
2020-05-17 21:53:50 +00:00
|
|
|
|
#~(if (string-suffix? ".svg" #+image)
|
|
|
|
|
(begin
|
|
|
|
|
(use-modules (gnu build svg))
|
|
|
|
|
(svg->png #+image #$output
|
|
|
|
|
#:width #$width
|
|
|
|
|
#:height #$height))
|
|
|
|
|
(copy-file #+image #$output))))))
|
|
|
|
|
|
|
|
|
|
(define* (grub-background-image config)
|
|
|
|
|
"Return the GRUB background image defined in CONFIG or #f if none was found.
|
|
|
|
|
If the suffix of the image file is \".svg\", then it is converted into a PNG
|
|
|
|
|
file with the resolution provided in CONFIG."
|
|
|
|
|
(let* ((theme (bootloader-theme config))
|
|
|
|
|
(image (grub-theme-image theme)))
|
2018-11-15 12:32:07 +00:00
|
|
|
|
(and image
|
2020-05-17 21:53:50 +00:00
|
|
|
|
(match (grub-theme-resolution theme)
|
|
|
|
|
(((? number? width) . (? number? height))
|
|
|
|
|
(image->png image #:width width #:height height))
|
|
|
|
|
(_ #f)))))
|
2014-11-08 14:07:18 +00:00
|
|
|
|
|
2020-10-24 18:36:21 +00:00
|
|
|
|
(define (grub-locale-directory grub)
|
|
|
|
|
"Generate a directory with the locales from GRUB."
|
|
|
|
|
(define builder
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (ice-9 ftw))
|
|
|
|
|
(let ((locale (string-append #$grub "/share/locale"))
|
|
|
|
|
(out #$output))
|
|
|
|
|
(mkdir out)
|
|
|
|
|
(chdir out)
|
|
|
|
|
(for-each (lambda (lang)
|
|
|
|
|
(let ((file (string-append locale "/" lang
|
|
|
|
|
"/LC_MESSAGES/grub.mo"))
|
|
|
|
|
(dest (string-append lang ".mo")))
|
|
|
|
|
(when (file-exists? file)
|
|
|
|
|
(copy-file file dest))))
|
|
|
|
|
(scandir locale)))))
|
|
|
|
|
(computed-file "grub-locales" builder))
|
|
|
|
|
|
2016-10-28 10:07:18 +00:00
|
|
|
|
(define* (eye-candy config store-device store-mount-point
|
2020-06-09 12:16:59 +00:00
|
|
|
|
#:key store-directory-prefix port)
|
2019-07-14 11:50:23 +00:00
|
|
|
|
"Return a gexp that writes to PORT (a port-valued gexp) the 'grub.cfg' part
|
|
|
|
|
concerned with graphics mode, background images, colors, and all that.
|
|
|
|
|
STORE-DEVICE designates the device holding the store, and STORE-MOUNT-POINT is
|
|
|
|
|
its mount point; these are used to determine where the background image and
|
2020-06-09 12:16:59 +00:00
|
|
|
|
fonts must be searched for. STORE-DIRECTORY-PREFIX is a directory prefix to
|
|
|
|
|
prepend to any store file name."
|
2020-12-28 11:24:16 +00:00
|
|
|
|
(define (setup-gfxterm config)
|
2017-05-15 20:24:18 +00:00
|
|
|
|
(if (memq 'gfxterm (bootloader-configuration-terminal-outputs config))
|
2020-06-09 12:16:59 +00:00
|
|
|
|
#~(format #f "
|
2020-12-28 11:24:16 +00:00
|
|
|
|
if loadfont unicode; then
|
2020-06-09 12:16:59 +00:00
|
|
|
|
set gfxmode=~a
|
|
|
|
|
insmod all_video
|
|
|
|
|
insmod gfxterm
|
|
|
|
|
fi~%"
|
|
|
|
|
#$(string-join
|
|
|
|
|
(grub-theme-gfxmode (bootloader-theme config))
|
|
|
|
|
";"))
|
2017-05-15 20:24:18 +00:00
|
|
|
|
""))
|
2017-05-11 07:12:44 +00:00
|
|
|
|
|
2014-11-08 14:07:18 +00:00
|
|
|
|
(define (theme-colors type)
|
2017-05-15 20:24:18 +00:00
|
|
|
|
(let* ((theme (bootloader-theme config))
|
2014-11-08 14:07:18 +00:00
|
|
|
|
(colors (type theme)))
|
|
|
|
|
(string-append (symbol->string (assoc-ref colors 'fg)) "/"
|
|
|
|
|
(symbol->string (assoc-ref colors 'bg)))))
|
|
|
|
|
|
2018-11-15 12:32:07 +00:00
|
|
|
|
(define image
|
2019-07-14 11:50:23 +00:00
|
|
|
|
(normalize-file (grub-background-image config)
|
|
|
|
|
store-mount-point
|
2020-05-28 02:44:28 +00:00
|
|
|
|
store-directory-prefix))
|
2018-11-15 12:32:07 +00:00
|
|
|
|
|
|
|
|
|
(and image
|
|
|
|
|
#~(format #$port "
|
2014-12-13 21:15:01 +00:00
|
|
|
|
# Set 'root' to the partition that contains /gnu/store.
|
2016-01-21 21:45:54 +00:00
|
|
|
|
~a
|
2014-12-13 21:15:01 +00:00
|
|
|
|
|
2017-05-11 07:12:44 +00:00
|
|
|
|
~a
|
|
|
|
|
~a
|
2014-11-08 14:07:18 +00:00
|
|
|
|
|
|
|
|
|
insmod png
|
|
|
|
|
if background_image ~a; then
|
|
|
|
|
set color_normal=~a
|
|
|
|
|
set color_highlight=~a
|
|
|
|
|
else
|
|
|
|
|
set menu_color_normal=cyan/blue
|
|
|
|
|
set menu_color_highlight=white/blue
|
|
|
|
|
fi~%"
|
2020-12-28 11:24:16 +00:00
|
|
|
|
#$(grub-root-search store-device image)
|
|
|
|
|
#$(setup-gfxterm config)
|
2018-11-15 12:32:07 +00:00
|
|
|
|
#$(grub-setup-io config)
|
2016-01-21 21:45:54 +00:00
|
|
|
|
|
2019-07-14 11:50:23 +00:00
|
|
|
|
#$image
|
2018-11-15 12:32:07 +00:00
|
|
|
|
#$(theme-colors grub-theme-color-normal)
|
|
|
|
|
#$(theme-colors grub-theme-color-highlight))))
|
2014-11-08 14:07:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Configuration file.
|
|
|
|
|
;;;
|
|
|
|
|
|
2019-03-17 21:37:53 +00:00
|
|
|
|
(define* (keyboard-layout-file layout
|
|
|
|
|
#:key
|
|
|
|
|
(grub grub))
|
|
|
|
|
"Process the X keyboard layout description LAYOUT, a <keyboard-layout> record,
|
|
|
|
|
and return a file in the format for GRUB keymaps. LAYOUT must be present in
|
|
|
|
|
the 'share/X11/xkb/symbols/' directory of 'xkeyboard-config'."
|
|
|
|
|
(define builder
|
|
|
|
|
(with-imported-modules '((guix build utils))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
|
|
|
|
|
|
;; 'grub-kbdcomp' passes all its arguments but '-o' to 'ckbcomp'
|
|
|
|
|
;; (from the 'console-setup' package).
|
2020-05-15 14:01:20 +00:00
|
|
|
|
(invoke #+(file-append grub "/bin/grub-mklayout")
|
2019-03-17 21:37:53 +00:00
|
|
|
|
"-i" #+(keyboard-layout->console-keymap layout)
|
|
|
|
|
"-o" #$output))))
|
|
|
|
|
|
2020-04-05 21:37:33 +00:00
|
|
|
|
(computed-file (string-append "grub-keymap."
|
|
|
|
|
(string-map (match-lambda
|
|
|
|
|
(#\, #\-)
|
|
|
|
|
(chr chr))
|
|
|
|
|
(keyboard-layout-name layout)))
|
2019-03-17 21:37:53 +00:00
|
|
|
|
builder))
|
|
|
|
|
|
2017-05-11 07:12:44 +00:00
|
|
|
|
(define (grub-setup-io config)
|
|
|
|
|
"Return GRUB commands to configure the input / output interfaces. The result
|
|
|
|
|
is a string that can be inserted in grub.cfg."
|
|
|
|
|
(let* ((symbols->string (lambda (list)
|
|
|
|
|
(string-join (map symbol->string list) " ")))
|
2017-05-15 20:24:18 +00:00
|
|
|
|
(outputs (bootloader-configuration-terminal-outputs config))
|
|
|
|
|
(inputs (bootloader-configuration-terminal-inputs config))
|
|
|
|
|
(unit (bootloader-configuration-serial-unit config))
|
|
|
|
|
(speed (bootloader-configuration-serial-speed config))
|
2017-05-11 07:12:44 +00:00
|
|
|
|
|
|
|
|
|
;; Respectively, GRUB_TERMINAL_OUTPUT and GRUB_TERMINAL_INPUT,
|
|
|
|
|
;; as documented in GRUB manual section "Simple Configuration
|
|
|
|
|
;; Handling".
|
|
|
|
|
(valid-outputs '(console serial serial_0 serial_1 serial_2 serial_3
|
|
|
|
|
gfxterm vga_text mda_text morse spkmodem))
|
|
|
|
|
(valid-inputs '(console serial serial_0 serial_1 serial_2 serial_3
|
|
|
|
|
at_keyboard usb_keyboard))
|
|
|
|
|
|
|
|
|
|
(io (string-append
|
2022-01-13 10:06:31 +00:00
|
|
|
|
;; UNIT and SPEED are arguments to the same GRUB command
|
|
|
|
|
;; ("serial"), so we process them together.
|
|
|
|
|
(if (or unit speed)
|
|
|
|
|
(string-append
|
2017-05-11 07:12:44 +00:00
|
|
|
|
"serial"
|
|
|
|
|
(if unit
|
2022-01-13 10:06:31 +00:00
|
|
|
|
;; COM ports 1 through 4
|
|
|
|
|
(if (and (exact-integer? unit) (<= unit 3) (>= unit 0))
|
|
|
|
|
(string-append " --unit=" (number->string unit))
|
|
|
|
|
#f)
|
|
|
|
|
"")
|
2017-05-11 07:12:44 +00:00
|
|
|
|
(if speed
|
2022-01-13 10:06:31 +00:00
|
|
|
|
(if (exact-integer? speed)
|
|
|
|
|
(string-append " --speed=" (number->string speed))
|
|
|
|
|
#f)
|
|
|
|
|
"")
|
|
|
|
|
"\n")
|
|
|
|
|
"")
|
|
|
|
|
(if (null? inputs)
|
|
|
|
|
""
|
|
|
|
|
(string-append
|
|
|
|
|
"terminal_input "
|
|
|
|
|
(symbols->string
|
|
|
|
|
(map
|
|
|
|
|
(lambda (input)
|
|
|
|
|
(if (memq input valid-inputs) input #f)) inputs))
|
|
|
|
|
"\n"))
|
|
|
|
|
"terminal_output "
|
|
|
|
|
(symbols->string
|
|
|
|
|
(map
|
|
|
|
|
(lambda (output)
|
|
|
|
|
(if (memq output valid-outputs) output #f)) outputs)))))
|
2017-05-11 07:12:44 +00:00
|
|
|
|
(format #f "~a" io)))
|
|
|
|
|
|
2016-10-28 10:07:18 +00:00
|
|
|
|
(define (grub-root-search device file)
|
|
|
|
|
"Return the GRUB 'search' command to look for DEVICE, which contains FILE,
|
2016-01-21 21:45:54 +00:00
|
|
|
|
a gexp. The result is a gexp that can be inserted in the grub.cfg-generation
|
|
|
|
|
code."
|
2016-09-25 15:12:50 +00:00
|
|
|
|
;; Usually FILE is a file name gexp like "/gnu/store/…-linux/vmlinuz", but
|
|
|
|
|
;; it can also be something like "(hd0,msdos1)/vmlinuz" in the case of
|
|
|
|
|
;; custom menu entries. In the latter case, don't emit a 'search' command.
|
|
|
|
|
(if (and (string? file) (not (string-prefix? "/" file)))
|
|
|
|
|
""
|
2016-10-28 10:07:18 +00:00
|
|
|
|
(match device
|
|
|
|
|
;; Preferably refer to DEVICE by its UUID or label. This is more
|
2017-03-06 21:51:22 +00:00
|
|
|
|
;; efficient and less ambiguous, see <http://bugs.gnu.org/22281>.
|
2017-09-06 07:28:28 +00:00
|
|
|
|
((? uuid? uuid)
|
2016-09-25 15:12:50 +00:00
|
|
|
|
(format #f "search --fs-uuid --set ~a"
|
2016-10-28 10:07:18 +00:00
|
|
|
|
(uuid->string device)))
|
2018-05-18 11:43:07 +00:00
|
|
|
|
((? file-system-label? label)
|
|
|
|
|
(format #f "search --label --set ~a"
|
|
|
|
|
(file-system-label->string label)))
|
2020-09-14 12:20:16 +00:00
|
|
|
|
((? (lambda (device)
|
|
|
|
|
(and (string? device) (string-contains device ":/"))) nfs-uri)
|
2020-09-26 10:54:00 +00:00
|
|
|
|
;; If the device is an NFS share, then we assume that the expected
|
|
|
|
|
;; file on that device (e.g. the GRUB background image or the kernel)
|
|
|
|
|
;; has to be loaded over the network. Otherwise we would need an
|
|
|
|
|
;; additional device information for some local disk to look for that
|
|
|
|
|
;; file, which we do not have.
|
2020-09-14 12:20:16 +00:00
|
|
|
|
;;
|
|
|
|
|
;; We explicitly set "root=(tftp)" here even though if grub.cfg
|
|
|
|
|
;; had been loaded via TFTP, Grub would have set "root=(tftp)"
|
|
|
|
|
;; automatically anyway. The reason is if you have a system that
|
|
|
|
|
;; used to be on NFS but now is local, root would be set to local
|
|
|
|
|
;; disk. If you then selected an older system generation that is
|
|
|
|
|
;; supposed to boot from network in the Grub boot menu, Grub still
|
|
|
|
|
;; wouldn't load those files from network otherwise.
|
|
|
|
|
;;
|
|
|
|
|
;; TFTP is preferred to HTTP because it is used more widely and
|
|
|
|
|
;; specified in standards more widely--especially BOOTP/DHCPv4
|
|
|
|
|
;; defines a TFTP server for DHCP option 66, but not HTTP.
|
|
|
|
|
;;
|
|
|
|
|
;; Note: DHCPv6 specifies option 59 to contain a boot-file-url,
|
|
|
|
|
;; which can contain a HTTP or TFTP URL.
|
|
|
|
|
;;
|
|
|
|
|
;; Note: It is assumed that the file paths are of a similar
|
|
|
|
|
;; setup on both the TFTP server and the NFS server (it is
|
|
|
|
|
;; not possible to search for files on TFTP).
|
|
|
|
|
;;
|
|
|
|
|
;; TODO: Allow HTTP.
|
|
|
|
|
"set root=(tftp)")
|
2018-05-18 11:43:07 +00:00
|
|
|
|
((or #f (? string?))
|
2016-09-25 15:12:50 +00:00
|
|
|
|
#~(format #f "search --file --set ~a" #$file)))))
|
2016-01-21 21:45:54 +00:00
|
|
|
|
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(define* (make-grub-configuration grub config entries
|
2014-06-25 20:54:52 +00:00
|
|
|
|
#:key
|
2019-11-02 17:18:45 +00:00
|
|
|
|
(locale #f)
|
2014-06-25 20:54:52 +00:00
|
|
|
|
(system (%current-system))
|
2019-07-14 11:50:23 +00:00
|
|
|
|
(old-entries '())
|
2020-12-21 12:02:01 +00:00
|
|
|
|
(store-crypto-devices '())
|
2020-05-28 02:44:28 +00:00
|
|
|
|
store-directory-prefix)
|
2014-05-18 19:58:01 +00:00
|
|
|
|
"Return the GRUB configuration file corresponding to CONFIG, a
|
2017-05-15 20:24:18 +00:00
|
|
|
|
<bootloader-configuration> object, and where the store is available at
|
2020-05-28 02:44:28 +00:00
|
|
|
|
STORE-FS, a <file-system> object. OLD-ENTRIES is taken to be a list of menu
|
|
|
|
|
entries corresponding to old generations of the system.
|
2020-12-21 12:02:01 +00:00
|
|
|
|
STORE-CRYPTO-DEVICES contain the UUIDs of the encrypted units that must
|
|
|
|
|
be unlocked to access the store contents.
|
2020-05-28 02:44:28 +00:00
|
|
|
|
STORE-DIRECTORY-PREFIX may be used to specify a store prefix, as is required
|
|
|
|
|
when booting a root file system on a Btrfs subvolume."
|
2014-05-18 19:58:01 +00:00
|
|
|
|
(define all-entries
|
2017-06-29 10:42:59 +00:00
|
|
|
|
(append entries (bootloader-configuration-menu-entries config)))
|
|
|
|
|
(define (menu-entry->gexp entry)
|
2020-05-26 16:09:01 +00:00
|
|
|
|
(let ((label (menu-entry-label entry))
|
|
|
|
|
(linux (menu-entry-linux entry))
|
|
|
|
|
(device (menu-entry-device entry))
|
2022-09-04 17:25:40 +00:00
|
|
|
|
(device-mount-point (menu-entry-device-mount-point entry))
|
|
|
|
|
(multiboot-kernel (menu-entry-multiboot-kernel entry))
|
|
|
|
|
(chain-loader (menu-entry-chain-loader entry)))
|
|
|
|
|
(cond
|
|
|
|
|
(linux
|
|
|
|
|
(let ((arguments (menu-entry-linux-arguments entry))
|
|
|
|
|
(linux (normalize-file linux
|
|
|
|
|
device-mount-point
|
|
|
|
|
store-directory-prefix))
|
|
|
|
|
(initrd (normalize-file (menu-entry-initrd entry)
|
|
|
|
|
device-mount-point
|
|
|
|
|
store-directory-prefix)))
|
|
|
|
|
;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point.
|
|
|
|
|
;; Use the right file names for LINUX and INITRD in case
|
|
|
|
|
;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a
|
|
|
|
|
;; separate partition.
|
|
|
|
|
|
2022-12-08 04:18:55 +00:00
|
|
|
|
;; When STORE-DIRECTORY-PREFIX is defined, prepend it the linux and
|
2022-09-04 17:25:40 +00:00
|
|
|
|
;; initrd paths, to allow booting from a Btrfs subvolume.
|
|
|
|
|
#~(format port "menuentry ~s {
|
2016-01-21 21:45:54 +00:00
|
|
|
|
~a
|
2016-09-09 21:27:00 +00:00
|
|
|
|
linux ~a ~a
|
gnu: vm: Rewrite helper functions as monadic functions.
* gnu/system/dmd.scm (host-name-service, nscd-service, mingetty-service,
syslog-service, guix-service, static-networking-service): Rewrite as
monadic functions.
(dmd-configuration-file): Use 'text-file' instead of
'add-text-to-store'.
* gnu/system/grub.scm (grub-configuration-file): Rewrite as a monadic
function.
* gnu/system/linux.scm (pam-services->directory): Likewise.
* gnu/system/shadow.scm (group-file, passwd-file, guix-build-accounts):
Likewise.
* gnu/system/vm.scm (expression->derivation-in-linux-vm, qemu-image,
union, system-qemu-image): Likewise.
2013-10-03 19:30:30 +00:00
|
|
|
|
initrd ~a
|
2013-09-11 20:36:50 +00:00
|
|
|
|
}~%"
|
2022-09-04 17:25:40 +00:00
|
|
|
|
#$label
|
|
|
|
|
#$(grub-root-search device linux)
|
|
|
|
|
#$linux (string-join (list #$@arguments))
|
|
|
|
|
#$initrd)))
|
|
|
|
|
(multiboot-kernel
|
2023-05-23 14:03:53 +00:00
|
|
|
|
(let* ((kernel (menu-entry-multiboot-kernel entry))
|
|
|
|
|
(arguments (menu-entry-multiboot-arguments entry))
|
|
|
|
|
;; Choose between device names as understood by Mach's built-in
|
|
|
|
|
;; IDE driver ("hdX") and those understood by rumpdisk ("wdX"
|
|
|
|
|
;; in the "noide" case).
|
|
|
|
|
(disk (if (member "noide" arguments) "w" "h"))
|
|
|
|
|
(modules (menu-entry-multiboot-modules entry))
|
|
|
|
|
(root-index 1)) ; XXX EFI will need root-index 2
|
2022-09-04 17:25:40 +00:00
|
|
|
|
#~(format port "
|
2020-05-26 16:09:01 +00:00
|
|
|
|
menuentry ~s {
|
2023-05-23 14:03:53 +00:00
|
|
|
|
multiboot ~a root=part:~a:device:~ad0~a~a
|
2022-09-04 17:25:40 +00:00
|
|
|
|
}~%"
|
|
|
|
|
#$label
|
|
|
|
|
#$kernel
|
2023-05-23 14:03:53 +00:00
|
|
|
|
#$root-index
|
|
|
|
|
#$disk
|
|
|
|
|
(string-join (list #$@arguments) " " 'prefix)
|
2022-09-04 17:25:40 +00:00
|
|
|
|
(string-join (map string-join '#$modules)
|
|
|
|
|
"\n module " 'prefix))))
|
|
|
|
|
(chain-loader
|
|
|
|
|
#~(format port "
|
|
|
|
|
menuentry ~s {
|
|
|
|
|
~a
|
|
|
|
|
chainloader ~a
|
2020-05-26 16:09:01 +00:00
|
|
|
|
}~%"
|
|
|
|
|
#$label
|
2022-09-04 17:25:40 +00:00
|
|
|
|
#$(grub-root-search device chain-loader)
|
|
|
|
|
#$chain-loader)))))
|
2020-05-26 16:09:01 +00:00
|
|
|
|
|
2020-12-21 12:02:01 +00:00
|
|
|
|
(define (crypto-devices)
|
|
|
|
|
(define (crypto-device->cryptomount dev)
|
|
|
|
|
(if (uuid? dev)
|
|
|
|
|
#~(format port "cryptomount -u ~a~%"
|
|
|
|
|
;; cryptomount only accepts UUID without the hypen.
|
|
|
|
|
#$(string-delete #\- (uuid->string dev)))
|
|
|
|
|
;; Other type of devices aren't implemented.
|
|
|
|
|
#~()))
|
|
|
|
|
(let ((devices (map crypto-device->cryptomount store-crypto-devices))
|
2021-11-15 20:53:39 +00:00
|
|
|
|
(modules #~(format port "insmod luks~%insmod luks2~%")))
|
2020-12-21 12:02:01 +00:00
|
|
|
|
(if (null? devices)
|
|
|
|
|
devices
|
|
|
|
|
(cons modules devices))))
|
|
|
|
|
|
2020-05-26 16:09:01 +00:00
|
|
|
|
(define (sugar)
|
|
|
|
|
(let* ((entry (first all-entries))
|
|
|
|
|
(device (menu-entry-device entry))
|
|
|
|
|
(mount-point (menu-entry-device-mount-point entry)))
|
|
|
|
|
(eye-candy config
|
|
|
|
|
device
|
|
|
|
|
mount-point
|
|
|
|
|
#:store-directory-prefix store-directory-prefix
|
|
|
|
|
#:port #~port)))
|
2018-11-15 12:32:07 +00:00
|
|
|
|
|
2019-11-02 17:18:45 +00:00
|
|
|
|
(define locale-config
|
2020-10-24 18:36:21 +00:00
|
|
|
|
(let* ((entry (first all-entries))
|
|
|
|
|
(device (menu-entry-device entry))
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(mount-point (menu-entry-device-mount-point entry)))
|
2020-10-24 18:36:21 +00:00
|
|
|
|
#~(let ((locale #$(and locale
|
|
|
|
|
(locale-definition-source
|
|
|
|
|
(locale-name->definition locale))))
|
|
|
|
|
(locales #$(and locale
|
|
|
|
|
(normalize-file (grub-locale-directory grub)
|
|
|
|
|
mount-point
|
|
|
|
|
store-directory-prefix))))
|
|
|
|
|
(when locale
|
|
|
|
|
(format port "\
|
2019-11-02 17:18:45 +00:00
|
|
|
|
# Localization configuration.
|
2020-10-24 18:36:21 +00:00
|
|
|
|
~asearch --file --set ~a/en@quot.mo
|
|
|
|
|
set locale_dir=~a
|
|
|
|
|
set lang=~a~%"
|
|
|
|
|
;; Skip the search if there is an image, as it has already
|
|
|
|
|
;; been performed by eye-candy and traversing the store is
|
|
|
|
|
;; an expensive operation.
|
|
|
|
|
#$(if (grub-theme-image (bootloader-theme config))
|
|
|
|
|
"# "
|
|
|
|
|
"")
|
|
|
|
|
locales
|
|
|
|
|
locales
|
|
|
|
|
locale)))))
|
2019-11-02 17:18:45 +00:00
|
|
|
|
|
2019-03-17 21:37:53 +00:00
|
|
|
|
(define keyboard-layout-config
|
2019-07-14 11:50:23 +00:00
|
|
|
|
(let* ((layout (bootloader-configuration-keyboard-layout config))
|
|
|
|
|
(keymap* (and layout
|
|
|
|
|
(keyboard-layout-file layout #:grub grub)))
|
2020-10-24 15:48:28 +00:00
|
|
|
|
(entry (first all-entries))
|
|
|
|
|
(device (menu-entry-device entry))
|
|
|
|
|
(mount-point (menu-entry-device-mount-point entry))
|
2019-07-14 11:50:23 +00:00
|
|
|
|
(keymap (and keymap*
|
2020-10-24 15:48:28 +00:00
|
|
|
|
(normalize-file keymap* mount-point
|
|
|
|
|
store-directory-prefix))))
|
2019-07-14 11:50:23 +00:00
|
|
|
|
#~(when #$keymap
|
|
|
|
|
(format port "\
|
2019-03-17 21:37:53 +00:00
|
|
|
|
insmod keylayouts
|
2019-07-14 11:50:23 +00:00
|
|
|
|
keymap ~a~%" #$keymap))))
|
2019-03-17 21:37:53 +00:00
|
|
|
|
|
2018-11-15 12:32:07 +00:00
|
|
|
|
(define builder
|
|
|
|
|
#~(call-with-output-file #$output
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(format port
|
2019-03-13 15:44:02 +00:00
|
|
|
|
"# This file was generated from your Guix configuration. Any changes
|
2016-09-08 12:56:14 +00:00
|
|
|
|
# will be lost upon reconfiguration.
|
|
|
|
|
")
|
2020-12-21 12:02:01 +00:00
|
|
|
|
#$@(crypto-devices)
|
2020-05-26 16:09:01 +00:00
|
|
|
|
#$(sugar)
|
2019-11-02 17:18:45 +00:00
|
|
|
|
#$locale-config
|
2019-03-17 21:37:53 +00:00
|
|
|
|
#$keyboard-layout-config
|
2018-11-15 12:32:07 +00:00
|
|
|
|
(format port "
|
2014-04-28 21:40:24 +00:00
|
|
|
|
set default=~a
|
2014-12-13 20:28:12 +00:00
|
|
|
|
set timeout=~a~%"
|
2018-11-15 12:32:07 +00:00
|
|
|
|
#$(bootloader-configuration-default-entry config)
|
|
|
|
|
#$(bootloader-configuration-timeout config))
|
|
|
|
|
#$@(map menu-entry->gexp all-entries)
|
2014-11-08 14:07:18 +00:00
|
|
|
|
|
2018-11-15 12:32:07 +00:00
|
|
|
|
#$@(if (pair? old-entries)
|
|
|
|
|
#~((format port "
|
2014-06-25 20:54:52 +00:00
|
|
|
|
submenu \"GNU system, old configurations...\" {~%")
|
2018-11-15 12:32:07 +00:00
|
|
|
|
#$@(map menu-entry->gexp old-entries)
|
|
|
|
|
(format port "}~%"))
|
2019-12-12 19:53:06 +00:00
|
|
|
|
#~())
|
|
|
|
|
(format port "
|
|
|
|
|
if [ \"${grub_platform}\" == efi ]; then
|
|
|
|
|
menuentry \"Firmware setup\" {
|
|
|
|
|
fwsetup
|
|
|
|
|
}
|
|
|
|
|
fi~%"))))
|
2013-09-11 20:36:50 +00:00
|
|
|
|
|
2020-01-03 11:16:52 +00:00
|
|
|
|
;; Since this file is rather unique, there's no point in trying to
|
|
|
|
|
;; substitute it.
|
|
|
|
|
(computed-file "grub.cfg" builder
|
|
|
|
|
#:options '(#:local-build? #t
|
|
|
|
|
#:substitutable? #f)))
|
2013-09-11 20:36:50 +00:00
|
|
|
|
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(define (grub-configuration-file config . args)
|
|
|
|
|
(let* ((bootloader (bootloader-configuration-bootloader config))
|
|
|
|
|
(grub (bootloader-package bootloader)))
|
|
|
|
|
(apply make-grub-configuration grub config args)))
|
|
|
|
|
|
|
|
|
|
(define (grub-efi-configuration-file . args)
|
|
|
|
|
(apply make-grub-configuration grub-efi args))
|
|
|
|
|
|
|
|
|
|
(define grub-cfg "/boot/grub/grub.cfg")
|
|
|
|
|
|
2017-05-15 20:24:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Install procedures.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define install-grub
|
|
|
|
|
#~(lambda (bootloader device mount-point)
|
|
|
|
|
(let ((grub (string-append bootloader "/sbin/grub-install"))
|
|
|
|
|
(install-dir (string-append mount-point "/boot")))
|
2020-05-23 17:09:38 +00:00
|
|
|
|
;; Install GRUB on DEVICE which is mounted at MOUNT-POINT. If DEVICE
|
|
|
|
|
;; is #f, then we populate the disk-image rooted at MOUNT-POINT.
|
|
|
|
|
(if device
|
|
|
|
|
(begin
|
|
|
|
|
;; Tell 'grub-install' that there might be a LUKS-encrypted
|
|
|
|
|
;; /boot or root partition.
|
|
|
|
|
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
|
|
|
|
|
|
|
|
|
|
;; Hide potentially confusing messages from the user, such as
|
|
|
|
|
;; "Installing for i386-pc platform."
|
|
|
|
|
(invoke/quiet grub "--no-floppy" "--target=i386-pc"
|
|
|
|
|
"--boot-directory" install-dir
|
|
|
|
|
device))
|
2020-12-28 11:24:16 +00:00
|
|
|
|
;; When creating a disk-image, only install a font and GRUB modules.
|
|
|
|
|
(let* ((fonts (string-append install-dir "/grub/fonts")))
|
|
|
|
|
(mkdir-p fonts)
|
|
|
|
|
(copy-file (string-append bootloader "/share/grub/unicode.pf2")
|
|
|
|
|
(string-append fonts "/unicode.pf2"))
|
|
|
|
|
(copy-recursively (string-append bootloader "/lib/")
|
|
|
|
|
install-dir))))))
|
2017-08-20 08:48:19 +00:00
|
|
|
|
|
2020-05-23 17:09:14 +00:00
|
|
|
|
(define install-grub-disk-image
|
|
|
|
|
#~(lambda (bootloader root-index image)
|
|
|
|
|
;; Install GRUB on the given IMAGE. The root partition index is
|
|
|
|
|
;; ROOT-INDEX.
|
|
|
|
|
(let ((grub-mkimage
|
|
|
|
|
(string-append bootloader "/bin/grub-mkimage"))
|
|
|
|
|
(modules '("biosdisk" "part_msdos" "fat" "ext2"))
|
|
|
|
|
(grub-bios-setup
|
|
|
|
|
(string-append bootloader "/sbin/grub-bios-setup"))
|
|
|
|
|
(root-device (format #f "hd0,msdos~a" root-index))
|
|
|
|
|
(boot-img (string-append bootloader "/lib/grub/i386-pc/boot.img"))
|
|
|
|
|
(device-map "device.map"))
|
|
|
|
|
|
|
|
|
|
;; Create a minimal, standalone GRUB image that will be written
|
|
|
|
|
;; directly in the MBR-GAP (space between the end of the MBR and the
|
|
|
|
|
;; first partition).
|
|
|
|
|
(apply invoke grub-mkimage
|
|
|
|
|
"-O" "i386-pc"
|
|
|
|
|
"-o" "core.img"
|
|
|
|
|
"-p" (format #f "(~a)/boot/grub" root-device)
|
|
|
|
|
modules)
|
|
|
|
|
|
|
|
|
|
;; Create a device mapping file.
|
|
|
|
|
(call-with-output-file device-map
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(format port "(hd0) ~a~%" image)))
|
|
|
|
|
|
|
|
|
|
;; Copy the default boot.img, that will be written on the MBR sector
|
|
|
|
|
;; by GRUB-BIOS-SETUP.
|
|
|
|
|
(copy-file boot-img "boot.img")
|
|
|
|
|
|
|
|
|
|
;; Install both the "boot.img" and the "core.img" files on the given
|
|
|
|
|
;; IMAGE. On boot, the MBR sector will execute the minimal GRUB
|
|
|
|
|
;; written in the MBR-GAP. GRUB configuration and missing modules will
|
|
|
|
|
;; be read from ROOT-DEVICE.
|
|
|
|
|
(invoke grub-bios-setup
|
|
|
|
|
"-m" device-map
|
|
|
|
|
"-r" root-device
|
|
|
|
|
"-d" "."
|
|
|
|
|
image))))
|
|
|
|
|
|
2017-08-20 08:48:19 +00:00
|
|
|
|
(define install-grub-efi
|
|
|
|
|
#~(lambda (bootloader efi-dir mount-point)
|
2020-11-11 19:48:54 +00:00
|
|
|
|
;; There is nothing useful to do when called in the context of a disk
|
|
|
|
|
;; image generation.
|
|
|
|
|
(when efi-dir
|
|
|
|
|
;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
|
|
|
|
|
;; system whose root is mounted at MOUNT-POINT.
|
|
|
|
|
(let ((grub-install (string-append bootloader "/sbin/grub-install"))
|
|
|
|
|
(install-dir (string-append mount-point "/boot"))
|
|
|
|
|
;; When installing Guix, it's common to mount EFI-DIR below
|
|
|
|
|
;; MOUNT-POINT rather than /boot/efi on the live image.
|
|
|
|
|
(target-esp (if (file-exists? (string-append mount-point efi-dir))
|
|
|
|
|
(string-append mount-point efi-dir)
|
|
|
|
|
efi-dir)))
|
|
|
|
|
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
|
|
|
|
|
;; root partition.
|
|
|
|
|
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
|
|
|
|
|
(invoke/quiet grub-install "--boot-directory" install-dir
|
|
|
|
|
"--bootloader-id=Guix"
|
|
|
|
|
"--efi-directory" target-esp)))))
|
2017-05-15 20:24:18 +00:00
|
|
|
|
|
2022-05-25 04:32:54 +00:00
|
|
|
|
(define install-grub-efi-removable
|
|
|
|
|
#~(lambda (bootloader efi-dir mount-point)
|
|
|
|
|
;; NOTE: mount-point is /mnt in guix system init /etc/config.scm /mnt/point
|
|
|
|
|
;; NOTE: efi-dir comes from target list of booloader configuration
|
|
|
|
|
;; There is nothing useful to do when called in the context of a disk
|
|
|
|
|
;; image generation.
|
|
|
|
|
(when efi-dir
|
|
|
|
|
;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
|
|
|
|
|
;; system whose root is mounted at MOUNT-POINT.
|
|
|
|
|
(let ((grub-install (string-append bootloader "/sbin/grub-install"))
|
|
|
|
|
(install-dir (string-append mount-point "/boot"))
|
|
|
|
|
;; When installing Guix, it's common to mount EFI-DIR below
|
|
|
|
|
;; MOUNT-POINT rather than /boot/efi on the live image.
|
|
|
|
|
(target-esp (if (file-exists? (string-append mount-point efi-dir))
|
|
|
|
|
(string-append mount-point efi-dir)
|
|
|
|
|
efi-dir)))
|
|
|
|
|
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
|
|
|
|
|
;; root partition.
|
|
|
|
|
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
|
|
|
|
|
(invoke/quiet grub-install "--boot-directory" install-dir
|
|
|
|
|
"--removable"
|
|
|
|
|
;; "--no-nvram"
|
|
|
|
|
"--bootloader-id=Guix"
|
|
|
|
|
"--efi-directory" target-esp)))))
|
|
|
|
|
|
2022-06-18 05:18:35 +00:00
|
|
|
|
(define install-grub-efi32
|
|
|
|
|
#~(lambda (bootloader efi-dir mount-point)
|
|
|
|
|
;; There is nothing useful to do when called in the context of a disk
|
|
|
|
|
;; image generation.
|
|
|
|
|
(when efi-dir
|
|
|
|
|
;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
|
|
|
|
|
;; system whose root is mounted at MOUNT-POINT.
|
|
|
|
|
(let ((grub-install (string-append bootloader "/sbin/grub-install"))
|
|
|
|
|
(install-dir (string-append mount-point "/boot"))
|
|
|
|
|
;; When installing Guix, it's common to mount EFI-DIR below
|
|
|
|
|
;; MOUNT-POINT rather than /boot/efi on the live image.
|
|
|
|
|
(target-esp (if (file-exists? (string-append mount-point efi-dir))
|
|
|
|
|
(string-append mount-point efi-dir)
|
|
|
|
|
efi-dir)))
|
|
|
|
|
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
|
|
|
|
|
;; root partition.
|
|
|
|
|
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
|
|
|
|
|
(invoke/quiet grub-install "--boot-directory" install-dir
|
|
|
|
|
"--bootloader-id=Guix"
|
|
|
|
|
(cond ((target-x86?) "--target=i386-efi")
|
|
|
|
|
((target-arm?) "--target=arm-efi"))
|
|
|
|
|
"--efi-directory" target-esp)))))
|
|
|
|
|
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(define* (make-grub-efi-netboot-installer grub-efi grub-cfg subdir)
|
|
|
|
|
"Make a bootloader-installer for a grub-efi-netboot bootloader, which expects
|
|
|
|
|
its files in SUBDIR and its configuration file in GRUB-CFG.
|
|
|
|
|
|
|
|
|
|
As a grub-efi-netboot package is already pre-installed by 'grub-mknetdir', the
|
|
|
|
|
installer basically copies all files from the bootloader-package (or profile)
|
|
|
|
|
into the bootloader-target directory.
|
|
|
|
|
|
|
|
|
|
Additionally for network booting over TFTP, two relative symlinks to the store
|
|
|
|
|
and to the GRUB-CFG file are necessary. Due to this a TFTP root directory must
|
|
|
|
|
not be located on a FAT file-system.
|
|
|
|
|
|
|
|
|
|
If the bootloader-target does not support symlinks, then it is assumed to be a
|
|
|
|
|
kind of EFI System Partition (ESP). In this case an intermediate configuration
|
|
|
|
|
file is created with the help of GRUB-EFI to load the GRUB-CFG.
|
|
|
|
|
|
|
|
|
|
The installer is usable for any efi-bootloader-chain, which prepares the
|
|
|
|
|
bootloader-profile in a way ready for copying.
|
|
|
|
|
|
|
|
|
|
The installer does not manipulate the system's 'UEFI Boot Manager'.
|
|
|
|
|
|
|
|
|
|
The returned installer accepts the BOOTLOADER, TARGET and MOUNT-POINT
|
|
|
|
|
arguments. Its job is to copy the BOOTLOADER, which must be a pre-installed
|
|
|
|
|
grub-efi-netboot package with a SUBDIR like efi/boot or efi/Guix, below the
|
|
|
|
|
directory TARGET for the system whose root is mounted at MOUNT-POINT.
|
2020-09-26 10:54:00 +00:00
|
|
|
|
|
|
|
|
|
MOUNT-POINT is the last argument in 'guix system init /etc/config.scm mnt/point'
|
|
|
|
|
or '/' for other 'guix system' commands.
|
|
|
|
|
|
2021-08-07 19:07:47 +00:00
|
|
|
|
Where TARGET comes from the targets argument given to the
|
|
|
|
|
bootloader-configuration in:
|
2020-09-26 10:54:00 +00:00
|
|
|
|
|
|
|
|
|
(operating-system
|
|
|
|
|
(bootloader (bootloader-configuration
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(targets '(\"/boot/efi\"))
|
2020-09-26 10:54:00 +00:00
|
|
|
|
…))
|
|
|
|
|
…)
|
|
|
|
|
|
|
|
|
|
TARGET is required to be an absolute directory name, usually mounted via NFS,
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
and finally needs to be provided by a TFTP server as
|
|
|
|
|
the TFTP root directory.
|
2020-09-26 10:54:00 +00:00
|
|
|
|
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
Usually the installer will be used to prepare network booting over TFTP. Then
|
2020-09-26 10:54:00 +00:00
|
|
|
|
GRUB will load tftp://server/SUBDIR/grub.cfg and this file will instruct it to
|
|
|
|
|
load more files from the store like tftp://server/gnu/store/…-linux…/Image.
|
|
|
|
|
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
To make this possible two symlinks are created. The first symlink points
|
2020-09-26 10:54:00 +00:00
|
|
|
|
relatively form MOUNT-POINT/TARGET/SUBDIR/grub.cfg to
|
|
|
|
|
MOUNT-POINT/boot/grub/grub.cfg, and the second symlink points relatively from
|
|
|
|
|
MOUNT-POINT/TARGET/%store-prefix to MOUNT-POINT/%store-prefix.
|
|
|
|
|
|
2021-04-09 17:56:31 +00:00
|
|
|
|
It is important to note that these symlinks need to be relative, as the absolute
|
2020-09-26 10:54:00 +00:00
|
|
|
|
paths on the TFTP server side are unknown.
|
|
|
|
|
|
|
|
|
|
It is also important to note that both symlinks will point outside the TFTP root
|
|
|
|
|
directory and that the TARGET/%store-prefix symlink makes the whole store
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
accessible via TFTP. Possibly the TFTP server must be configured to allow
|
|
|
|
|
accesses outside its TFTP root directory. This all may need to be considered
|
|
|
|
|
for security aspects. It is advised to disable any TFTP write access!
|
|
|
|
|
|
|
|
|
|
The installer can also be used to prepare booting from local storage, if the
|
|
|
|
|
underlying file-system, like FAT on an EFI System Partition (ESP), does not
|
|
|
|
|
support symlinks. In this case the MOUNT-POINT/TARGET/SUBDIR/grub.cfg will be
|
|
|
|
|
created with the help of GRUB-EFI to load the /boot/grub/grub.cfg file. A
|
|
|
|
|
symlink to the store is not needed in this case."
|
|
|
|
|
(with-imported-modules '((guix build union))
|
|
|
|
|
#~(lambda (bootloader target mount-point)
|
|
|
|
|
;; In context of a disk image creation TARGET will be #f and an
|
|
|
|
|
;; installer is expected to do necessary installations on MOUNT-POINT,
|
|
|
|
|
;; which will become the root file system. If TARGET is #f, this
|
|
|
|
|
;; installer has nothing to do, as it only cares about the EFI System
|
|
|
|
|
;; Partition (ESP).
|
|
|
|
|
(when target
|
|
|
|
|
(use-modules ((guix build union) #:select (symlink-relative))
|
|
|
|
|
(ice-9 popen)
|
|
|
|
|
(ice-9 rdelim))
|
|
|
|
|
(let* ((mount-point/target (string-append mount-point target "/"))
|
|
|
|
|
;; When installing Guix, it is common to mount TARGET below
|
|
|
|
|
;; MOUNT-POINT rather than the root directory.
|
|
|
|
|
(bootloader-target (if (file-exists? mount-point/target)
|
|
|
|
|
mount-point/target
|
|
|
|
|
target))
|
|
|
|
|
(store (string-append mount-point (%store-prefix)))
|
|
|
|
|
(store-link (string-append bootloader-target (%store-prefix)))
|
|
|
|
|
(grub-cfg (string-append mount-point #$grub-cfg))
|
|
|
|
|
(grub-cfg-link (string-append bootloader-target
|
|
|
|
|
#$subdir "/"
|
|
|
|
|
(basename grub-cfg))))
|
|
|
|
|
;; Copy the bootloader into the bootloader-target directory.
|
|
|
|
|
;; Should we beforehand recursively delete any existing file?
|
|
|
|
|
(copy-recursively bootloader bootloader-target
|
|
|
|
|
#:follow-symlinks? #t
|
|
|
|
|
#:log (%make-void-port "w"))
|
|
|
|
|
;; For TFTP we need to install additional relative symlinks.
|
|
|
|
|
;; If we install on an EFI System Partition (ESP) or some other FAT
|
|
|
|
|
;; file-system, then symlinks cannot be created and are not needed.
|
|
|
|
|
;; Therefore we ignore exceptions when trying.
|
|
|
|
|
;; Prepare the symlink to the grub.cfg.
|
|
|
|
|
(mkdir-p (dirname grub-cfg-link))
|
|
|
|
|
(false-if-exception (delete-file grub-cfg-link))
|
|
|
|
|
(if (unspecified?
|
|
|
|
|
(false-if-exception (symlink-relative grub-cfg grub-cfg-link)))
|
|
|
|
|
;; Symlinks are supported.
|
|
|
|
|
(begin
|
|
|
|
|
;; Prepare the symlink to the store.
|
|
|
|
|
(mkdir-p (dirname store-link))
|
|
|
|
|
(false-if-exception (delete-file store-link))
|
|
|
|
|
(symlink-relative store store-link))
|
|
|
|
|
;; Creating symlinks does not seem to be supported. Probably
|
|
|
|
|
;; an ESP is used. Add a script to search and load the actual
|
|
|
|
|
;; grub.cfg.
|
|
|
|
|
(let* ((probe #$(file-append grub-efi "/sbin/grub-probe"))
|
|
|
|
|
(port (open-pipe* OPEN_READ probe "--target=fs_uuid"
|
|
|
|
|
grub-cfg))
|
|
|
|
|
(search-root
|
|
|
|
|
(match (read-line port)
|
|
|
|
|
((? eof-object?)
|
|
|
|
|
;; There is no UUID available. As a fallback search
|
|
|
|
|
;; everywhere for the grub.cfg.
|
|
|
|
|
(string-append "search --file --set " #$grub-cfg))
|
|
|
|
|
(fs-uuid
|
|
|
|
|
;; The UUID to load the grub.cfg from is known.
|
|
|
|
|
(string-append "search --fs-uuid --set " fs-uuid))))
|
|
|
|
|
(load-grub-cfg (string-append "configfile " #$grub-cfg)))
|
|
|
|
|
(close-pipe port)
|
|
|
|
|
(with-output-to-file grub-cfg-link
|
|
|
|
|
(lambda ()
|
|
|
|
|
(display (string-join (list search-root
|
|
|
|
|
load-grub-cfg)
|
|
|
|
|
"\n")))))))))))
|
2020-09-26 10:54:00 +00:00
|
|
|
|
|
2017-05-15 20:24:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloader definitions.
|
|
|
|
|
;;;
|
2020-09-06 13:54:33 +00:00
|
|
|
|
;;; For all these grub-bootloader variables the path to /boot/grub/grub.cfg
|
|
|
|
|
;;; is fixed. Inheriting and overwriting the field 'configuration-file' will
|
|
|
|
|
;;; break 'guix system delete-generations', 'guix system switch-generation',
|
|
|
|
|
;;; and 'guix system roll-back'.
|
2017-05-15 20:24:18 +00:00
|
|
|
|
|
|
|
|
|
(define grub-bootloader
|
|
|
|
|
(bootloader
|
|
|
|
|
(name 'grub)
|
|
|
|
|
(package grub)
|
|
|
|
|
(installer install-grub)
|
2020-05-23 17:09:14 +00:00
|
|
|
|
(disk-image-installer install-grub-disk-image)
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(configuration-file grub-cfg)
|
2017-05-15 20:24:18 +00:00
|
|
|
|
(configuration-file-generator grub-configuration-file)))
|
|
|
|
|
|
2020-09-06 13:56:18 +00:00
|
|
|
|
(define grub-minimal-bootloader
|
2020-03-08 20:17:27 +00:00
|
|
|
|
(bootloader
|
2020-05-23 17:09:46 +00:00
|
|
|
|
(inherit grub-bootloader)
|
|
|
|
|
(package grub-minimal)))
|
2020-03-08 20:17:27 +00:00
|
|
|
|
|
2020-09-06 13:56:18 +00:00
|
|
|
|
(define grub-efi-bootloader
|
2017-05-15 20:24:18 +00:00
|
|
|
|
(bootloader
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(name 'grub-efi)
|
|
|
|
|
(package grub-efi)
|
2017-08-20 08:48:19 +00:00
|
|
|
|
(installer install-grub-efi)
|
2020-05-23 17:09:14 +00:00
|
|
|
|
(disk-image-installer #f)
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(configuration-file grub-cfg)
|
|
|
|
|
(configuration-file-generator grub-configuration-file)))
|
2017-05-15 20:24:18 +00:00
|
|
|
|
|
2022-05-25 04:32:54 +00:00
|
|
|
|
(define grub-efi-removable-bootloader
|
|
|
|
|
(bootloader
|
|
|
|
|
(inherit grub-efi-bootloader)
|
|
|
|
|
(name 'grub-efi-removable-bootloader)
|
|
|
|
|
(installer install-grub-efi-removable)))
|
|
|
|
|
|
2022-06-18 05:18:35 +00:00
|
|
|
|
(define grub-efi32-bootloader
|
|
|
|
|
(bootloader
|
|
|
|
|
(inherit grub-efi-bootloader)
|
|
|
|
|
(installer install-grub-efi32)
|
|
|
|
|
(name 'grub-efi32)
|
|
|
|
|
(package grub-efi32)))
|
|
|
|
|
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(define (make-grub-efi-netboot-bootloader name subdir)
|
2020-09-26 10:54:00 +00:00
|
|
|
|
(bootloader
|
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-12-01 00:59:09 +00:00
|
|
|
|
(name name)
|
|
|
|
|
(package (make-grub-efi-netboot (symbol->string name) subdir))
|
|
|
|
|
(installer (make-grub-efi-netboot-installer grub-efi grub-cfg subdir))
|
|
|
|
|
(disk-image-installer #f)
|
|
|
|
|
(configuration-file grub-cfg)
|
|
|
|
|
(configuration-file-generator grub-efi-configuration-file)))
|
|
|
|
|
|
|
|
|
|
(define grub-efi-netboot-bootloader
|
|
|
|
|
(make-grub-efi-netboot-bootloader 'grub-efi-netboot-bootloader
|
|
|
|
|
"efi/Guix"))
|
|
|
|
|
|
|
|
|
|
(define grub-efi-netboot-removable-bootloader
|
|
|
|
|
(make-grub-efi-netboot-bootloader 'grub-efi-netboot-removable-bootloader
|
|
|
|
|
"efi/boot"))
|
2020-09-26 10:54:00 +00:00
|
|
|
|
|
2020-09-06 13:56:18 +00:00
|
|
|
|
(define grub-mkrescue-bootloader
|
2017-07-20 23:06:48 +00:00
|
|
|
|
(bootloader
|
|
|
|
|
(inherit grub-efi-bootloader)
|
|
|
|
|
(package grub-hybrid)))
|
|
|
|
|
|
2017-05-15 20:24:18 +00:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Compatibility macros.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define-syntax grub-configuration
|
|
|
|
|
(syntax-rules (grub)
|
|
|
|
|
((_ (grub package) fields ...)
|
|
|
|
|
(if (eq? package grub)
|
|
|
|
|
(bootloader-configuration
|
|
|
|
|
(bootloader grub-bootloader)
|
|
|
|
|
fields ...)
|
|
|
|
|
(bootloader-configuration
|
|
|
|
|
(bootloader grub-efi-bootloader)
|
|
|
|
|
fields ...)))
|
|
|
|
|
((_ fields ...)
|
|
|
|
|
(bootloader-configuration
|
|
|
|
|
(bootloader grub-bootloader)
|
|
|
|
|
fields ...))))
|
|
|
|
|
|
2013-09-11 20:36:50 +00:00
|
|
|
|
;;; grub.scm ends here
|