2013-09-11 16:36:50 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2019-03-13 11:44:02 -04:00
|
|
|
|
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
2016-10-28 06:07:18 -04:00
|
|
|
|
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
|
2017-05-11 03:12:44 -04:00
|
|
|
|
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
|
2017-05-15 16:24:18 -04:00
|
|
|
|
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
|
2013-09-11 16:36:50 -04: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 16:24:18 -04:00
|
|
|
|
(define-module (gnu bootloader grub)
|
2013-09-11 16:36:50 -04:00
|
|
|
|
#:use-module (guix records)
|
2018-11-15 07:32:07 -05:00
|
|
|
|
#:use-module ((guix utils) #:select (%current-system))
|
2014-04-28 17:40:24 -04:00
|
|
|
|
#:use-module (guix gexp)
|
2014-11-12 08:28:36 -05:00
|
|
|
|
#:use-module (gnu artwork)
|
2017-05-15 16:24:18 -04:00
|
|
|
|
#:use-module (gnu bootloader)
|
2017-09-06 03:28:28 -04:00
|
|
|
|
#:use-module (gnu system uuid)
|
2018-05-18 07:43:07 -04:00
|
|
|
|
#:use-module (gnu system file-systems)
|
2019-03-17 17:37:53 -04:00
|
|
|
|
#:use-module (gnu system keyboard)
|
2017-02-09 13:46:47 -05:00
|
|
|
|
#:autoload (gnu packages bootloaders) (grub)
|
2016-10-24 18:58:26 -04:00
|
|
|
|
#:autoload (gnu packages gtk) (guile-cairo guile-rsvg)
|
2019-03-17 17:37:53 -04:00
|
|
|
|
#:autoload (gnu packages xorg) (xkeyboard-config)
|
2013-09-11 16:36:50 -04:00
|
|
|
|
#:use-module (ice-9 match)
|
2015-08-09 18:45:49 -04:00
|
|
|
|
#:use-module (ice-9 regex)
|
2013-09-11 16:36:50 -04:00
|
|
|
|
#:use-module (srfi srfi-1)
|
2014-11-08 09:07:18 -05:00
|
|
|
|
#:export (grub-image
|
|
|
|
|
grub-image?
|
|
|
|
|
grub-image-aspect-ratio
|
|
|
|
|
grub-image-file
|
|
|
|
|
|
|
|
|
|
grub-theme
|
|
|
|
|
grub-theme?
|
|
|
|
|
grub-theme-images
|
|
|
|
|
grub-theme-color-normal
|
|
|
|
|
grub-theme-color-highlight
|
|
|
|
|
|
|
|
|
|
%background-image
|
|
|
|
|
%default-theme
|
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
grub-bootloader
|
|
|
|
|
grub-efi-bootloader
|
2017-07-20 19:06:48 -04:00
|
|
|
|
grub-mkrescue-bootloader
|
2014-05-18 15:58:01 -04:00
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
grub-configuration))
|
2013-09-11 16:36:50 -04:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;;
|
|
|
|
|
;;; Configuration of GNU GRUB.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2016-10-28 06:07:18 -04:00
|
|
|
|
(define (strip-mount-point mount-point file)
|
|
|
|
|
"Strip MOUNT-POINT from FILE, which is a gexp or other lowerable object
|
|
|
|
|
denoting a file name."
|
2017-05-29 08:24:20 -04:00
|
|
|
|
(match mount-point
|
|
|
|
|
((? string? mount-point)
|
|
|
|
|
(if (string=? mount-point "/")
|
|
|
|
|
file
|
|
|
|
|
#~(let ((file #$file))
|
|
|
|
|
(if (string-prefix? #$mount-point file)
|
|
|
|
|
(substring #$file #$(string-length mount-point))
|
|
|
|
|
file))))
|
|
|
|
|
(#f file)))
|
2016-09-14 10:13:24 -04:00
|
|
|
|
|
2014-11-08 09:07:18 -05:00
|
|
|
|
(define-record-type* <grub-image>
|
|
|
|
|
grub-image make-grub-image
|
|
|
|
|
grub-image?
|
|
|
|
|
(aspect-ratio grub-image-aspect-ratio ;rational number
|
|
|
|
|
(default 4/3))
|
|
|
|
|
(file grub-image-file)) ;file-valued gexp (SVG)
|
|
|
|
|
|
|
|
|
|
(define-record-type* <grub-theme>
|
|
|
|
|
grub-theme make-grub-theme
|
|
|
|
|
grub-theme?
|
|
|
|
|
(images grub-theme-images
|
|
|
|
|
(default '())) ;list of <grub-image>
|
|
|
|
|
(color-normal grub-theme-color-normal
|
|
|
|
|
(default '((fg . cyan) (bg . blue))))
|
|
|
|
|
(color-highlight grub-theme-color-highlight
|
|
|
|
|
(default '((fg . white) (bg . blue)))))
|
|
|
|
|
|
|
|
|
|
(define %background-image
|
|
|
|
|
(grub-image
|
|
|
|
|
(aspect-ratio 4/3)
|
2017-02-01 06:30:56 -05:00
|
|
|
|
(file (file-append %artwork-repository
|
|
|
|
|
"/grub/GuixSD-fully-black-4-3.svg"))))
|
2014-11-08 09:07:18 -05:00
|
|
|
|
|
|
|
|
|
(define %default-theme
|
|
|
|
|
;; Default theme contributed by Felipe López.
|
|
|
|
|
(grub-theme
|
|
|
|
|
(images (list %background-image))
|
2015-02-12 17:42:29 -05:00
|
|
|
|
(color-highlight '((fg . yellow) (bg . black)))
|
2014-11-08 09:07:18 -05:00
|
|
|
|
(color-normal '((fg . light-gray) (bg . black))))) ;XXX: #x303030
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Background image & themes.
|
|
|
|
|
;;;
|
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
(define (bootloader-theme config)
|
|
|
|
|
"Return user defined theme in CONFIG if defined or %default-theme
|
|
|
|
|
otherwise."
|
|
|
|
|
(or (bootloader-configuration-theme config) %default-theme))
|
|
|
|
|
|
2016-10-24 18:58:26 -04:00
|
|
|
|
(define* (svg->png svg #:key width height)
|
|
|
|
|
"Build a PNG of HEIGHT x WIDTH from SVG."
|
2018-11-15 07:32:07 -05:00
|
|
|
|
(computed-file "grub-image.png"
|
|
|
|
|
(with-imported-modules '((gnu build svg))
|
|
|
|
|
(with-extensions (list guile-rsvg guile-cairo)
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (gnu build svg))
|
|
|
|
|
(svg->png #+svg #$output
|
|
|
|
|
#:width #$width
|
|
|
|
|
#:height #$height))))))
|
2014-11-08 09:07:18 -05:00
|
|
|
|
|
2015-11-01 16:29:53 -05:00
|
|
|
|
(define* (grub-background-image config #:key (width 1024) (height 768))
|
2014-11-08 09:07:18 -05:00
|
|
|
|
"Return the GRUB background image defined in CONFIG with a ratio of
|
|
|
|
|
WIDTH/HEIGHT, or #f if none was found."
|
|
|
|
|
(let* ((ratio (/ width height))
|
|
|
|
|
(image (find (lambda (image)
|
|
|
|
|
(= (grub-image-aspect-ratio image) ratio))
|
2017-05-15 16:24:18 -04:00
|
|
|
|
(grub-theme-images
|
|
|
|
|
(bootloader-theme config)))))
|
2018-11-15 07:32:07 -05:00
|
|
|
|
(and image
|
|
|
|
|
(svg->png (grub-image-file image)
|
|
|
|
|
#:width width #:height height))))
|
2014-11-08 09:07:18 -05:00
|
|
|
|
|
2016-10-28 06:07:18 -04:00
|
|
|
|
(define* (eye-candy config store-device store-mount-point
|
|
|
|
|
#:key system port)
|
2018-11-15 07:32:07 -05:00
|
|
|
|
"Return a gexp that writes to PORT (a port-valued gexp) the
|
2014-11-08 09:07:18 -05:00
|
|
|
|
'grub.cfg' part concerned with graphics mode, background images, colors, and
|
2016-10-28 06:07:18 -04:00
|
|
|
|
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 fonts must be searched for. SYSTEM must be the target
|
|
|
|
|
system string---e.g., \"x86_64-linux\"."
|
2015-08-09 18:45:49 -04:00
|
|
|
|
(define setup-gfxterm-body
|
2017-01-03 12:14:50 -05:00
|
|
|
|
;; Intel and EFI systems need to be switched into graphics mode, whereas
|
|
|
|
|
;; most other modern architectures have no other mode and therefore don't
|
|
|
|
|
;; need to be switched.
|
2015-08-09 18:45:49 -04:00
|
|
|
|
(if (string-match "^(x86_64|i[3-6]86)-" system)
|
|
|
|
|
"
|
2015-10-29 04:58:17 -04:00
|
|
|
|
# Leave 'gfxmode' to 'auto'.
|
2015-08-09 18:45:49 -04:00
|
|
|
|
insmod video_bochs
|
|
|
|
|
insmod video_cirrus
|
|
|
|
|
insmod gfxterm
|
2017-01-03 12:14:50 -05:00
|
|
|
|
|
|
|
|
|
if [ \"${grub_platform}\" == efi ]; then
|
|
|
|
|
# This is for (U)EFI systems (these modules are unavailable in the
|
|
|
|
|
# non-EFI GRUB.) If we don't load them, GRUB boots in \"blind mode\",
|
|
|
|
|
# which isn't convenient.
|
|
|
|
|
insmod efi_gop
|
|
|
|
|
insmod efi_uga
|
2017-03-24 19:22:14 -04:00
|
|
|
|
else
|
|
|
|
|
# These are specific to non-EFI Intel machines.
|
|
|
|
|
insmod vbe
|
|
|
|
|
insmod vga
|
2017-01-03 12:14:50 -05:00
|
|
|
|
fi
|
2015-08-09 18:45:49 -04:00
|
|
|
|
"
|
|
|
|
|
""))
|
|
|
|
|
|
2017-05-11 03:12:44 -04:00
|
|
|
|
(define (setup-gfxterm config font-file)
|
2017-05-15 16:24:18 -04:00
|
|
|
|
(if (memq 'gfxterm (bootloader-configuration-terminal-outputs config))
|
|
|
|
|
#~(format #f "if loadfont ~a; then
|
2017-05-11 03:12:44 -04:00
|
|
|
|
setup_gfxterm
|
|
|
|
|
fi~%" #$font-file)
|
2017-05-15 16:24:18 -04:00
|
|
|
|
""))
|
2017-05-11 03:12:44 -04:00
|
|
|
|
|
2014-11-08 09:07:18 -05:00
|
|
|
|
(define (theme-colors type)
|
2017-05-15 16:24:18 -04:00
|
|
|
|
(let* ((theme (bootloader-theme config))
|
2014-11-08 09:07:18 -05:00
|
|
|
|
(colors (type theme)))
|
|
|
|
|
(string-append (symbol->string (assoc-ref colors 'fg)) "/"
|
|
|
|
|
(symbol->string (assoc-ref colors 'bg)))))
|
|
|
|
|
|
2016-01-21 16:45:54 -05:00
|
|
|
|
(define font-file
|
2016-10-28 06:07:18 -04:00
|
|
|
|
(strip-mount-point store-mount-point
|
2016-09-14 10:13:24 -04:00
|
|
|
|
(file-append grub "/share/grub/unicode.pf2")))
|
2016-01-21 16:45:54 -05:00
|
|
|
|
|
2018-11-15 07:32:07 -05:00
|
|
|
|
(define image
|
|
|
|
|
(grub-background-image config))
|
|
|
|
|
|
|
|
|
|
(and image
|
|
|
|
|
#~(format #$port "
|
2015-08-09 18:45:49 -04:00
|
|
|
|
function setup_gfxterm {~a}
|
2014-11-08 09:07:18 -05:00
|
|
|
|
|
2014-12-13 16:15:01 -05:00
|
|
|
|
# Set 'root' to the partition that contains /gnu/store.
|
2016-01-21 16:45:54 -05:00
|
|
|
|
~a
|
2014-12-13 16:15:01 -05:00
|
|
|
|
|
2017-05-11 03:12:44 -04:00
|
|
|
|
~a
|
|
|
|
|
~a
|
2014-11-08 09:07:18 -05: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~%"
|
2018-11-15 07:32:07 -05:00
|
|
|
|
#$setup-gfxterm-body
|
|
|
|
|
#$(grub-root-search store-device font-file)
|
|
|
|
|
#$(setup-gfxterm config font-file)
|
|
|
|
|
#$(grub-setup-io config)
|
2016-01-21 16:45:54 -05:00
|
|
|
|
|
2018-11-15 07:32:07 -05:00
|
|
|
|
#$(strip-mount-point store-mount-point image)
|
|
|
|
|
#$(theme-colors grub-theme-color-normal)
|
|
|
|
|
#$(theme-colors grub-theme-color-highlight))))
|
2014-11-08 09:07:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Configuration file.
|
|
|
|
|
;;;
|
|
|
|
|
|
2019-03-17 17:37:53 -04: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).
|
|
|
|
|
(invoke #$(file-append grub "/bin/grub-mklayout")
|
|
|
|
|
"-i" #+(keyboard-layout->console-keymap layout)
|
|
|
|
|
"-o" #$output))))
|
|
|
|
|
|
|
|
|
|
(computed-file (string-append "grub-keymap." (keyboard-layout-name layout))
|
|
|
|
|
builder))
|
|
|
|
|
|
2017-05-11 03:12:44 -04: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 16:24:18 -04: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 03:12:44 -04: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
|
|
|
|
|
"terminal_output "
|
|
|
|
|
(symbols->string
|
|
|
|
|
(map
|
|
|
|
|
(lambda (output)
|
|
|
|
|
(if (memq output valid-outputs) output #f)) outputs)) "\n"
|
|
|
|
|
(if (null? inputs)
|
|
|
|
|
""
|
|
|
|
|
(string-append
|
|
|
|
|
"terminal_input "
|
|
|
|
|
(symbols->string
|
|
|
|
|
(map
|
|
|
|
|
(lambda (input)
|
|
|
|
|
(if (memq input valid-inputs) input #f)) inputs)) "\n"))
|
|
|
|
|
;; UNIT and SPEED are arguments to the same GRUB command
|
|
|
|
|
;; ("serial"), so we process them together.
|
|
|
|
|
(if (or unit speed)
|
|
|
|
|
(string-append
|
|
|
|
|
"serial"
|
|
|
|
|
(if unit
|
|
|
|
|
;; COM ports 1 through 4
|
|
|
|
|
(if (and (exact-integer? unit) (<= unit 3) (>= unit 0))
|
|
|
|
|
(string-append " --unit=" (number->string unit))
|
|
|
|
|
#f)
|
|
|
|
|
"")
|
|
|
|
|
(if speed
|
|
|
|
|
(if (exact-integer? speed)
|
|
|
|
|
(string-append " --speed=" (number->string speed))
|
|
|
|
|
#f)
|
|
|
|
|
""))
|
|
|
|
|
""))))
|
|
|
|
|
(format #f "~a" io)))
|
|
|
|
|
|
2016-10-28 06:07:18 -04:00
|
|
|
|
(define (grub-root-search device file)
|
|
|
|
|
"Return the GRUB 'search' command to look for DEVICE, which contains FILE,
|
2016-01-21 16:45:54 -05:00
|
|
|
|
a gexp. The result is a gexp that can be inserted in the grub.cfg-generation
|
|
|
|
|
code."
|
2016-09-25 11:12:50 -04: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 06:07:18 -04:00
|
|
|
|
(match device
|
|
|
|
|
;; Preferably refer to DEVICE by its UUID or label. This is more
|
2017-03-06 16:51:22 -05:00
|
|
|
|
;; efficient and less ambiguous, see <http://bugs.gnu.org/22281>.
|
2017-09-06 03:28:28 -04:00
|
|
|
|
((? uuid? uuid)
|
2016-09-25 11:12:50 -04:00
|
|
|
|
(format #f "search --fs-uuid --set ~a"
|
2016-10-28 06:07:18 -04:00
|
|
|
|
(uuid->string device)))
|
2018-05-18 07:43:07 -04:00
|
|
|
|
((? file-system-label? label)
|
|
|
|
|
(format #f "search --label --set ~a"
|
|
|
|
|
(file-system-label->string label)))
|
|
|
|
|
((or #f (? string?))
|
2016-09-25 11:12:50 -04:00
|
|
|
|
#~(format #f "search --file --set ~a" #$file)))))
|
2016-01-21 16:45:54 -05:00
|
|
|
|
|
2016-10-28 06:07:18 -04:00
|
|
|
|
(define* (grub-configuration-file config entries
|
2014-06-25 16:54:52 -04:00
|
|
|
|
#:key
|
|
|
|
|
(system (%current-system))
|
|
|
|
|
(old-entries '()))
|
2014-05-18 15:58:01 -04:00
|
|
|
|
"Return the GRUB configuration file corresponding to CONFIG, a
|
2017-05-15 16:24:18 -04:00
|
|
|
|
<bootloader-configuration> object, and where the store is available at
|
|
|
|
|
STORE-FS, a <file-system> object. OLD-ENTRIES is taken to be a list of menu
|
|
|
|
|
entries corresponding to old generations of the system."
|
2014-05-18 15:58:01 -04:00
|
|
|
|
(define all-entries
|
2017-06-29 06:42:59 -04:00
|
|
|
|
(append entries (bootloader-configuration-menu-entries config)))
|
|
|
|
|
(define (menu-entry->gexp entry)
|
|
|
|
|
(let ((device (menu-entry-device entry))
|
|
|
|
|
(device-mount-point (menu-entry-device-mount-point entry))
|
|
|
|
|
(label (menu-entry-label entry))
|
|
|
|
|
(kernel (menu-entry-linux entry))
|
|
|
|
|
(arguments (menu-entry-linux-arguments entry))
|
|
|
|
|
(initrd (menu-entry-initrd entry)))
|
2016-10-28 06:07:18 -04:00
|
|
|
|
;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point.
|
2017-05-29 08:24:20 -04:00
|
|
|
|
;; Use the right file names for KERNEL and INITRD in case
|
2016-10-28 06:07:18 -04:00
|
|
|
|
;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a
|
|
|
|
|
;; separate partition.
|
2017-05-29 08:24:20 -04:00
|
|
|
|
(let ((kernel (strip-mount-point device-mount-point kernel))
|
|
|
|
|
(initrd (strip-mount-point device-mount-point initrd)))
|
2016-09-14 10:13:24 -04:00
|
|
|
|
#~(format port "menuentry ~s {
|
2016-01-21 16:45:54 -05:00
|
|
|
|
~a
|
2016-09-09 17:27:00 -04: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 15:30:30 -04:00
|
|
|
|
initrd ~a
|
2013-09-11 16:36:50 -04:00
|
|
|
|
}~%"
|
2016-09-14 10:13:24 -04:00
|
|
|
|
#$label
|
2017-05-29 08:24:20 -04:00
|
|
|
|
#$(grub-root-search device kernel)
|
|
|
|
|
#$kernel (string-join (list #$@arguments))
|
|
|
|
|
#$initrd))))
|
2018-11-15 07:32:07 -05:00
|
|
|
|
(define sugar
|
|
|
|
|
(eye-candy config
|
|
|
|
|
(menu-entry-device (first all-entries))
|
|
|
|
|
(menu-entry-device-mount-point (first all-entries))
|
|
|
|
|
#:system system
|
|
|
|
|
#:port #~port))
|
|
|
|
|
|
2019-03-17 17:37:53 -04:00
|
|
|
|
(define keyboard-layout-config
|
|
|
|
|
(let ((layout (bootloader-configuration-keyboard-layout config))
|
|
|
|
|
(grub (bootloader-package
|
|
|
|
|
(bootloader-configuration-bootloader config))))
|
|
|
|
|
#~(let ((keymap #$(and layout
|
|
|
|
|
(keyboard-layout-file layout #:grub grub))))
|
|
|
|
|
(when keymap
|
|
|
|
|
(format port "\
|
|
|
|
|
insmod keylayouts
|
|
|
|
|
keymap ~a~%" keymap)))))
|
|
|
|
|
|
2018-11-15 07:32:07 -05:00
|
|
|
|
(define builder
|
|
|
|
|
#~(call-with-output-file #$output
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(format port
|
2019-03-13 11:44:02 -04:00
|
|
|
|
"# This file was generated from your Guix configuration. Any changes
|
2016-09-08 08:56:14 -04:00
|
|
|
|
# will be lost upon reconfiguration.
|
|
|
|
|
")
|
2018-11-15 07:32:07 -05:00
|
|
|
|
#$sugar
|
2019-03-17 17:37:53 -04:00
|
|
|
|
#$keyboard-layout-config
|
2018-11-15 07:32:07 -05:00
|
|
|
|
(format port "
|
2014-04-28 17:40:24 -04:00
|
|
|
|
set default=~a
|
2014-12-13 15:28:12 -05:00
|
|
|
|
set timeout=~a~%"
|
2018-11-15 07:32:07 -05:00
|
|
|
|
#$(bootloader-configuration-default-entry config)
|
|
|
|
|
#$(bootloader-configuration-timeout config))
|
|
|
|
|
#$@(map menu-entry->gexp all-entries)
|
2014-11-08 09:07:18 -05:00
|
|
|
|
|
2018-11-15 07:32:07 -05:00
|
|
|
|
#$@(if (pair? old-entries)
|
|
|
|
|
#~((format port "
|
2014-06-25 16:54:52 -04:00
|
|
|
|
submenu \"GNU system, old configurations...\" {~%")
|
2018-11-15 07:32:07 -05:00
|
|
|
|
#$@(map menu-entry->gexp old-entries)
|
|
|
|
|
(format port "}~%"))
|
|
|
|
|
#~()))))
|
2013-09-11 16:36:50 -04:00
|
|
|
|
|
2018-11-15 07:32:07 -05:00
|
|
|
|
(computed-file "grub.cfg" builder))
|
2013-09-11 16:36:50 -04:00
|
|
|
|
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Install procedures.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define install-grub
|
|
|
|
|
#~(lambda (bootloader device mount-point)
|
|
|
|
|
;; Install GRUB on DEVICE which is mounted at MOUNT-POINT.
|
|
|
|
|
(let ((grub (string-append bootloader "/sbin/grub-install"))
|
|
|
|
|
(install-dir (string-append mount-point "/boot")))
|
|
|
|
|
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
|
|
|
|
|
;; root partition.
|
|
|
|
|
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
|
|
|
|
|
|
2019-03-16 12:09:19 -04:00
|
|
|
|
;; 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))))
|
2017-08-20 04:48:19 -04:00
|
|
|
|
|
|
|
|
|
(define install-grub-efi
|
|
|
|
|
#~(lambda (bootloader efi-dir mount-point)
|
|
|
|
|
;; 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"))
|
2018-06-23 17:38:18 -04:00
|
|
|
|
(install-dir (string-append mount-point "/boot"))
|
2019-03-13 11:44:02 -04:00
|
|
|
|
;; When installing Guix, it's common to mount EFI-DIR below
|
2018-06-23 17:38:18 -04:00
|
|
|
|
;; 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)))
|
2017-08-20 04:48:19 -04:00
|
|
|
|
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
|
|
|
|
|
;; root partition.
|
|
|
|
|
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
|
2019-03-16 12:09:19 -04:00
|
|
|
|
(invoke/quiet grub-install "--boot-directory" install-dir
|
|
|
|
|
"--bootloader-id=Guix"
|
|
|
|
|
"--efi-directory" target-esp))))
|
2017-05-15 16:24:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Bootloader definitions.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define grub-bootloader
|
|
|
|
|
(bootloader
|
|
|
|
|
(name 'grub)
|
|
|
|
|
(package grub)
|
|
|
|
|
(installer install-grub)
|
|
|
|
|
(configuration-file "/boot/grub/grub.cfg")
|
|
|
|
|
(configuration-file-generator grub-configuration-file)))
|
|
|
|
|
|
|
|
|
|
(define* grub-efi-bootloader
|
|
|
|
|
(bootloader
|
|
|
|
|
(inherit grub-bootloader)
|
2017-08-20 04:48:19 -04:00
|
|
|
|
(installer install-grub-efi)
|
2017-05-15 16:24:18 -04:00
|
|
|
|
(name 'grub-efi)
|
|
|
|
|
(package grub-efi)))
|
|
|
|
|
|
2017-07-20 19:06:48 -04:00
|
|
|
|
(define* grub-mkrescue-bootloader
|
|
|
|
|
(bootloader
|
|
|
|
|
(inherit grub-efi-bootloader)
|
|
|
|
|
(package grub-hybrid)))
|
|
|
|
|
|
2017-05-15 16:24:18 -04: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 16:36:50 -04:00
|
|
|
|
;;; grub.scm ends here
|