From: Leo Famulari <leo@famulari.name>
To: myglc2 <myglc2@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: Non-graphical GRUB configuration
Date: Wed, 5 Apr 2017 07:59:19 -0400 [thread overview]
Message-ID: <20170405115919.GA28944@jasmine> (raw)
In-Reply-To: <20170402210620.GA26945@jasmine>
[-- Attachment #1.1: Type: text/plain, Size: 1240 bytes --]
On Sun, Apr 02, 2017 at 05:06:20PM -0400, Leo Famulari wrote:
> Based on the GRUB manual [0], how about this plan?
>
> We'd add these fields to (grub-configuration):
>
> terminal-outputs: One or more symbols: console, serial, gfxterm,
> ofconsole, vga_text. Default gfxterm.
>
> terminal-inputs: One or more symbols: console, serial, ofconsole,
> at_keyboard,usb_keyboard. Default unset.
>
> If 'terminal-inputs' or 'serial-*' are unset, we do what we do now:
> nothing. If 'terminal-outputs' is unset, we also do the same thing we
> now, which is set it to gfxterm.
>
> If any of them are set, we'd insert the corresponding text into the
> generated grub.cfg.
>
> If terminal-outputs does not include the symbol 'gfxterm', we'd disable
> the "setup_gfxterm" function.
Here's a WIP patch that I'd like some advice about. It does insert the
relevant text into grub.cfg, although I recommend testing it in a
virtual machine for now.
Questions:
1) In general, is this approach okay?
2) I think that (grub-setup-io) should be used in
(grub-configuration-file) instead of (eye-candy). But, when I try
calling it there, in the builder, it has no effect on grub.cfg. Any
suggestions for debugging this?
[-- Attachment #1.2: 0001-system-grub-Expose-GRUB-settings-for-interactive-int.patch --]
[-- Type: text/plain, Size: 6733 bytes --]
From c1d081d111fb4778b6a0625abbdd8cc540ae630f Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Sun, 2 Apr 2017 22:18:00 -0400
Subject: [PATCH] system: grub: Expose GRUB settings for interactive
interfaces.
WIP: Does not validate input and setup-io is used in the wrong place
* gnu/system/grub.scm (<grub-configuration>): Add new fields
terminal-outputs, terminal-inputs, serial-unit, and serial-speed.
(grub-setup-io, setup-gfxterm): New procedures.
* doc/guix.texi (GRUB Configuration): Document the new fields.
---
doc/guix.texi | 17 ++++++++++++
gnu/system/grub.scm | 75 +++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 75 insertions(+), 17 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index aa779e38e..8107872bc 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14920,6 +14920,23 @@ The @code{grub-theme} object describing the theme to use.
@item @code{grub} (default: @code{grub})
The GRUB package to use.
+
+@item @code{terminal-outputs} (default: @code{'gfxterm})
+The output terminals used for the GRUB boot menu, as a list of symbols.
+
+@item @code{terminal-inputs} (default: @code{'()})
+The input terminals used for the GRUB boot menu, as a list of symbols.
+The default is the native platform terminal as determined by GRUB at
+run-time.
+
+@item @code{serial-unit} (default: @code{#f})
+The serial unit used by GRUB, as an integer from 0 to 3. The default
+value is deferred to GRUB; currently GRUB choosese 0, which corresponds
+to COM1.
+
+@item @code{serial-speed} (default: @code{#f})
+The speed of the serial interface, as an integer. The default value is
+deferred to GRUB; currently GRUB chooses 9600bps.
@end table
@end deftp
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index 4f9bde6a6..8a516f05f 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -107,17 +107,25 @@ denoting a file name."
(define-record-type* <grub-configuration>
grub-configuration make-grub-configuration
grub-configuration?
- (grub grub-configuration-grub ; package
- (default (@ (gnu packages bootloaders) grub)))
- (device grub-configuration-device) ; string
- (menu-entries grub-configuration-menu-entries ; list
- (default '()))
- (default-entry grub-configuration-default-entry ; integer
- (default 0))
- (timeout grub-configuration-timeout ; integer
- (default 5))
- (theme grub-configuration-theme ; <grub-theme>
- (default %default-theme)))
+ (grub grub-configuration-grub ; package
+ (default (@ (gnu packages bootloaders) grub)))
+ (device grub-configuration-device) ; string
+ (menu-entries grub-configuration-menu-entries ; list
+ (default '()))
+ (default-entry grub-configuration-default-entry ; integer
+ (default 0))
+ (timeout grub-configuration-timeout ; integer
+ (default 5))
+ (theme grub-configuration-theme ; <grub-theme>
+ (default %default-theme))
+ (terminal-outputs grub-configuration-terminal-outputs ; list of symbols
+ (default '(gfxterm)))
+ (terminal-inputs grub-configuration-terminal-inputs ; list of symbols
+ (default '()))
+ (serial-unit grub-configuration-serial-unit ; integer | #f
+ (default #f))
+ (serial-speed grub-configuration-serial-speed ; integer | #f
+ (default #f)))
(define-record-type* <menu-entry>
menu-entry make-menu-entry
@@ -198,11 +206,16 @@ system string---e.g., \"x86_64-linux\"."
insmod vbe
insmod vga
fi
-
- terminal_output gfxterm
"
""))
+ (define (setup-gfxterm config font-file)
+ (if (memq 'gfxterm (grub-configuration-terminal-outputs config))
+ #~(format #f "if loadfont ~a; then
+ setup_gfxterm
+fi~%" #$font-file)
+ ""))
+
(define (theme-colors type)
(let* ((theme (grub-configuration-theme config))
(colors (type theme)))
@@ -221,9 +234,8 @@ function setup_gfxterm {~a}
# Set 'root' to the partition that contains /gnu/store.
~a
-if loadfont ~a; then
- setup_gfxterm
-fi
+~a
+~a
insmod png
if background_image ~a; then
@@ -235,7 +247,8 @@ else
fi~%"
#$setup-gfxterm-body
#$(grub-root-search store-device font-file)
- #$font-file
+ #$(grub-setup-io config)
+ #$(setup-gfxterm config font-file)
#$(strip-mount-point store-mount-point image)
#$(theme-colors grub-theme-color-normal)
@@ -246,6 +259,34 @@ fi~%"
;;; Configuration file.
;;;
+(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.
+TODO Check the bounds of unit, and compare outputs and inputs to a list of
+valid interfaces taken from the GRUB manual."
+ (let* ((symbols->string (lambda (list)
+ (string-join (map symbol->string list) " ")))
+ (outputs (grub-configuration-terminal-outputs config))
+ (inputs (grub-configuration-terminal-inputs config))
+ (unit (grub-configuration-serial-unit config))
+ (speed (grub-configuration-serial-speed config))
+ (io (string-append
+ "terminal_output " (symbols->string outputs) "\n"
+ (if (null? inputs)
+ ""
+ (string-append "terminal_input "
+ (symbols->string inputs) "\n"))
+ (if (or unit speed)
+ (string-append "serial"
+ (if unit
+ (string-append " --unit="
+ (number->string unit)) "")
+ (if speed
+ (string-append " --speed="
+ (number->string speed)) ""))
+ ""))))
+ (format #f "~a" io)))
+
(define (grub-root-search device file)
"Return the GRUB 'search' command to look for DEVICE, which contains FILE,
a gexp. The result is a gexp that can be inserted in the grub.cfg-generation
--
2.12.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-04-05 11:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-31 12:59 question about pty,agetty for an intermediate virtual server image ng0
2017-03-31 23:43 ` Leo Famulari
2017-04-01 7:27 ` ng0
2017-04-01 18:33 ` Leo Famulari
2017-04-01 20:29 ` Leo Famulari
2017-04-02 16:31 ` question about pty, agetty " myglc2
2017-04-02 21:06 ` Non-graphical GRUB configuration Leo Famulari
2017-04-02 22:13 ` Leo Famulari
2017-04-03 0:31 ` myglc2
2017-04-03 8:39 ` Ludovic Courtès
2017-04-03 0:16 ` myglc2
2017-04-05 11:59 ` Leo Famulari [this message]
2017-04-05 15:14 ` myglc2
2017-04-05 16:07 ` Leo Famulari
2017-04-05 20:43 ` myglc2
2017-04-06 15:18 ` Leo Famulari
2017-04-06 17:34 ` myglc2
2017-04-17 13:44 ` myglc2
2017-04-17 19:51 ` Leo Famulari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170405115919.GA28944@jasmine \
--to=leo@famulari.name \
--cc=guix-devel@gnu.org \
--cc=myglc2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).