all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Dualbooting with guixsd not handling grub installation
Date: Thu, 01 Feb 2018 09:14:54 +0300	[thread overview]
Message-ID: <87h8r1me1t.fsf@gmail.com> (raw)
In-Reply-To: <877etkxufy.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 18 Dec 2017 10:21:37 +0100")


[-- Attachment #1.1: Type: text/plain, Size: 731 bytes --]

Hello Ludovic,

ludo@gnu.org (Ludovic Courtès) writes:

> Oleg Pykhalov <go.wigust@gmail.com> skribis:

[...]

>> Are linux linux-arguments initrd in menu-entry required?
>
> Currently yes: this is how you tell GRUB what to boot.

I see an issue with it, because not always you want them.

>> Maybe we could have configfile field?
>> https://www.gnu.org/software/grub/manual/grub/html_node/configfile.html
>
> Yes, we could do that.  One question is how to integrated properly since
> ‘menu-entry’ is now bootloader-independent.  Perhaps Mathieu or Danny
> have ideas?

We could start by adding a way to add anything.  Here is a patch.
Probably ugly, but as a draft and idea about additional-options.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: bootloader: Add additional-options to menu-entry. --]
[-- Type: text/x-patch, Size: 4241 bytes --]

From 7d7162a8ec78c84e7eba3ae9f7c4fbf07703617e Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <go.wigust@gmail.com>
Date: Thu, 1 Feb 2018 08:59:30 +0300
Subject: [PATCH] bootloader: Add additional-options to menu-entry.

* gnu/bootloader.scm (<menu-entry>)[additional-options]: New field.
* gnu/bootloader/grub.scm (grub-configuration-file): Handle this.
---
 gnu/bootloader.scm      | 19 +++++++++++--------
 gnu/bootloader/grub.scm | 27 +++++++++++++++++++--------
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 736f11952..9a3c29a88 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -31,6 +31,7 @@
             menu-entry-linux-arguments
             menu-entry-initrd
             menu-entry-device-mount-point
+            menu-entry-additional-options
 
             bootloader
             bootloader?
@@ -65,15 +66,17 @@
 (define-record-type* <menu-entry>
   menu-entry make-menu-entry
   menu-entry?
-  (label           menu-entry-label)
-  (device          menu-entry-device       ; file system uuid, label, or #f
-                   (default #f))
+  (label              menu-entry-label)
+  (device             menu-entry-device      ; file system uuid, label, or #f
+                      (default #f))
   (device-mount-point menu-entry-device-mount-point
-                   (default #f))
-  (linux           menu-entry-linux)
-  (linux-arguments menu-entry-linux-arguments
-                   (default '()))          ; list of string-valued gexps
-  (initrd          menu-entry-initrd))     ; file name of the initrd as a gexp
+                      (default #f))
+  (linux              menu-entry-linux)
+  (linux-arguments    menu-entry-linux-arguments
+                      (default '()))         ; list of string-valued gexps
+  (initrd             menu-entry-initrd)     ; file name of the initrd as a gexp
+  (additional-options menu-entry-additional-options
+                      (default '())))        ; list of string-valued gexps
 
 \f
 ;;;
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 96e53c5c2..7613c2a84 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -324,22 +324,33 @@ entries corresponding to old generations of the system."
           (label (menu-entry-label entry))
           (kernel (menu-entry-linux entry))
           (arguments (menu-entry-linux-arguments entry))
-          (initrd (menu-entry-initrd entry)))
+          (initrd (menu-entry-initrd entry))
+          (additional-options (menu-entry-additional-options entry)))
       ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point.
       ;; Use the right file names for KERNEL and INITRD in case
       ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a
       ;; separate partition.
-      (let ((kernel  (strip-mount-point device-mount-point kernel))
-            (initrd  (strip-mount-point device-mount-point initrd)))
-        #~(format port "menuentry ~s {
+      (if (and (file-append? kernel) (file-append? initrd))
+          (let ((kernel  (strip-mount-point device-mount-point kernel))
+                (initrd  (strip-mount-point device-mount-point initrd)))
+            #~(format port "menuentry ~s {
   ~a
   linux ~a ~a
   initrd ~a
+  ~a
+}~%"
+                      #$label
+                      #$(grub-root-search device kernel)
+                      #$kernel (string-join (list #$@arguments))
+                      #$initrd
+                      (string-join (list #$@additional-options) "\n")))
+          #~(format port "menuentry ~s {
+  ~a
+  ~a
 }~%"
-                  #$label
-                  #$(grub-root-search device kernel)
-                  #$kernel (string-join (list #$@arguments))
-                  #$initrd))))
+                    #$label
+                    #$(grub-root-search device kernel)
+                    (string-join (list #$@additional-options) "\n")))))
   (mlet %store-monad ((sugar (eye-candy config
                                         (menu-entry-device
                                          (first all-entries))
-- 
2.15.1


[-- Attachment #1.3: Type: text/plain, Size: 969 bytes --]


Which allows to use additional-options in menu-entry:
--8<---------------cut here---------------start------------->8---
(operating-system
…
 (bootloader
  (bootloader-configuration
   (bootloader grub-efi-bootloader)
   (target "/boot/efi")
   (menu-entries
    (list (menu-entry
           (label "Another distro")
           (linux "")
           (initrd "")
           (additional-options '("search --label --set another-disk-label"
                                 "configfile /boot/grub/grub.cfg")))))))
…)
--8<---------------cut here---------------end--------------->8---

Will produce the following Grub menuentry:
--8<---------------cut here---------------start------------->8---
menuentry "Another distro" {
  
  search --label --set another-disk-label
configfile /boot/grub/grub.cfg
}
--8<---------------cut here---------------end--------------->8---

I successfully reconfigured and dualbooted with attached patch.

Oleg.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2018-02-01  6:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-09 23:35 Dualbooting with guixsd not handling grub installation Martin Castillo
2017-12-10  1:11 ` Jelle Licht
2017-12-10 11:41   ` Mathieu Othacehe
2017-12-11  9:39     ` Ludovic Courtès
2017-12-14  2:27       ` Martin Castillo
2017-12-15 14:53         ` Ludovic Courtès
2017-12-17 12:29           ` Oleg Pykhalov
2017-12-18  9:21             ` Ludovic Courtès
2018-02-01  6:14               ` Oleg Pykhalov [this message]
2018-02-01  8:06                 ` Félicien Pillot
2018-02-02 22:34                   ` Oleg Pykhalov
2018-02-05 13:15                 ` Ludovic Courtès
2018-02-06 12:25                   ` Oleg Pykhalov

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h8r1me1t.fsf@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.