all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#26339: [PATCH 00/18] wip: Support non grub bootloaders.
@ 2017-04-02 13:49 Mathieu Othacehe
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                   ` (9 more replies)
  0 siblings, 10 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:49 UTC (permalink / raw)
  To: 26339

Hi,

Here's a first draft of my work on bootloaders.
Basically, I rebased David patches and started to work on top of it.

I adapted system commands "init", "reconfigure" and "switch-generation"
to the new bootloader API.

All of this is functional with my basic configuration. Don't hesitate
to test this out and comment !

I still have to update documentation. I also left untested UEFI related
stuff.

Thanks,

Mathieu

David Craven (4):
  system: Pass <bootloader-parameter> to grub.
  system: Add extlinux support.
  scripts: system: Rename --no-grub option to --no-bootloader.
  bootloader: Add install procedures and use them.

Mathieu Othacehe (14):
  system: Rename operating-system-grub.cfg to operating-system-bootcfg.
  vm: Reword grub.cfg to boot.cfg
  system: Add bootloader type.
  bootloader: Stop using grub module.
  scripts: system: Move save-load-path-excursion and
    save-environment-excursion macros to the top.
  system: Rename kernel->grub-label to kernel->boot-label.
  bootloader: Add device and type to bootloader-configuration record.
  system: Rename grub-device to fs->boot-device.
  scripts: system: Remove unused variables.
  scripts: system: Rename grub? and install-grub? to bootloader? and
    install-bootloader?.
  scripts: system: Adapt "reconfigure" to new bootloader API.
  scripts: system: Adapt "init" to new bootloader API.
  scripts: system: Adapt "switch-generation" to new bootloader API.
  scripts: system: Display bootloader device and type in
    "list-generations".

 gnu.scm                   |   3 +-
 gnu/build/install.scm     |  36 ++---
 gnu/build/vm.scm          |  22 +--
 gnu/local.mk              |   1 +
 gnu/system.scm            |  72 +++++++---
 gnu/system/bootloader.scm | 253 +++++++++++++++++++++++++++++++++
 gnu/system/grub.scm       |  41 ++++--
 gnu/system/vm.scm         |  52 ++++---
 gnu/tests.scm             |   3 +-
 gnu/tests/nfs.scm         |   3 +-
 gnu/tests/web.scm         |   2 +-
 guix/scripts/system.scm   | 353 ++++++++++++++++++++++++++--------------------
 tests/guix-system.sh      |   2 -
 tests/system.scm          |   2 -
 14 files changed, 592 insertions(+), 253 deletions(-)
 create mode 100644 gnu/system/bootloader.scm

-- 
2.12.2

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
@ 2017-04-02 13:52 ` Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 02/18] system: Add extlinux support Mathieu Othacehe
                     ` (20 more replies)
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                   ` (8 subsequent siblings)
  9 siblings, 21 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339; +Cc: David Craven

From: David Craven <david@craven.ch>

* gnu/system.scm (operating-system-grub.cfg): Pass <bootloader-parameter>.
* gnu/system/grub.scm (boot-parameters->menu-entry): New variable.
  (grub-configuration-file): Use boot-parameters->menu-entry.
---
 gnu/system.scm      | 12 +++++++-----
 gnu/system/grub.scm | 19 +++++++++++++++----
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 0f52351cf..d528c4a6a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -99,6 +99,7 @@
 
             system-linux-image-file-name
 
+            <boot-parameters>
             boot-parameters
             boot-parameters?
             boot-parameters-label
@@ -741,16 +742,17 @@ listed in OS.  The C library expects to find it under
        (root-device -> (if (eq? 'uuid (file-system-title root-fs))
                            (uuid->string (file-system-device root-fs))
                            (file-system-device root-fs)))
-       (entries ->  (list (menu-entry
+       (entries ->  (list (boot-parameters
                            (label label)
+                           (root-device root-device)
 
                            ;; The device where the kernel and initrd live.
-                           (device (grub-device store-fs))
-                           (device-mount-point
+                           (store-device (grub-device store-fs))
+                           (store-mount-point
                             (file-system-mount-point store-fs))
 
-                           (linux kernel)
-                           (linux-arguments
+                           (kernel kernel)
+                           (kernel-arguments
                             (cons* (string-append "--root=" root-device)
                                    #~(string-append "--system=" #$system)
                                    #~(string-append "--load=" #$system
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index 4f9bde6a6..f2838d633 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -26,6 +26,7 @@
   #:use-module (guix gexp)
   #:use-module (guix download)
   #:use-module (gnu artwork)
+  #:use-module (gnu system)
   #:use-module (gnu system file-systems)
   #:autoload   (gnu packages bootloaders) (grub)
   #:autoload   (gnu packages compression) (gzip)
@@ -266,6 +267,15 @@ code."
         (#f
          #~(format #f "search --file --set ~a" #$file)))))
 
+(define (boot-parameters->menu-entry conf)
+  (menu-entry
+   (label (boot-parameters-label conf))
+   (device (boot-parameters-store-device conf))
+   (device-mount-point (boot-parameters-store-mount-point conf))
+   (linux (boot-parameters-kernel conf))
+   (linux-arguments (boot-parameters-kernel-arguments conf))
+   (initrd (boot-parameters-initrd conf))))
+
 (define* (grub-configuration-file config entries
                                   #:key
                                   (system (%current-system))
@@ -275,7 +285,8 @@ code."
 <file-system> object.  OLD-ENTRIES is taken to be a list of menu entries
 corresponding to old generations of the system."
   (define all-entries
-    (append entries (grub-configuration-menu-entries config)))
+    (append (map boot-parameters->menu-entry entries)
+            (grub-configuration-menu-entries config)))
 
   (define entry->gexp
     (match-lambda
@@ -298,9 +309,9 @@ corresponding to old generations of the system."
                   #$initrd)))))
 
   (mlet %store-monad ((sugar (eye-candy config
-                                        (menu-entry-device (first entries))
+                                        (menu-entry-device (first all-entries))
                                         (menu-entry-device-mount-point
-                                         (first entries))
+                                         (first all-entries))
                                         #:system system
                                         #:port #~port)))
     (define builder
@@ -321,7 +332,7 @@ set timeout=~a~%"
             #$@(if (pair? old-entries)
                    #~((format port "
 submenu \"GNU system, old configurations...\" {~%")
-                      #$@(map entry->gexp old-entries)
+                      #$@(map entry->gexp (map boot-parameters->menu-entry old-entries))
                       (format port "}~%"))
                    #~()))))
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 16:03     ` Danny Milosavljevic
  2017-05-08 20:06     ` Ludovic Courtès
  2017-04-02 13:52   ` bug#26339: [PATCH 03/18] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
                     ` (19 subsequent siblings)
  20 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339; +Cc: David Craven

From: David Craven <david@craven.ch>

* gnu/system.scm (operating-system): Add default bootloader.
  (operating-system-grub.cfg): Use bootloader-configuration-file-procedure.
* gnu/system/grub.scm (bootloader-configuration->grub-configuration): New
  variable.
  (grub-configuration-file): Use bootloader-configuration->grub-configuration.
* guix/scripts/system.scm (profile-grub-entries): Rename system->grub-entry to
  system->boot-parameters and adjust accordingly.
  (perform-action): Make bootloader optional. Use
  bootloader-configuration-device.
* gnu/system/bootloader.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* tests/system.scm: Adjust operating-system to new API.
* tests/guix-system.sh: Adjust operating-system to new API.
---
 gnu/local.mk              |   1 +
 gnu/system.scm            |  10 +--
 gnu/system/bootloader.scm | 158 ++++++++++++++++++++++++++++++++++++++++++++++
 gnu/system/grub.scm       |  22 ++++---
 guix/scripts/system.scm   |  44 ++++++-------
 tests/guix-system.sh      |   2 -
 tests/system.scm          |   2 -
 7 files changed, 197 insertions(+), 42 deletions(-)
 create mode 100644 gnu/system/bootloader.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 68f561e95..d3033f54f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -437,6 +437,7 @@ GNU_SYSTEM_MODULES =				\
 						\
   %D%/system.scm				\
   %D%/system/file-systems.scm			\
+  %D%/system/bootloader.scm			\
   %D%/system/grub.scm				\
   %D%/system/install.scm			\
   %D%/system/linux-container.scm		\
diff --git a/gnu/system.scm b/gnu/system.scm
index d528c4a6a..e0257bd4a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -47,7 +47,7 @@
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services base)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system nss)
   #:use-module (gnu system locale)
@@ -131,8 +131,8 @@
           (default linux-libre))
   (kernel-arguments operating-system-kernel-arguments
                     (default '()))                ; list of gexps/strings
-  (bootloader operating-system-bootloader)        ; <grub-configuration>
-
+  (bootloader operating-system-bootloader         ; <bootloader-configuration>
+              (default (extlinux-configuration)))
   (initrd operating-system-initrd                 ; (list fs) -> M derivation
           (default base-initrd))
   (firmware operating-system-firmware             ; list of packages
@@ -759,8 +759,8 @@ listed in OS.  The C library expects to find it under
                                                     "/boot")
                                    (operating-system-kernel-arguments os)))
                            (initrd initrd)))))
-    (grub-configuration-file (operating-system-bootloader os) entries
-                             #:old-entries old-entries)))
+    ((bootloader-configuration-file-procedure (operating-system-bootloader os))
+     (operating-system-bootloader os) entries #:old-entries old-entries)))
 
 (define (grub-device fs)
   "Given FS, a <file-system> object, return a value suitable for use as the
diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
new file mode 100644
index 000000000..6da19f6d3
--- /dev/null
+++ b/gnu/system/bootloader.scm
@@ -0,0 +1,158 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 David Craven <david@craven.ch>
+;;;
+;;; 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/>.
+
+(define-module (gnu system bootloader)
+  #:use-module (gnu system)
+  #:use-module (gnu system grub)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix records)
+  #:use-module (ice-9 match)
+  #:export (bootloader-configuration
+            bootloader-configuration?
+            bootloader-configuration-bootloader
+            bootloader-configuration-device
+            bootloader-configuration-menu-entries
+            bootloader-configuration-default-entry
+            bootloader-configuration-timeout
+            bootloader-configuration-file-location
+            bootloader-configuration-file-procedure
+            bootloader-configuration-install-procedure
+            bootloader-configuration-additional-configuration
+
+            extlinux-configuration
+            grub-configuration
+            grub-efi-configuration
+            syslinux-configuration))
+
+;;; Commentary:
+;;;
+;;; Generic configuration for bootloaders.
+;;;
+;;; Code:
+
+(define-record-type* <bootloader-configuration>
+  bootloader-configuration make-bootloader-configuration
+  bootloader-configuration?
+  (bootloader                      bootloader-configuration-bootloader     ; package
+                                   (default #f))
+  (device                          bootloader-configuration-device         ; string
+                                   (default #f))
+  (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
+                                   (default '()))
+  (default-entry                   bootloader-configuration-default-entry  ; integer
+                                   (default 0))
+  (timeout                         bootloader-configuration-timeout        ; integer
+                                   (default 5))
+  (configuration-file-location     bootloader-configuration-file-location
+                                   (default #f))
+  (configuration-file-procedure    bootloader-configuration-file-procedure ; procedure
+                                   (default #f))
+  (install-procedure               bootloader-configuration-install-procedure ; procedure
+                                   (default #f))
+  (additional-configuration        bootloader-configuration-additional-configuration ; record
+                                   (default #f)))
+
+\f
+
+;;;
+;;; Extlinux configuration file.
+;;;
+
+(define* (extlinux-configuration-file config entries
+                                      #:key
+                                      (system (%current-system))
+                                      (old-entries '()))
+  "Return the U-Boot configuration file corresponding to CONFIG, a
+<u-boot-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."
+
+  (define all-entries
+    (append entries (bootloader-configuration-menu-entries config)))
+
+  (define boot-parameters->gexp
+    (match-lambda
+      (($ <boot-parameters> label _ _ _ kernel kernel-arguments initrd)
+       #~(format port "LABEL ~a
+  MENU LABEL ~a
+  KERNEL ~a
+  FDTDIR ~a/lib/dtbs
+  INITRD ~a
+  APPEND ~a
+~%"
+                 #$label #$label
+                 #$kernel #$kernel #$initrd
+                 (string-join (list #$@kernel-arguments))))))
+
+  (define builder
+    #~(call-with-output-file #$output
+        (lambda (port)
+          (let ((timeout #$(bootloader-configuration-timeout config)))
+            (format port "
+UI menu.c32
+PROMPT ~a
+TIMEOUT ~a~%"
+                    (if (> timeout 0) 1 0)
+                    (* 10 timeout))
+            #$@(map boot-parameters->gexp all-entries)
+
+            #$@(if (pair? old-entries)
+                   #~((format port "~%")
+                      #$@(map boot-parameters->gexp old-entries)
+                      (format port "~%"))
+                   #~())))))
+
+  (gexp->derivation "extlinux.conf" builder))
+
+
+\f
+
+;;;
+;;; Bootloader configurations.
+;;;
+
+(define* (extlinux-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit config)
+   (configuration-file-location "/boot/extlinux/extlinux.conf")
+   (configuration-file-procedure extlinux-configuration-file)))
+
+(define* (grub-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit config)
+   (bootloader (@ (gnu packages bootloaders) grub))
+   (configuration-file-location "/boot/grub/grub.cfg")
+   (configuration-file-procedure grub-configuration-file)
+   (install-procedure install-grub)
+   (additional-configuration
+    (let ((additional-config (bootloader-configuration-additional-configuration config)))
+      (if additional-config additional-config %default-theme)))))
+
+(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit (grub-configuration config))
+   (bootloader (@ (gnu packages bootloaders) grub-efi))))
+
+(define* (syslinux-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit (extlinux-configuration config))
+   (bootloader (@ (gnu packages bootloaders) syslinux))
+   (install-procedure install-syslinux)))
+
+;;; bootloader.scm ends here
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index f2838d633..0b52e3e7e 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -27,6 +27,7 @@
   #:use-module (guix download)
   #:use-module (gnu artwork)
   #:use-module (gnu system)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:autoload   (gnu packages bootloaders) (grub)
   #:autoload   (gnu packages compression) (gzip)
@@ -49,14 +50,6 @@
             %background-image
             %default-theme
 
-            grub-configuration
-            grub-configuration?
-            grub-configuration-device
-            grub-configuration-grub
-
-            menu-entry
-            menu-entry?
-
             grub-configuration-file))
 
 ;;; Commentary:
@@ -276,7 +269,16 @@ code."
    (linux-arguments (boot-parameters-kernel-arguments conf))
    (initrd (boot-parameters-initrd conf))))
 
-(define* (grub-configuration-file config entries
+(define (bootloader-configuration->grub-configuration config)
+  (grub-configuration
+   (grub (bootloader-configuration-bootloader config))
+   (device (bootloader-configuration-device config))
+   (menu-entries (bootloader-configuration-menu-entries config))
+   (default-entry (bootloader-configuration-default-entry config))
+   (timeout (bootloader-configuration-timeout config))
+   (theme (bootloader-configuration-additional-configuration config))))
+
+(define* (grub-configuration-file bootloader-config entries
                                   #:key
                                   (system (%current-system))
                                   (old-entries '()))
@@ -284,6 +286,8 @@ code."
 <grub-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."
+  (define config (bootloader-configuration->grub-configuration bootloader-config))
+
   (define all-entries
     (append (map boot-parameters->menu-entry entries)
             (grub-configuration-menu-entries config)))
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 144a7fd37..fb32d08a5 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -37,10 +37,10 @@
   #:use-module (guix build utils)
   #:use-module (gnu build install)
   #:use-module (gnu system)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system linux-container)
   #:use-module (gnu system vm)
-  #:use-module (gnu system grub)
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services herd)
@@ -366,32 +366,25 @@ it atomically, and then run OS's activation script."
                                   (numbers (generation-numbers profile)))
   "Return a list of 'menu-entry' for the generations of PROFILE specified by
 NUMBERS, which is a list of generation numbers."
-  (define (system->grub-entry system number time)
+  (define (system->boot-parameters system number time)
     (unless-file-not-found
      (let* ((file             (string-append system "/parameters"))
             (params           (call-with-input-file file
                                 read-boot-parameters))
-            (label            (boot-parameters-label params))
             (root             (boot-parameters-root-device params))
             (root-device      (if (bytevector? root)
                                   (uuid->string root)
-                                  root))
-            (kernel           (boot-parameters-kernel params))
-            (kernel-arguments (boot-parameters-kernel-arguments params))
-            (initrd           (boot-parameters-initrd params)))
-       (menu-entry
-        (label (string-append label " (#"
+                                  root)))
+       (boot-parameters
+        (inherit params)
+        (label (string-append (boot-parameters-label params) " (#"
                               (number->string number) ", "
                               (seconds->string time) ")"))
-        (device (boot-parameters-store-device params))
-        (device-mount-point (boot-parameters-store-mount-point params))
-        (linux kernel)
-        (linux-arguments
-         (cons* (string-append "--root=" root-device)
+        (kernel-arguments
+         (cons* (string-append "--root=" (boot-parameters-root-device params))
                 (string-append "--system=" system)
                 (string-append "--load=" system "/boot")
-                kernel-arguments))
-        (initrd initrd)))))
+                (boot-parameters-kernel-arguments params)))))))
 
   (let* ((systems (map (cut generation-file-name profile <>)
                        numbers))
@@ -399,7 +392,7 @@ NUMBERS, which is a list of generation numbers."
                          (unless-file-not-found
                           (stat:mtime (lstat system))))
                        systems)))
-    (filter-map system->grub-entry systems numbers times)))
+    (filter-map system->boot-parameters systems numbers times)))
 
 \f
 ;;;
@@ -613,8 +606,11 @@ building anything."
                                                 #:image-size image-size
                                                 #:full-boot? full-boot?
                                                 #:mappings mappings))
-       (grub      (package->derivation (grub-configuration-grub
-                                        (operating-system-bootloader os))))
+       (bootloader (let ((bootloader (bootloader-configuration-bootloader
+                                      (operating-system-bootloader os))))
+                     (if bootloader
+                         (package->derivation bootloader)
+                         (return #f))))
        (grub.cfg  (if (eq? 'container action)
                       (return #f)
                       (operating-system-grub.cfg os
@@ -626,8 +622,8 @@ building anything."
        ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
        ;; root.  See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if grub?
-                          (list sys grub.cfg grub)
+                      (if (and grub? bootloader)
+                          (list sys grub.cfg bootloader)
                           (list sys grub.cfg))
                       (list sys)))
        (%         (if derivations-only?
@@ -643,8 +639,8 @@ building anything."
                     drvs)
 
           ;; Make sure GRUB is accessible.
-          (when grub?
-            (let ((prefix (derivation->output-path grub)))
+          (when (and grub? bootloader)
+            (let ((prefix (derivation->output-path bootloader)))
               (setenv "PATH"
                       (string-append  prefix "/bin:" prefix "/sbin:"
                                       (getenv "PATH")))))
@@ -835,7 +831,7 @@ resulting from command-line parsing."
                      ((first second) second)
                      (_ #f)))
          (device   (and grub?
-                        (grub-configuration-device
+                        (bootloader-configuration-device
                          (operating-system-bootloader os)))))
 
     (with-store store
diff --git a/tests/guix-system.sh b/tests/guix-system.sh
index de6db0928..525480a11 100644
--- a/tests/guix-system.sh
+++ b/tests/guix-system.sh
@@ -91,7 +91,6 @@ OS_BASE='
   (timezone "Europe/Paris")
   (locale "en_US.UTF-8")
 
-  (bootloader (grub-configuration (device "/dev/sdX")))
   (file-systems (cons (file-system
                         (device "root")
                         (title (string->symbol "label"))
@@ -162,7 +161,6 @@ make_user_config ()
   (timezone "Europe/Paris")
   (locale "en_US.UTF-8")
 
-  (bootloader (grub-configuration (device "/dev/sdX")))
   (file-systems (cons (file-system
                         (device "root")
                         (title 'label)
diff --git a/tests/system.scm b/tests/system.scm
index ca34409be..bdda08e18 100644
--- a/tests/system.scm
+++ b/tests/system.scm
@@ -36,7 +36,6 @@
     (host-name "komputilo")
     (timezone "Europe/Berlin")
     (locale "en_US.utf8")
-    (bootloader (grub-configuration (device "/dev/sdX")))
     (file-systems (cons %root-fs %base-file-systems))
 
     (users %base-user-accounts)))
@@ -51,7 +50,6 @@
     (host-name "komputilo")
     (timezone "Europe/Berlin")
     (locale "en_US.utf8")
-    (bootloader (grub-configuration (device "/dev/sdX")))
     (mapped-devices (list %luks-device))
     (file-systems (cons (file-system
                           (inherit %root-fs)
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 03/18] scripts: system: Rename --no-grub option to --no-bootloader.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 02/18] system: Add extlinux support Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 10:10     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them Mathieu Othacehe
                     ` (18 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339; +Cc: David Craven

From: David Craven <david@craven.ch>

* guix/scripts/system.scm (%options, show-help): Adjust accordingly.
---
 guix/scripts/system.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index fb32d08a5..04274919e 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -733,7 +733,7 @@ Some ACTIONS support additional ARGS.\n"))
   (display (_ "
       --image-size=SIZE  for 'vm-image', produce an image of SIZE"))
   (display (_ "
-      --no-grub          for 'init', do not install GRUB"))
+      --no-bootloader    for 'init', do not install a bootloader"))
   (display (_ "
       --share=SPEC       for 'vm', share host file system according to SPEC"))
   (display (_ "
@@ -768,7 +768,7 @@ Some ACTIONS support additional ARGS.\n"))
                  (lambda (opt name arg result)
                    (alist-cons 'image-size (size->number arg)
                                result)))
-         (option '("no-grub") #f #f
+         (option '("no-bootloader") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'install-grub? #f result)))
          (option '("full-boot") #f #f
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 02/18] system: Add extlinux support Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 03/18] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 16:22     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 05/18] system: Rename operating-system-grub.cfg to operating-system-bootcfg Mathieu Othacehe
                     ` (17 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339; +Cc: David Craven

From: David Craven <david@craven.ch>

* gnu/system/bootloader.scm (dd, install-grub, install-syslinux): New
  procedures.
* gnu/build/install.scm (install-boot-config): New procedure.
  (install-grub): Move to (gnu system bootloader).
* gnu/build/vm.scm (register-bootcfg-root): Rename register-grub.cfg-root and
  adjust accordingly.
  (initialize-hard-disk): Takes a bootloader, bootcfg, bootcfg-location and
  install-bootloader procedure. Adjust accordingly.
* gnu/system/vm.scm (qemu-image): Adjust to initialize-hard-disk.
  (system-disk-image, system-qemu-image, system-qemu-image/shared-store):
  Adjust to qemu-image.
---
 gnu/build/install.scm     | 36 ++++++++--------------------------
 gnu/build/vm.scm          | 17 ++++++++++------
 gnu/system/bootloader.scm | 49 ++++++++++++++++++++++++++++++++++++++++++++++-
 gnu/system/vm.scm         | 37 +++++++++++++++++++++++------------
 4 files changed, 92 insertions(+), 47 deletions(-)

diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index 5cb6055a0..9e30c0d23 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -22,8 +22,7 @@
   #:use-module (guix build store-copy)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
-  #:export (install-grub
-            install-grub-config
+  #:export (install-boot-config
             evaluate-populate-directive
             populate-root-file-system
             reset-timestamps
@@ -39,36 +38,17 @@
 ;;;
 ;;; Code:
 
-(define (install-grub grub.cfg device mount-point)
-  "Install GRUB with GRUB.CFG on DEVICE, which is assumed to be mounted on
-MOUNT-POINT.
-
-Note that the caller must make sure that GRUB.CFG is registered as a GC root
-so that the fonts, background images, etc. referred to by GRUB.CFG are not
-GC'd."
-  (install-grub-config grub.cfg mount-point)
-
-  ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or root
-  ;; partition.
-  (setenv "GRUB_ENABLE_CRYPTODISK" "y")
-
-  (unless (zero? (system* "grub-install" "--no-floppy"
-                          "--boot-directory"
-                          (string-append mount-point "/boot")
-                          device))
-    (error "failed to install GRUB")))
-
-(define (install-grub-config grub.cfg mount-point)
-  "Atomically copy GRUB.CFG into boot/grub/grub.cfg on the MOUNT-POINT.  Note
-that the caller must make sure that GRUB.CFG is registered as a GC root so
-that the fonts, background images, etc. referred to by GRUB.CFG are not GC'd."
-  (let* ((target (string-append mount-point "/boot/grub/grub.cfg"))
+(define (install-boot-config bootcfg bootcfg-location mount-point)
+  "Atomically copy BOOTCFG into BOOTCFG-LOCATION on the MOUNT-POINT.  Note
+that the caller must make sure that BOOTCFG is registered as a GC root so
+that the fonts, background images, etc. referred to by BOOTCFG are not GC'd."
+  (let* ((target (string-append mount-point bootcfg-location))
          (pivot  (string-append target ".new")))
     (mkdir-p (dirname target))
 
-    ;; Copy GRUB.CFG instead of just symlinking it, because symlinks won't
+    ;; Copy BOOTCFG instead of just symlinking it, because symlinks won't
     ;; work when /boot is on a separate partition.  Do that atomically.
-    (copy-file grub.cfg pivot)
+    (copy-file bootcfg pivot)
     (rename-file pivot target)))
 
 (define (evaluate-populate-directive directive target)
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 60ee18ebe..c536f4f44 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -283,15 +283,18 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
     (unless register-closures?
       (reset-timestamps target))))
 
-(define (register-grub.cfg-root target grub.cfg)
+(define (register-bootcfg-root target bootcfg)
   "On file system TARGET, register GRUB.CFG as a GC root."
   (let ((directory (string-append target "/var/guix/gcroots")))
     (mkdir-p directory)
-    (symlink grub.cfg (string-append directory "/grub.cfg"))))
+    (symlink bootcfg (string-append directory "/bootcfg"))))
 
 (define* (initialize-hard-disk device
                                #:key
-                               grub.cfg
+                               bootloader
+                               bootcfg
+                               bootcfg-location
+                               install-bootloader
                                (partitions '()))
   "Initialize DEVICE as a disk containing all the <partition> objects listed
 in PARTITIONS, and using GRUB.CFG as its bootloader configuration file.
@@ -309,10 +312,12 @@ passing it a directory name where it is mounted."
     (display "mounting root partition...\n")
     (mkdir-p target)
     (mount (partition-device root) target (partition-file-system root))
-    (install-grub grub.cfg device target)
+    (install-boot-config bootcfg bootcfg-location target)
+    (when install-bootloader
+      (install-bootloader bootloader device target))
 
-    ;; Register GRUB.CFG as a GC root.
-    (register-grub.cfg-root target grub.cfg)
+    ;; Register BOOTCFG as a GC root.
+    (register-bootcfg-root target bootcfg)
 
     (umount target)))
 
diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
index 6da19f6d3..ea570ee00 100644
--- a/gnu/system/bootloader.scm
+++ b/gnu/system/bootloader.scm
@@ -38,7 +38,11 @@
             extlinux-configuration
             grub-configuration
             grub-efi-configuration
-            syslinux-configuration))
+            syslinux-configuration
+
+            dd
+            install-grub
+            install-syslinux))
 
 ;;; Commentary:
 ;;;
@@ -155,4 +159,47 @@ TIMEOUT ~a~%"
    (bootloader (@ (gnu packages bootloaders) syslinux))
    (install-procedure install-syslinux)))
 
+\f
+
+;;;
+;;; Bootloader install procedures.
+;;;
+
+(define dd
+  #~(lambda (bs count if of)
+      (zero? (system* "dd"
+                      (string-append "bs=" (number->string bs))
+                      (string-append "count=" (number->string count))
+                      (string-append "if=" if)
+                      (string-append "of=" of)))))
+
+(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")
+
+        (unless (zero? (system* grub "--no-floppy"
+                                "--boot-directory" install-dir
+                                device))
+          (error "failed to install GRUB")))))
+
+(define install-syslinux
+  #~(lambda (bootloader device mount-point)
+      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
+            (install-dir (string-append mount-point "/boot/extlinux"))
+            (syslinux-dir (string-append bootloader "/share/syslinux")))
+        (mkdir-p install-dir)
+        (for-each (lambda (file)
+                    (copy-file file
+                               (string-append install-dir "/" (basename file))))
+                  (find-files syslinux-dir "\\.c32$"))
+
+        (unless (and (zero? (system* extlinux "--install" install-dir))
+                     (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
+          (error "failed to install SYSLINUX")))))
+
 ;;; bootloader.scm ends here
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 5c6e7f684..6f852d7ea 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -45,10 +45,10 @@
                 #:select (%guile-static-stripped))
   #:use-module (gnu packages admin)
 
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system pam)
   #:use-module (gnu system linux-initrd)
-  #:use-module (gnu system grub)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system)
   #:use-module (gnu services)
@@ -175,8 +175,9 @@ made available under the /xchg CIFS share."
                      (disk-image-format "qcow2")
                      (file-system-type "ext4")
                      file-system-label
-                     os-derivation
-                     grub-configuration
+                     os.drv
+                     bootcfg.drv
+                     bootloader-configuration
                      (register-closures? #t)
                      (inputs '())
                      copy-inputs?)
@@ -200,7 +201,7 @@ the image."
                       (guix build utils))
 
          (let ((inputs
-                '#$(append (list qemu parted grub e2fsprogs)
+                '#$(append (list qemu parted e2fsprogs)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -222,7 +223,7 @@ the image."
                                #:closures graphs
                                #:copy-closures? #$copy-inputs?
                                #:register-closures? #$register-closures?
-                               #:system-directory #$os-derivation))
+                               #:system-directory #$os.drv))
                   (partitions (list (partition
                                      (size #$(- disk-image-size
                                                 (* 10 (expt 2 20))))
@@ -232,7 +233,16 @@ the image."
                                      (initializer initialize)))))
              (initialize-hard-disk "/dev/vda"
                                    #:partitions partitions
-                                   #:grub.cfg #$grub-configuration)
+                                   #:bootloader
+                                   #$(bootloader-configuration-bootloader
+                                      bootloader-configuration)
+                                   #:bootcfg #$bootcfg.drv
+                                   #:bootcfg-location
+                                   #$(bootloader-configuration-file-location
+                                      bootloader-configuration)
+                                   #:install-bootloader
+                                   #$(bootloader-configuration-install-procedure
+                                      bootloader-configuration))
              (reboot)))))
    #:system system
    #:make-disk-image? #t
@@ -286,8 +296,9 @@ to USB sticks meant to be read-only."
     (mlet* %store-monad ((os-drv   (operating-system-derivation os))
                          (grub.cfg (operating-system-grub.cfg os)))
       (qemu-image #:name name
-                  #:os-derivation os-drv
-                  #:grub-configuration grub.cfg
+                  #:os.drv os-drv
+                  #:bootcfg.drv grub.cfg
+                  #:bootloader-configuration (operating-system-bootloader os)
                   #:disk-image-size disk-image-size
                   #:disk-image-format "raw"
                   #:file-system-type file-system-type
@@ -329,8 +340,9 @@ of the GNU system as described by OS."
     (mlet* %store-monad
         ((os-drv      (operating-system-derivation os))
          (grub.cfg    (operating-system-grub.cfg os)))
-      (qemu-image  #:os-derivation os-drv
-                   #:grub-configuration grub.cfg
+      (qemu-image  #:os.drv os-drv
+                   #:bootcfg.drv grub.cfg
+                   #:bootloader-configuration (operating-system-bootloader os)
                    #:disk-image-size disk-image-size
                    #:file-system-type file-system-type
                    #:inputs `(("system" ,os-drv)
@@ -428,8 +440,9 @@ bootloader refers to: OS kernel, initrd, bootloader data, etc."
     ;; GRUB.CFG and all its dependencies, including the output of OS-DRV.
     ;; This is more than needed (we only need the kernel, initrd, GRUB for its
     ;; font, and the background image), but it's hard to filter that.
-    (qemu-image #:os-derivation os-drv
-                #:grub-configuration grub.cfg
+    (qemu-image #:os.drv os-drv
+                #:bootcfg.drv grub.cfg
+                #:bootloader-configuration (operating-system-bootloader os)
                 #:disk-image-size disk-image-size
                 #:inputs (if full-boot?
                              `(("grub.cfg" ,grub.cfg))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 05/18] system: Rename operating-system-grub.cfg to operating-system-bootcfg.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (2 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 12:44     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 06/18] vm: Reword grub.cfg to boot.cfg Mathieu Othacehe
                     ` (16 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (operating-system-grub.cfg): Rename to
  operating-system-bootcfg.
---
 gnu/system.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index e0257bd4a..a9b05806a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -92,7 +93,7 @@
 
             operating-system-derivation
             operating-system-profile
-            operating-system-grub.cfg
+            operating-system-bootcfg
             operating-system-etc-directory
             operating-system-locale-directory
             operating-system-boot-script
@@ -729,9 +730,9 @@ listed in OS.  The C library expects to find it under
   "Return the file system that contains the store of OS."
   (store-file-system (operating-system-file-systems os)))
 
-(define* (operating-system-grub.cfg os #:optional (old-entries '()))
-  "Return the GRUB configuration file for OS.  Use OLD-ENTRIES to populate the
-\"old entries\" menu."
+(define* (operating-system-bootcfg os #:optional (old-entries '()))
+  "Return the bootloader configuration file for OS.  Use OLD-ENTRIES to
+populate the \"old entries\" menu."
   (mlet* %store-monad
       ((system      (operating-system-derivation os))
        (root-fs ->  (operating-system-root-file-system os))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 06/18] vm: Reword grub.cfg to boot.cfg
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (3 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 05/18] system: Rename operating-system-grub.cfg to operating-system-bootcfg Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 12:43     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 07/18] system: Add bootloader type Mathieu Othacehe
                     ` (15 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* gnu/build/vm.scm (register-bootcfg-root): Reword grub.cfg to boot.cfg,
(initialize-hard-disk): ditto,
* gnu/system/vm.scm (system-disk-image): ditto,
(system-qemu-image): ditto,
(system-qemu-image/shared-store): ditto.
---
 gnu/build/vm.scm  |  5 +++--
 gnu/system/vm.scm | 21 +++++++++++----------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index c536f4f44..766163e1d 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -284,7 +285,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
       (reset-timestamps target))))
 
 (define (register-bootcfg-root target bootcfg)
-  "On file system TARGET, register GRUB.CFG as a GC root."
+  "On file system TARGET, register BOOTCFG as a GC root."
   (let ((directory (string-append target "/var/guix/gcroots")))
     (mkdir-p directory)
     (symlink bootcfg (string-append directory "/bootcfg"))))
@@ -297,7 +298,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
                                install-bootloader
                                (partitions '()))
   "Initialize DEVICE as a disk containing all the <partition> objects listed
-in PARTITIONS, and using GRUB.CFG as its bootloader configuration file.
+in PARTITIONS, and using BOOTCFG as its bootloader configuration file.
 
 Each partition is initialized by calling its 'initializer' procedure,
 passing it a directory name where it is mounted."
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 6f852d7ea..7efbc872c 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -294,10 +295,10 @@ to USB sticks meant to be read-only."
                                   file-systems-to-keep)))))
 
     (mlet* %store-monad ((os-drv   (operating-system-derivation os))
-                         (grub.cfg (operating-system-grub.cfg os)))
+                         (bootcfg  (operating-system-bootcfg os)))
       (qemu-image #:name name
                   #:os.drv os-drv
-                  #:bootcfg.drv grub.cfg
+                  #:bootcfg.drv bootcfg
                   #:bootloader-configuration (operating-system-bootloader os)
                   #:disk-image-size disk-image-size
                   #:disk-image-format "raw"
@@ -306,7 +307,7 @@ to USB sticks meant to be read-only."
                   #:copy-inputs? #t
                   #:register-closures? #t
                   #:inputs `(("system" ,os-drv)
-                             ("grub.cfg" ,grub.cfg))))))
+                             ("bootcfg" ,bootcfg))))))
 
 (define* (system-qemu-image os
                             #:key
@@ -339,14 +340,14 @@ of the GNU system as described by OS."
                                   file-systems-to-keep)))))
     (mlet* %store-monad
         ((os-drv      (operating-system-derivation os))
-         (grub.cfg    (operating-system-grub.cfg os)))
+         (bootcfg     (operating-system-bootcfg os)))
       (qemu-image  #:os.drv os-drv
-                   #:bootcfg.drv grub.cfg
+                   #:bootcfg.drv bootcfg
                    #:bootloader-configuration (operating-system-bootloader os)
                    #:disk-image-size disk-image-size
                    #:file-system-type file-system-type
                    #:inputs `(("system" ,os-drv)
-                              ("grub.cfg" ,grub.cfg))
+                              ("bootcfg" ,bootcfg))
                    #:copy-inputs? #t))))
 
 \f
@@ -435,17 +436,17 @@ When FULL-BOOT? is true, return an image that does a complete boot sequence,
 bootloaded included; thus, make a disk image that contains everything the
 bootloader refers to: OS kernel, initrd, bootloader data, etc."
   (mlet* %store-monad ((os-drv   (operating-system-derivation os))
-                       (grub.cfg (operating-system-grub.cfg os)))
+                       (bootcfg  (operating-system-bootcfg os)))
     ;; XXX: When FULL-BOOT? is true, we end up creating an image that contains
-    ;; GRUB.CFG and all its dependencies, including the output of OS-DRV.
+    ;; BOOTCFG and all its dependencies, including the output of OS-DRV.
     ;; This is more than needed (we only need the kernel, initrd, GRUB for its
     ;; font, and the background image), but it's hard to filter that.
     (qemu-image #:os.drv os-drv
-                #:bootcfg.drv grub.cfg
+                #:bootcfg.drv bootcfg
                 #:bootloader-configuration (operating-system-bootloader os)
                 #:disk-image-size disk-image-size
                 #:inputs (if full-boot?
-                             `(("grub.cfg" ,grub.cfg))
+                             `(("bootcfg" ,bootcfg))
                              '())
 
                 ;; XXX: Passing #t here is too slow, so let it off by default.
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 07/18] system: Add bootloader type.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (4 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 06/18] vm: Reword grub.cfg to boot.cfg Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 16:26     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 08/18] bootloader: Stop using grub module Mathieu Othacehe
                     ` (14 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* gnu/system/bootloader.scm
(<bootloader-configuration>)[type]: New field.
(%extlinux-configuration, %grub-configuration, %grub-efi-configuration,
%syslinux-configuration): New exported variables.
(extlinux-configuration, grub-configuration, grub-efi-configuration,
syslinux-configuration): New exported compatibility macros.
---
 gnu/system/bootloader.scm | 116 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 82 insertions(+), 34 deletions(-)

diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
index ea570ee00..c2b23c380 100644
--- a/gnu/system/bootloader.scm
+++ b/gnu/system/bootloader.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 David Craven <david@craven.ch>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,10 +23,12 @@
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
+  #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
   #:export (bootloader-configuration
             bootloader-configuration?
             bootloader-configuration-bootloader
+            bootloader-configuration-type
             bootloader-configuration-device
             bootloader-configuration-menu-entries
             bootloader-configuration-default-entry
@@ -35,6 +38,13 @@
             bootloader-configuration-install-procedure
             bootloader-configuration-additional-configuration
 
+            %extlinux-configuration
+            %grub-configuration
+            %grub-efi-configuration
+            %syslinux-configuration
+
+            lookup-bootloader-configuration
+
             extlinux-configuration
             grub-configuration
             grub-efi-configuration
@@ -55,6 +65,8 @@
   bootloader-configuration?
   (bootloader                      bootloader-configuration-bootloader     ; package
                                    (default #f))
+  (type                            bootloader-configuration-type
+                                   (default #f))                           ; symbol
   (device                          bootloader-configuration-device         ; string
                                    (default #f))
   (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
@@ -128,40 +140,6 @@ TIMEOUT ~a~%"
 \f
 
 ;;;
-;;; Bootloader configurations.
-;;;
-
-(define* (extlinux-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit config)
-   (configuration-file-location "/boot/extlinux/extlinux.conf")
-   (configuration-file-procedure extlinux-configuration-file)))
-
-(define* (grub-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit config)
-   (bootloader (@ (gnu packages bootloaders) grub))
-   (configuration-file-location "/boot/grub/grub.cfg")
-   (configuration-file-procedure grub-configuration-file)
-   (install-procedure install-grub)
-   (additional-configuration
-    (let ((additional-config (bootloader-configuration-additional-configuration config)))
-      (if additional-config additional-config %default-theme)))))
-
-(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit (grub-configuration config))
-   (bootloader (@ (gnu packages bootloaders) grub-efi))))
-
-(define* (syslinux-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit (extlinux-configuration config))
-   (bootloader (@ (gnu packages bootloaders) syslinux))
-   (install-procedure install-syslinux)))
-
-\f
-
-;;;
 ;;; Bootloader install procedures.
 ;;;
 
@@ -202,4 +180,74 @@ TIMEOUT ~a~%"
                      (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
           (error "failed to install SYSLINUX")))))
 
+
+;;;
+;;; Bootloader configurations.
+;;;
+
+(define* %extlinux-configuration
+  (bootloader-configuration
+   (type 'extlinux)
+   (configuration-file-location "/boot/extlinux/extlinux.conf")
+   (configuration-file-procedure extlinux-configuration-file)))
+
+(define* %grub-configuration
+  (bootloader-configuration
+   (type 'grub)
+   (bootloader (@ (gnu packages bootloaders) grub))
+   (configuration-file-location "/boot/grub/grub.cfg")
+   (configuration-file-procedure grub-configuration-file)
+   (install-procedure install-grub)
+   (additional-configuration %default-theme)))
+
+(define* %grub-efi-configuration
+  (bootloader-configuration
+   (inherit %grub-configuration)
+   (type 'grub-efi)
+   (bootloader (@ (gnu packages bootloaders) grub-efi))))
+
+(define* %syslinux-configuration
+  (bootloader-configuration
+   (inherit %extlinux-configuration)
+   (type 'syslinux)
+   (bootloader (@ (gnu packages bootloaders) syslinux))
+   (install-procedure install-syslinux)))
+
+(define %bootloader-configurations
+  (list %extlinux-configuration
+        %grub-configuration
+        %grub-efi-configuration
+        %syslinux-configuration))
+
+(define (lookup-bootloader-configuration type)
+  (or (find (lambda (conf)
+              (eq? (bootloader-configuration-type conf)
+                   type))
+            %bootloader-configurations)
+      (error "~a: unknown bootloader type" type)))
+
+;;;
+;;; Compatibility macros.
+;;;
+
+(define-syntax-rule (extlinux-configuration fields ...)
+  (bootloader-configuration
+   (inherit %extlinux-configuration)
+   fields ...))
+
+(define-syntax-rule (grub-configuration fields ...)
+  (bootloader-configuration
+   (inherit %grub-configuration)
+   fields ...))
+
+(define-syntax-rule (grub-efi-configuration fields ...)
+  (bootloader-configuration
+   (inherit %grub-efi-configuration)
+   fields ...))
+
+(define-syntax-rule (syslinux-configuration fields ...)
+  (bootloader-configuration
+   (inherit %syslinux-configuration)
+   fields ...))
+
 ;;; bootloader.scm ends here
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 08/18] bootloader: Stop using grub module.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (5 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 07/18] system: Add bootloader type Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 13:33     ` Danny Milosavljevic
  2017-04-15 16:44     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top Mathieu Othacehe
                     ` (13 subsequent siblings)
  20 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* gnu.scm (%public-modules): Replace grub by bootloader.
* gnu/tests.scm (define-module): Ditto.
* gnu/tests/nfs.scm (define-module): Ditto.
* gnu/tests/web.scm (define-module): Ditto.
---
 gnu.scm           | 3 ++-
 gnu/tests.scm     | 3 ++-
 gnu/tests/nfs.scm | 3 ++-
 gnu/tests/web.scm | 2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gnu.scm b/gnu.scm
index 932e4cdd5..56b84b74d 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Joshua S. Grant <jgrant@parenthetical.io>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,7 +35,7 @@
       '((gnu system)
         (gnu system mapped-devices)
         (gnu system file-systems)
-        (gnu system grub)                         ; 'grub-configuration'
+        (gnu system bootloader)
         (gnu system pam)
         (gnu system shadow)                       ; 'user-account'
         (gnu system linux-initrd)
diff --git a/gnu/tests.scm b/gnu/tests.scm
index e84d1ebb2..25c7c3fd3 100644
--- a/gnu/tests.scm
+++ b/gnu/tests.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,7 +22,7 @@
   #:use-module (guix utils)
   #:use-module (guix records)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu services)
diff --git a/gnu/tests/nfs.scm b/gnu/tests/nfs.scm
index 1f28f5a5b..432fc83a1 100644
--- a/gnu/tests/nfs.scm
+++ b/gnu/tests/nfs.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 John Darrington <jmd@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +21,7 @@
 (define-module (gnu tests nfs)
   #:use-module (gnu tests)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu system vm)
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index cdc579123..0e98a128c 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,7 +20,6 @@
 (define-module (gnu tests web)
   #:use-module (gnu tests)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu system vm)
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (6 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 08/18] bootloader: Stop using grub module Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 10:35     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 10/18] system: Rename kernel->grub-label to kernel->boot-label Mathieu Othacehe
                     ` (12 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (save-load-path-excursion,
save-environment-excursion): Move definitions to the top of the file.
It allows to use them in the whole file.
---
 guix/scripts/system.scm | 47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 04274919e..2ad210207 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +78,29 @@
 ;;; Installation.
 ;;;
 
+(define-syntax-rule (save-load-path-excursion body ...)
+  "Save the current values of '%load-path' and '%load-compiled-path', run
+BODY..., and restore them."
+  (let ((path %load-path)
+        (cpath %load-compiled-path))
+    (dynamic-wind
+      (const #t)
+      (lambda ()
+        body ...)
+      (lambda ()
+        (set! %load-path path)
+        (set! %load-compiled-path cpath)))))
+
+(define-syntax-rule (save-environment-excursion body ...)
+  "Save the current environment variables, run BODY..., and restore them."
+  (let ((env (environ)))
+    (dynamic-wind
+      (const #t)
+      (lambda ()
+        body ...)
+      (lambda ()
+        (environ env)))))
+
 (define topologically-sorted*
   (store-lift topologically-sorted))
 
@@ -201,29 +225,6 @@ the ownership of '~a' may be incorrect!~%")
   ;; The system profile.
   (string-append %state-directory "/profiles/system"))
 
-(define-syntax-rule (save-environment-excursion body ...)
-  "Save the current environment variables, run BODY..., and restore them."
-  (let ((env (environ)))
-    (dynamic-wind
-      (const #t)
-      (lambda ()
-        body ...)
-      (lambda ()
-        (environ env)))))
-
-(define-syntax-rule (save-load-path-excursion body ...)
-  "Save the current values of '%load-path' and '%load-compiled-path', run
-BODY..., and restore them."
-  (let ((path %load-path)
-        (cpath %load-compiled-path))
-    (dynamic-wind
-      (const #t)
-      (lambda ()
-        body ...)
-      (lambda ()
-        (set! %load-path path)
-        (set! %load-compiled-path cpath)))))
-
 (define-syntax-rule (with-shepherd-error-handling mbody ...)
   "Catch and report Shepherd errors that arise when binding MBODY, a monadic
 expression in %STORE-MONAD."
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 10/18] system: Rename kernel->grub-label to kernel->boot-label.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (7 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 10:40     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 11/18] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
                     ` (11 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (kernel->grub-label): Rename to kernel->boot-label.
(operating-system-grub.cfg): Adapt.
(operating-system-parameters-file): Ditto.
---
 gnu/system.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index a9b05806a..6c41fe814 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -702,8 +702,8 @@ listed in OS.  The C library expects to find it under
   (locale-directory definitions
                     #:libcs (operating-system-locale-libcs os)))
 
-(define (kernel->grub-label kernel)
-  "Return a label for the GRUB menu entry that boots KERNEL."
+(define (kernel->boot-label kernel)
+  "Return a label for the bootloader menu entry that boots KERNEL."
   (string-append "GNU with "
                  (string-titlecase (package-name kernel)) " "
                  (package-version kernel)
@@ -737,7 +737,7 @@ populate the \"old entries\" menu."
       ((system      (operating-system-derivation os))
        (root-fs ->  (operating-system-root-file-system os))
        (store-fs -> (operating-system-store-file-system os))
-       (label ->    (kernel->grub-label (operating-system-kernel os)))
+       (label ->    (kernel->boot-label (operating-system-kernel os)))
        (kernel ->   (operating-system-kernel-file os))
        (initrd      (operating-system-initrd-file os))
        (root-device -> (if (eq? 'uuid (file-system-title root-fs))
@@ -777,7 +777,7 @@ this file is the reconstruction of GRUB menu entries for old configurations."
   (mlet %store-monad ((initrd   (operating-system-initrd-file os))
                       (root ->  (operating-system-root-file-system os))
                       (store -> (operating-system-store-file-system os))
-                      (label -> (kernel->grub-label
+                      (label -> (kernel->boot-label
                                  (operating-system-kernel os))))
     (gexp->file "parameters"
                 #~(boot-parameters
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 11/18] bootloader: Add device and type to bootloader-configuration record.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (8 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 10/18] system: Rename kernel->grub-label to kernel->boot-label Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 12/18] system: Rename grub-device to fs->boot-device Mathieu Othacehe
                     ` (10 subsequent siblings)
  20 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (<boot-parameters>)[device, type]: New fields.
(boot-parameters-boot-device): New exported procedure.
(boot-parameters-boot-type): Ditto.
(operating-system-grub.cfg): Add new fields.
(operating-system-parameters-file): Add new fields and replace GRUB by
bootloader in doctype.
(read-boot-parameters): Ditto.

* gnu/system/bootloader.scm (extlinux-configuration-file): Adapt matching to
  new fields.
---
 gnu/system.scm            | 29 ++++++++++++++++++++++++++++-
 gnu/system/bootloader.scm |  2 +-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 6c41fe814..9775e5be8 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -105,6 +105,8 @@
             boot-parameters?
             boot-parameters-label
             boot-parameters-root-device
+            boot-parameters-boot-device
+            boot-parameters-boot-type
             boot-parameters-store-device
             boot-parameters-store-mount-point
             boot-parameters-kernel
@@ -736,8 +738,12 @@ populate the \"old entries\" menu."
   (mlet* %store-monad
       ((system      (operating-system-derivation os))
        (root-fs ->  (operating-system-root-file-system os))
+       (boot-device -> (bootloader-configuration-device
+                        (operating-system-bootloader os)))
        (store-fs -> (operating-system-store-file-system os))
        (label ->    (kernel->boot-label (operating-system-kernel os)))
+       (boot-type -> (bootloader-configuration-type
+                      (operating-system-bootloader os)))
        (kernel ->   (operating-system-kernel-file os))
        (initrd      (operating-system-initrd-file os))
        (root-device -> (if (eq? 'uuid (file-system-title root-fs))
@@ -746,12 +752,14 @@ populate the \"old entries\" menu."
        (entries ->  (list (boot-parameters
                            (label label)
                            (root-device root-device)
+                           (boot-device boot-device)
 
                            ;; The device where the kernel and initrd live.
                            (store-device (grub-device store-fs))
                            (store-mount-point
                             (file-system-mount-point store-fs))
 
+                           (boot-type boot-type)
                            (kernel kernel)
                            (kernel-arguments
                             (cons* (string-append "--root=" root-device)
@@ -773,10 +781,15 @@ device in a <menu-entry>."
 
 (define (operating-system-parameters-file os)
   "Return a file that describes the boot parameters of OS.  The primary use of
-this file is the reconstruction of GRUB menu entries for old configurations."
+this file is the reconstruction of bootloader menu entries for old
+configurations."
   (mlet %store-monad ((initrd   (operating-system-initrd-file os))
                       (root ->  (operating-system-root-file-system os))
+                      (boot-device -> (bootloader-configuration-device
+                                       (operating-system-bootloader os)))
                       (store -> (operating-system-store-file-system os))
+                      (boot-type -> (bootloader-configuration-type
+                                     (operating-system-bootloader os)))
                       (label -> (kernel->boot-label
                                  (operating-system-kernel os))))
     (gexp->file "parameters"
@@ -788,6 +801,8 @@ this file is the reconstruction of GRUB menu entries for old configurations."
                    (kernel-arguments
                     #$(operating-system-kernel-arguments os))
                    (initrd #$initrd)
+                   (boot-device #$boot-device)
+                   (boot-type #$boot-type)
                    (store
                     (device #$(grub-device store))
                     (mount-point #$(file-system-mount-point store))))
@@ -809,6 +824,8 @@ this file is the reconstruction of GRUB menu entries for old configurations."
   ;; exactly to the device field of the <file-system> object representing the
   ;; OS's root file system, so it might be a device path like "/dev/sda3".
   (root-device      boot-parameters-root-device)
+  (boot-device      boot-parameters-boot-device)
+  (boot-type        boot-parameters-boot-type)
   (store-device     boot-parameters-store-device)
   (store-mount-point boot-parameters-store-mount-point)
   (kernel           boot-parameters-kernel)
@@ -827,6 +844,16 @@ this file is the reconstruction of GRUB menu entries for old configurations."
       (label label)
       (root-device root)
 
+      (boot-device
+       (match (assq 'boot-device rest)
+         ((_ args) args)
+         (#f       #f))) ; for compatibility reasons.
+
+      (boot-type
+       (match (assq 'boot-type rest)
+         ((_ args) args)
+         (#f       'grub))) ; for compatibility reasons.
+
       ;; In the past, we would store the directory name of the kernel instead
       ;; of the absolute file name of its image.  Detect that and correct it.
       (kernel (if (string=? linux (direct-store-path linux))
diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
index c2b23c380..b4774792e 100644
--- a/gnu/system/bootloader.scm
+++ b/gnu/system/bootloader.scm
@@ -104,7 +104,7 @@ corresponding to old generations of the system."
 
   (define boot-parameters->gexp
     (match-lambda
-      (($ <boot-parameters> label _ _ _ kernel kernel-arguments initrd)
+      (($ <boot-parameters> label _ _ _ _ _ kernel kernel-arguments initrd)
        #~(format port "LABEL ~a
   MENU LABEL ~a
   KERNEL ~a
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 12/18] system: Rename grub-device to fs->boot-device.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (9 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 11/18] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 12:45     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 13/18] scripts: system: Remove unused variables Mathieu Othacehe
                     ` (9 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (grub-device): Rename to fs->boot-device,
(operating-system-grub.cfg): adapt,
(operating-system-parameters-file): ditto.
---
 gnu/system.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 9775e5be8..118816255 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -755,7 +755,7 @@ populate the \"old entries\" menu."
                            (boot-device boot-device)
 
                            ;; The device where the kernel and initrd live.
-                           (store-device (grub-device store-fs))
+                           (store-device (fs->boot-device store-fs))
                            (store-mount-point
                             (file-system-mount-point store-fs))
 
@@ -771,7 +771,7 @@ populate the \"old entries\" menu."
     ((bootloader-configuration-file-procedure (operating-system-bootloader os))
      (operating-system-bootloader os) entries #:old-entries old-entries)))
 
-(define (grub-device fs)
+(define (fs->boot-device fs)
   "Given FS, a <file-system> object, return a value suitable for use as the
 device in a <menu-entry>."
   (case (file-system-title fs)
@@ -804,7 +804,7 @@ configurations."
                    (boot-device #$boot-device)
                    (boot-type #$boot-type)
                    (store
-                    (device #$(grub-device store))
+                    (device #$(fs->boot-device store))
                     (mount-point #$(file-system-mount-point store))))
                 #:set-load-path? #f)))
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 13/18] scripts: system: Remove unused variables.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (10 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 12/18] system: Rename grub-device to fs->boot-device Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 14/18] scripts: system: Rename grub? and install-grub? to bootloader? and install-bootloader? Mathieu Othacehe
                     ` (8 subsequent siblings)
  20 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (profile-bootloader-entries): Remove root and
  root-device unused variables.
---
 guix/scripts/system.scm | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 2ad210207..d3118266e 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -371,11 +371,7 @@ NUMBERS, which is a list of generation numbers."
     (unless-file-not-found
      (let* ((file             (string-append system "/parameters"))
             (params           (call-with-input-file file
-                                read-boot-parameters))
-            (root             (boot-parameters-root-device params))
-            (root-device      (if (bytevector? root)
-                                  (uuid->string root)
-                                  root)))
+                                read-boot-parameters)))
        (boot-parameters
         (inherit params)
         (label (string-append (boot-parameters-label params) " (#"
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 14/18] scripts: system: Rename grub? and install-grub? to bootloader? and install-bootloader?.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (11 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 13/18] scripts: system: Remove unused variables Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 13:25     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 15/18] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
                     ` (7 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (perform-action): Rename grub? to bootloader,
(%options): rename install-grub? to install-bootloader?,
(%default-options): ditto,
(process-action): reindent and rename grub? to bootloader?.
---
 guix/scripts/system.scm | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index d3118266e..791cf1166 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -580,7 +580,7 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
     (warning (_ "Failing to do that may downgrade your system!~%"))))
 
 (define* (perform-action action os
-                         #:key grub? dry-run? derivations-only?
+                         #:key bootloader? dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '()))
@@ -767,7 +767,7 @@ Some ACTIONS support additional ARGS.\n"))
                                result)))
          (option '("no-bootloader") #f #f
                  (lambda (opt name arg result)
-                   (alist-cons 'install-grub? #f result)))
+                   (alist-cons 'install-bootloader? #f result)))
          (option '("full-boot") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'full-boot? #t result)))
@@ -801,7 +801,7 @@ Some ACTIONS support additional ARGS.\n"))
     (max-silent-time . 3600)
     (verbosity . 0)
     (image-size . ,(* 900 (expt 2 20)))
-    (install-grub? . #t)))
+    (install-bootloader? . #t)))
 
 \f
 ;;;
@@ -813,23 +813,23 @@ Some ACTIONS support additional ARGS.\n"))
 ACTION must be one of the sub-commands that takes an operating system
 declaration as an argument (a file name.)  OPTS is the raw alist of options
 resulting from command-line parsing."
-  (let* ((file     (match args
-                     (() #f)
-                     ((x . _) x)))
-         (system   (assoc-ref opts 'system))
-         (os       (if file
-                       (load* file %user-module
-                              #:on-error (assoc-ref opts 'on-error))
-                       (leave (_ "no configuration file specified~%"))))
-
-         (dry?     (assoc-ref opts 'dry-run?))
-         (grub?    (assoc-ref opts 'install-grub?))
-         (target   (match args
-                     ((first second) second)
-                     (_ #f)))
-         (device   (and grub?
-                        (bootloader-configuration-device
-                         (operating-system-bootloader os)))))
+  (let* ((file        (match args
+                        (() #f)
+                        ((x . _) x)))
+         (system      (assoc-ref opts 'system))
+         (os          (if file
+                          (load* file %user-module
+                                 #:on-error (assoc-ref opts 'on-error))
+                          (leave (_ "no configuration file specified~%"))))
+
+         (dry?        (assoc-ref opts 'dry-run?))
+         (bootloader? (assoc-ref opts 'install-bootloader?))
+         (target      (match args
+                        ((first second) second)
+                        (_ #f)))
+         (device      (and bootloader?
+                           (bootloader-configuration-device
+                            (operating-system-bootloader os)))))
 
     (with-store store
       (set-build-options-from-command-line store opts)
@@ -855,7 +855,7 @@ resulting from command-line parsing."
                                                        m)
                                                       (_ #f))
                                                     opts)
-                             #:grub? grub?
+                             #:bootloader? bootloader?
                              #:target target #:device device))))
         #:system system))))
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 15/18] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (12 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 14/18] scripts: system: Rename grub? and install-grub? to bootloader? and install-bootloader? Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 16/18] scripts: system: Adapt "init" " Mathieu Othacehe
                     ` (6 subsequent siblings)
  20 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install-grub*): Rename to install-bootloader. Use
  keys to pass arguments. Pass a new argument, "install-procedure" which is
  a script in store dealing with bootloader-specific install actions.
  Also call "install-boot-config" to install the bootloader config file.
(install-bootloader-derivation): New procedure. It returns a derivation that
builds a file containing "install-procedure" gexp.
(perform-action): Build install-proc derivation and call install-bootloader
with the resulting file. Stop adding GRUB to PATH as bootloaders are called in
install-proc with direct store paths.
---
 guix/scripts/system.scm | 116 ++++++++++++++++++++++++++++--------------------
 1 file changed, 69 insertions(+), 47 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 791cf1166..9f1d4f95c 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -147,27 +147,34 @@ TARGET, and register them."
               (map (cut copy-item <> target #:log-port log-port)
                    to-copy))))
 
-(define (install-grub* grub.cfg device target)
-  "This is a variant of 'install-grub' with error handling, lifted in
-%STORE-MONAD"
-  (let* ((gc-root      (string-append target %gc-roots-directory
-                                      "/grub.cfg"))
-         (temp-gc-root (string-append gc-root ".new"))
-         (delete-file  (lift1 delete-file %store-monad))
-         (make-symlink (lift2 switch-symlinks %store-monad))
-         (rename       (lift2 rename-file %store-monad)))
-    (mbegin %store-monad
-      ;; Prepare the symlink to GRUB.CFG to make sure that it's a GC root when
-      ;; 'install-grub' completes (being a bit paranoid.)
-      (make-symlink temp-gc-root grub.cfg)
-
-      (munless (false-if-exception (install-grub grub.cfg device target))
+(define* (install-bootloader install-procedure
+                             #:key
+                             bootcfg bootcfg-location
+                             device target)
+  "Call INSTALL-PROCEDURE with error handling, in %STORE-MONAD."
+  (with-monad %store-monad
+    (let* ((gc-root      (string-append target %gc-roots-directory
+                                        "/bootcfg"))
+           (temp-gc-root (string-append gc-root ".new"))
+           (install (and install-procedure
+                         (derivation->output-path install-procedure)))
+           (bootcfg (derivation->output-path bootcfg)))
+      ;; Prepare the symlink to bootloader config file to make sure that it's
+      ;; a GC root when 'install-procedure' completes (being a bit paranoid.)
+      (switch-symlinks temp-gc-root bootcfg)
+
+      (unless (false-if-exception
+               (begin
+                 (install-boot-config bootcfg bootcfg-location target)
+                 (when install
+                   (save-load-path-excursion (primitive-load install)))))
         (delete-file temp-gc-root)
-        (leave (_ "failed to install GRUB on device '~a'~%") device))
+        (leave (_ "failed to install bootloader on device ~a '~a'~%") install device))
 
-      ;; Register GRUB.CFG as a GC root so that its dependencies (background
-      ;; image, font, etc.) are not reclaimed.
-      (rename temp-gc-root gc-root))))
+      ;; Register bootloader config file as a GC root so that its dependencies
+      ;; (background image, font, etc.) are not reclaimed.
+      (rename-file temp-gc-root gc-root)
+      (return #t))))
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
@@ -579,16 +586,27 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
     (warning (_ "Consider running 'guix pull' before 'reconfigure'.~%"))
     (warning (_ "Failing to do that may downgrade your system!~%"))))
 
+(define (install-bootloader-derivation install-procedure
+                                       bootloader device target)
+  (with-monad %store-monad
+    (gexp->file "install-bootloader"
+                (with-imported-modules '((guix build utils))
+                  #~(begin
+                      (use-modules (guix build utils))
+                      (#$install-procedure #$bootloader
+                                           #$device
+                                           #$target))))))
+
 (define* (perform-action action os
                          #:key bootloader? dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '()))
-  "Perform ACTION for OS.  GRUB? specifies whether to install GRUB; DEVICE is
-the target devices for GRUB; TARGET is the target root directory; IMAGE-SIZE
-is the size of the image to be built, for the 'vm-image' and 'disk-image'
-actions.  FULL-BOOT? is used for the 'vm' action; it determines whether to
-boot directly to the kernel or to the bootloader.
+  "Perform ACTION for OS.  BOOTLOADER? specifies whether to install
+bootloader; DEVICE is the target devices for bootloader; TARGET is the target
+root directory; IMAGE-SIZE is the size of the image to be built, for the
+'vm-image' and 'disk-image' actions.  FULL-BOOT? is used for the 'vm' action;
+it determines whether to boot directly to the kernel or to the bootloader.
 
 When DERIVATIONS-ONLY? is true, print the derivation file name(s) without
 building anything."
@@ -608,20 +626,28 @@ building anything."
                      (if bootloader
                          (package->derivation bootloader)
                          (return #f))))
-       (grub.cfg  (if (eq? 'container action)
-                      (return #f)
-                      (operating-system-grub.cfg os
-                                                 (if (eq? 'init action)
-                                                     '()
-                                                     (profile-grub-entries)))))
-
-       ;; For 'init' and 'reconfigure', always build GRUB.CFG, even if
-       ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
-       ;; root.  See <http://bugs.gnu.org/21068>.
+       (bootcfg  (if (eq? 'container action)
+                     (return #f)
+                     (operating-system-bootcfg
+                      os
+                      (if (eq? 'init action)
+                          '()
+                          (profile-bootloader-entries)))))
+       (bootcfg-location -> (bootloader-configuration-file-location
+                             (operating-system-bootloader os)))
+       (install-proc
+        (let ((procedure (bootloader-configuration-install-procedure
+                          (operating-system-bootloader os)))
+              (target    (or target "/")))
+          (install-bootloader-derivation procedure bootloader device target)))
+
+       ;; For 'init' and 'reconfigure', always build BOOTCFG, even if
+       ;; --no-bootloader is passed, because we then use it as a GC root.
+       ;; See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if (and grub? bootloader)
-                          (list sys grub.cfg bootloader)
-                          (list sys grub.cfg))
+                      (if (and bootloader? bootloader)
+                          (list sys bootcfg bootloader install-proc)
+                          (list sys bootcfg))
                       (list sys)))
        (%         (if derivations-only?
                       (return (for-each (compose println derivation-file-name)
@@ -635,20 +661,16 @@ building anything."
           (for-each (compose println derivation->output-path)
                     drvs)
 
-          ;; Make sure GRUB is accessible.
-          (when (and grub? bootloader)
-            (let ((prefix (derivation->output-path bootloader)))
-              (setenv "PATH"
-                      (string-append  prefix "/bin:" prefix "/sbin:"
-                                      (getenv "PATH")))))
-
           (case action
             ((reconfigure)
              (mbegin %store-monad
                (switch-to-system os)
-               (mwhen grub?
-                 (install-grub* (derivation->output-path grub.cfg)
-                                device "/"))))
+               (mwhen bootloader?
+                 (install-bootloader install-proc
+                                     #:bootcfg bootcfg
+                                     #:bootcfg-location bootcfg-location
+                                     #:device device
+                                     #:target "/"))))
             ((init)
              (newline)
              (format #t (_ "initializing operating system under '~a'...~%")
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 16/18] scripts: system: Adapt "init" to new bootloader API.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (13 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 15/18] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-02 13:52   ` bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
                     ` (5 subsequent siblings)
  20 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install): Pass install-proc as a new
argument. Rename other arguments.
Call install-bootloader instead of install-grub*.
(perform-action): Adapt.
---
 guix/scripts/system.scm | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 9f1d4f95c..560115ec3 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -178,12 +178,14 @@ TARGET, and register them."
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
-                  grub? grub.cfg device)
-  "Copy the closure of GRUB.CFG, which includes the output of OS-DRV, to
+                  install-proc bootloader?
+                  bootcfg bootcfg-location
+                  device)
+  "Copy the closure of BOOTCFG, which includes the output of OS-DRV, to
 directory TARGET.  TARGET must be an absolute directory name since that's what
 'guix-register' expects.
 
-When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG."
+When BOOTLOADER? is true, install bootloader on DEVICE, using BOOTCFG."
   (define (maybe-copy to-copy)
     (with-monad %store-monad
       (if (string=? target "/")
@@ -212,16 +214,21 @@ the ownership of '~a' may be incorrect!~%")
         (populate (lift2 populate-root-file-system %store-monad)))
 
     (mbegin %store-monad
-      ;; Copy the closure of GRUB.CFG, which includes OS-DIR, GRUB's
-      ;; background image and so on.
-      (maybe-copy grub.cfg)
+      ;; Copy the closure of BOOTCFG, which includes OS-DIR,
+      ;; eventual background image and so on.
+      (maybe-copy
+       (derivation->output-path bootcfg))
 
       ;; Create a bunch of additional files.
       (format log-port "populating '~a'...~%" target)
       (populate os-dir target)
 
-      (mwhen grub?
-        (install-grub* grub.cfg device target)))))
+      (mwhen bootloader?
+        (install-bootloader install-proc
+                            #:bootcfg bootcfg
+                            #:bootcfg-location bootcfg-location
+                            #:device device
+                            #:target target)))))
 
 \f
 ;;;
@@ -676,8 +683,10 @@ building anything."
              (format #t (_ "initializing operating system under '~a'...~%")
                      target)
              (install sys (canonicalize-path target)
-                      #:grub? grub?
-                      #:grub.cfg (derivation->output-path grub.cfg)
+                      #:bootloader? bootloader?
+                      #:bootcfg bootcfg
+                      #:bootcfg-location bootcfg-location
+                      #:install-proc install-proc
                       #:device device))
             (else
              ;; All we had to do was to build SYS.
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (14 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 16/18] scripts: system: Adapt "init" " Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-15 16:47     ` Danny Milosavljevic
  2017-04-02 13:52   ` bug#26339: [PATCH 18/18] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
                     ` (4 subsequent siblings)
  20 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (profile-grub-entries): Rename to
  profile-bootloader-entries.
  (reinstall-grub): Rename to reinstall-bootloader. Read boot-device and
  boot-type from parameters file to be able to restore the correct bootloader
  on specified device.
  Factorize bootloader installation code by calling install-bootloader.
 (switch-to-system-generation): Adapt.
---
 guix/scripts/system.scm | 73 +++++++++++++++++++++++++++++--------------------
 1 file changed, 43 insertions(+), 30 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 560115ec3..400152d6d 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -377,8 +377,8 @@ it atomically, and then run OS's activation script."
     (date->string (time-utc->date time)
                   "~Y-~m-~d ~H:~M")))
 
-(define* (profile-grub-entries #:optional (profile %system-profile)
-                                  (numbers (generation-numbers profile)))
+(define* (profile-bootloader-entries #:optional (profile %system-profile)
+                                     (numbers (generation-numbers profile)))
   "Return a list of 'menu-entry' for the generations of PROFILE specified by
 NUMBERS, which is a list of generation numbers."
   (define (system->boot-parameters system number time)
@@ -419,50 +419,63 @@ connection to the store."
 ;;;
 (define (switch-to-system-generation store spec)
   "Switch the system profile to the generation specified by SPEC, and
-re-install grub with a grub configuration file that uses the specified system
+re-install bootloader with a configuration file that uses the specified system
 generation as its default entry.  STORE is an open connection to the store."
   (let ((number (relative-generation-spec->number %system-profile spec)))
     (if number
         (begin
-          (reinstall-grub store number)
+          (reinstall-bootloader store number)
           (switch-to-generation* %system-profile number))
         (leave (_ "cannot switch to system generation '~a'~%") spec))))
 
-(define (reinstall-grub store number)
-  "Re-install grub for existing system profile generation NUMBER.  STORE is an
-open connection to the store."
+(define (reinstall-bootloader store number)
+  "Re-install bootloader for existing system profile generation NUMBER.
+STORE is an open connection to the store."
   (let* ((generation (generation-file-name %system-profile number))
          (file (string-append generation "/parameters"))
          (params (unless-file-not-found
                   (call-with-input-file file read-boot-parameters)))
-         (root-device (boot-parameters-root-device params))
+         (boot-device (boot-parameters-boot-device params))
          ;; We don't currently keep track of past menu entries' details.  The
          ;; default values will allow the system to boot, even if they differ
          ;; from the actual past values for this generation's entry.
-         (grub-config (grub-configuration (device root-device)))
+         (boot-config (bootloader-configuration
+                       (inherit (lookup-bootloader-configuration
+                                 (boot-parameters-boot-type params)))
+                       (device boot-device)))
          ;; Make the specified system generation the default entry.
-         (entries (profile-grub-entries %system-profile (list number)))
+         (entries (profile-bootloader-entries %system-profile (list number)))
          (old-generations (delv number (generation-numbers %system-profile)))
-         (old-entries (profile-grub-entries %system-profile old-generations))
-         (grub.cfg (run-with-store store
-                     (grub-configuration-file grub-config
-                                              entries
-                                              #:old-entries old-entries))))
-    (show-what-to-build store (list grub.cfg))
-    (build-derivations store (list grub.cfg))
-    ;; This is basically the same as install-grub*, but for now we avoid
-    ;; re-installing the GRUB boot loader itself onto a device, mainly because
-    ;; we don't in general have access to the same version of the GRUB package
-    ;; which was used when installing this other system generation.
-    (let* ((grub.cfg-path (derivation->output-path grub.cfg))
-           (gc-root (string-append %gc-roots-directory "/grub.cfg"))
-           (temp-gc-root (string-append gc-root ".new")))
-      (switch-symlinks temp-gc-root grub.cfg-path)
-      (unless (false-if-exception (install-grub-config grub.cfg-path "/"))
-        (delete-file temp-gc-root)
-        (leave (_ "failed to re-install GRUB configuration file: '~a'~%")
-               grub.cfg-path))
-      (rename-file temp-gc-root gc-root))))
+         (old-entries (profile-bootloader-entries
+                       %system-profile old-generations)))
+    (run-with-store store
+      (mlet* %store-monad
+          ((bootcfg ((bootloader-configuration-file-procedure boot-config)
+                     boot-config entries
+                     #:old-entries old-entries))
+           (bootcfg-location -> (bootloader-configuration-file-location
+                                 boot-config))
+           (bootloader (package->derivation
+                        (bootloader-configuration-bootloader boot-config)))
+           (target -> "/")
+           (install-proc
+            (let ((procedure (bootloader-configuration-install-procedure
+                              boot-config)))
+              (install-bootloader-derivation
+               procedure bootloader boot-device target)))
+           (drvs -> (list bootcfg bootloader install-proc)))
+        (mbegin %store-monad
+          (show-what-to-build* drvs)
+          (built-derivations drvs)
+          ;; PARAMS file may not contain a suitable BOOT-DEVICE. If BOOT-DEVICE
+          ;; is #f do not run INSTALL-PROC during bootloader installation.
+          (install-bootloader (if boot-device
+                                  install-proc
+                                  #f)
+                              #:bootcfg bootcfg
+                              #:bootcfg-location bootcfg-location
+                              #:device boot-device
+                              #:target target))))))
 
 \f
 ;;;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 18/18] scripts: system: Display bootloader device and type in "list-generations".
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (15 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
@ 2017-04-02 13:52   ` Mathieu Othacehe
  2017-04-02 18:24   ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub David Craven
                     ` (3 subsequent siblings)
  20 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-02 13:52 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (display-system-generation): Display bootloader
  device and bootloader type.
---
 guix/scripts/system.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 400152d6d..df45e491c 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -534,17 +534,21 @@ list of services."
            (param-file  (string-append generation "/parameters"))
            (params      (call-with-input-file param-file read-boot-parameters))
            (label       (boot-parameters-label params))
+           (boot-type   (boot-parameters-boot-type params))
            (root        (boot-parameters-root-device params))
            (root-device (if (bytevector? root)
                             (uuid->string root)
                             root))
+           (boot-device (boot-parameters-boot-device params))
            (kernel      (boot-parameters-kernel params)))
       (display-generation profile number)
       (format #t (_ "  file name: ~a~%") generation)
       (format #t (_ "  canonical file name: ~a~%") (readlink* generation))
       ;; TRANSLATORS: Please preserve the two-space indentation.
       (format #t (_ "  label: ~a~%") label)
+      (format #t (_ "  bootloader type: ~a~%") boot-type)
       (format #t (_ "  root device: ~a~%") root-device)
+      (format #t (_ "  boot device: ~a~%") boot-device)
       (format #t (_ "  kernel: ~a~%") kernel))))
 
 (define* (list-generations pattern #:optional (profile %system-profile))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (16 preceding siblings ...)
  2017-04-02 13:52   ` bug#26339: [PATCH 18/18] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
@ 2017-04-02 18:24   ` David Craven
  2017-04-15 13:04   ` Danny Milosavljevic
                     ` (2 subsequent siblings)
  20 siblings, 0 replies; 204+ messages in thread
From: David Craven @ 2017-04-02 18:24 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Nice...

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 03/18] scripts: system: Rename --no-grub option to --no-bootloader.
  2017-04-02 13:52   ` bug#26339: [PATCH 03/18] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
@ 2017-04-15 10:10     ` Danny Milosavljevic
  2017-04-16  9:58       ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 10:10 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi,

> -         (option '("no-grub") #f #f
> +         (option '("no-bootloader") #f #f

I'd prefer if it accepted both options - for backward compatibility.  We don't know what scripts people use on top of guix - and it's likely that many user scripts already pass "--no-grub", especially since the less-dangerous choice is to pass it (as opposed to not pass it).  There is no harm in supporting both options.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top.
  2017-04-02 13:52   ` bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top Mathieu Othacehe
@ 2017-04-15 10:35     ` Danny Milosavljevic
  2017-04-15 10:46       ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 10:35 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

I applied this one patch to master as a41134b44219a0aadbad4445586c571b0fbffbbd.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 10/18] system: Rename kernel->grub-label to kernel->boot-label.
  2017-04-02 13:52   ` bug#26339: [PATCH 10/18] system: Rename kernel->grub-label to kernel->boot-label Mathieu Othacehe
@ 2017-04-15 10:40     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 10:40 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Pushed this patch to master as c2e9942b8fc8918c3e1d9612f99bea06be9ff81d.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top.
  2017-04-15 10:35     ` Danny Milosavljevic
@ 2017-04-15 10:46       ` Mathieu Othacehe
  2017-04-15 11:30         ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-15 10:46 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> I applied this one patch to master as a41134b44219a0aadbad4445586c571b0fbffbbd.

Thank you, but there might have been a problem somewhere, the commit
a41134b44219a0aadbad4445586c571b0fbffbbd only contains one copyright
line.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top.
  2017-04-15 10:46       ` Mathieu Othacehe
@ 2017-04-15 11:30         ` Danny Milosavljevic
  2017-04-15 11:41           ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 11:30 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

On Sat, 15 Apr 2017 12:46:16 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> > I applied this one patch to master as a41134b44219a0aadbad4445586c571b0fbffbbd.  
> 
> Thank you, but there might have been a problem somewhere, the commit
> a41134b44219a0aadbad4445586c571b0fbffbbd only contains one copyright
> line.

Yes, sorry.  Added follow-up commit 475e2ce211ac05a814c1f1bc2b9648baa17ad369.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top.
  2017-04-15 11:30         ` Danny Milosavljevic
@ 2017-04-15 11:41           ` Mathieu Othacehe
  2017-04-15 11:52             ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-15 11:41 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> Yes, sorry.  Added follow-up commit 475e2ce211ac05a814c1f1bc2b9648baa17ad369.

Thanks, there's still a small problem,

The renaming operating-system-grub.cfg -> operating-system-bootcfg was
introduced by mistake in commit 475e2ce.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top.
  2017-04-15 11:41           ` Mathieu Othacehe
@ 2017-04-15 11:52             ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 11:52 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi,

On Sat, 15 Apr 2017 13:41:40 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> The renaming operating-system-grub.cfg -> operating-system-bootcfg was
> introduced by mistake in commit 475e2ce.

Yeah, follow-up commit fe05cadf2d45e757f517ea94e68dfa4ede47a347 fixes it.  Thanks!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 06/18] vm: Reword grub.cfg to boot.cfg
  2017-04-02 13:52   ` bug#26339: [PATCH 06/18] vm: Reword grub.cfg to boot.cfg Mathieu Othacehe
@ 2017-04-15 12:43     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 12:43 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Applied a variant of this patch as 07f812c404cd05dcac0d2801ad476f6e367ca6d4.

Changes are:
- Changed context to make it apply without #:bootcfg.drv .

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 05/18] system: Rename operating-system-grub.cfg to operating-system-bootcfg.
  2017-04-02 13:52   ` bug#26339: [PATCH 05/18] system: Rename operating-system-grub.cfg to operating-system-bootcfg Mathieu Othacehe
@ 2017-04-15 12:44     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 12:44 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Commited a variant of this patch as c76b3046f651e8f46db1a093fdfc78cdc0bc3a13.

Changes are:
- Also adapt gnu/system/vm.scm and guix/scripts/system.scm to use operating-system-bootcfg (in order to make this patch apply independently).

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 12/18] system: Rename grub-device to fs->boot-device.
  2017-04-02 13:52   ` bug#26339: [PATCH 12/18] system: Rename grub-device to fs->boot-device Mathieu Othacehe
@ 2017-04-15 12:45     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 12:45 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Pushed a variant of this patch as 7085ca9690f6b3838ae3dc0f832c30e41681e835.

Changes are:
- Minimal changes to make it apply independently.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (17 preceding siblings ...)
  2017-04-02 18:24   ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub David Craven
@ 2017-04-15 13:04   ` Danny Milosavljevic
  2017-04-15 13:58   ` Danny Milosavljevic
  2017-04-15 20:17   ` Danny Milosavljevic
  20 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 13:04 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi,

> +            <boot-parameters>

I think it's disadvantageous to export the entire structure.  It makes the memory layout public and also makes us unable to replace it by a shim easily later - if we ever want to.

> +(define (boot-parameters->menu-entry conf)
> +  (menu-entry
> +   (label (boot-parameters-label conf))
> +   (device (boot-parameters-store-device conf))
> +   (device-mount-point (boot-parameters-store-mount-point conf))
> +   (linux (boot-parameters-kernel conf))
> +   (linux-arguments (boot-parameters-kernel-arguments conf))
> +   (initrd (boot-parameters-initrd conf))))

I think this way of using boot-parameters is good and also doesn't need the <boot-parameters> export above.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 14/18] scripts: system: Rename grub? and install-grub? to bootloader? and install-bootloader?.
  2017-04-02 13:52   ` bug#26339: [PATCH 14/18] scripts: system: Rename grub? and install-grub? to bootloader? and install-bootloader? Mathieu Othacehe
@ 2017-04-15 13:25     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 13:25 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Pushed a variant of this as e61519ab9c26b2309c84b65456c4ee5cd4d2c163 to master.

Changes are:
- Still use grub-configuration-device instead of bootloader-configuration-device (in order to make it apply independently).
- Still use "--no-grub" command line option.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 08/18] bootloader: Stop using grub module.
  2017-04-02 13:52   ` bug#26339: [PATCH 08/18] bootloader: Stop using grub module Mathieu Othacehe
@ 2017-04-15 13:33     ` Danny Milosavljevic
  2017-04-15 16:44     ` Danny Milosavljevic
  1 sibling, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 13:33 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339


> diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
> index cdc579123..0e98a128c 100644
> --- a/gnu/tests/web.scm
> +++ b/gnu/tests/web.scm
> @@ -1,5 +1,6 @@
>  ;;; GNU Guix --- Functional package management for GNU
>  ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
> +;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -19,7 +20,6 @@
>  (define-module (gnu tests web)
>    #:use-module (gnu tests)
>    #:use-module (gnu system)
> -  #:use-module (gnu system grub)
>    #:use-module (gnu system file-systems)
>    #:use-module (gnu system shadow)
>    #:use-module (gnu system vm)

Applied only this chunk as 99828febe05663c5d93dc52594eab28c6a1fe3d8 to master.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (18 preceding siblings ...)
  2017-04-15 13:04   ` Danny Milosavljevic
@ 2017-04-15 13:58   ` Danny Milosavljevic
  2017-04-15 15:39     ` Danny Milosavljevic
  2017-04-15 20:17   ` Danny Milosavljevic
  20 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 13:58 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
> index 4f9bde6a6..f2838d633 100644
> --- a/gnu/system/grub.scm
> +++ b/gnu/system/grub.scm
> @@ -298,9 +309,9 @@ corresponding to old generations of the system."
>                    #$initrd)))))
>  
>    (mlet %store-monad ((sugar (eye-candy config
> -                                        (menu-entry-device (first entries))
> +                                        (menu-entry-device (first all-entries))
>                                          (menu-entry-device-mount-point
> -                                         (first entries))
> +                                         (first all-entries))
>                                          #:system system
>                                          #:port #~port)))
>      (define builder

... oops.  (first entries) could indeed fail if the list of profile generations is empty.  That shouldn't happen but anyway, the new way is safer.

Applied only this chunk to master as 0ab1e8ae8892c92fd7a1fd07430ba6f2b710668d.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub.
  2017-04-15 13:58   ` Danny Milosavljevic
@ 2017-04-15 15:39     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 15:39 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

I've also applied the remainder of that patch in commit 2e58e05bb68d4b747882cfa2b460b132d456f54a to master now.

This introduces a structure <boot-parameters> that can be used to specify boot parameters in a grub-independent way. (gnu system grub) will then load the data from that into its own structure <menu-entry>.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-04-02 13:52   ` bug#26339: [PATCH 02/18] system: Add extlinux support Mathieu Othacehe
@ 2017-04-15 16:03     ` Danny Milosavljevic
  2017-05-08 20:06     ` Ludovic Courtès
  1 sibling, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 16:03 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> +            bootloader-configuration-file-location

In my opinion in UNIX such a thing is called a "file name", so how about

    bootloader-configururation-file-name

?

> +            bootloader-configuration-file-procedure

How about

  bootloader-configuration-file-generator

Or

  bootloader-configuration-file-generation-procedure


?

> +            bootloader-configuration-install-procedure

How about

  bootloader-configuration-installer

or

  bootloader-configuration-installation-procedure 

?

> +    (match-lambda
> +      (($ <boot-parameters> label _ _ _ kernel kernel-arguments initrd)
> +       #~(format port "LABEL ~a
> +  MENU LABEL ~a
> +  KERNEL ~a
> +  FDTDIR ~a/lib/dtbs
> +  INITRD ~a
> +  APPEND ~a
> +~%"
> +                 #$label #$label
> +                 #$kernel #$kernel #$initrd
> +                 (string-join (list #$@kernel-arguments))))))

I think it would be better to use the field accessor procedures.

> +                    (* 10 timeout))

Magical conversion? Could use a comment...

Remainder of the patch LGTM.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them.
  2017-04-02 13:52   ` bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them Mathieu Othacehe
@ 2017-04-15 16:22     ` Danny Milosavljevic
  2017-04-15 17:15       ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 16:22 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> +    (symlink bootcfg (string-append directory "/bootcfg"))))
                                                   ^^^^^^^

Is that safe? Will there only be one bootloader configuration at all times? What if the user uses multiple "guix system"s on the same machine?

> +    (install-boot-config bootcfg bootcfg-location target)
> +    (when install-bootloader
> +      (install-bootloader bootloader device target))

I think it's very good to finally seperate installation of the bootloader configuration and installation of the bootloader.  On some architectures (for example ARM) it's very uncommon to replace the bootloader - and if you do it too often it would wear out the flash storage prematurely.

>[exports]
> +            dd

Errrr... was that exported on purpose? Sounds very implementation-detaily to me.

> +                                   #:install-bootloader

Rather #:bootloader-installer or #:bootloader-installation ?  Or leave it as is, doesn't matter much, I guess.  I think a non-substantive for this is strange.

> +                                   #$(bootloader-configuration-install-procedure

If it's not installing a procedure it should be bootloader-configuration-installation-procedure or bootloader-configuration-installer, I think.

Otherwise LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 07/18] system: Add bootloader type.
  2017-04-02 13:52   ` bug#26339: [PATCH 07/18] system: Add bootloader type Mathieu Othacehe
@ 2017-04-15 16:26     ` Danny Milosavljevic
  2017-04-15 17:23       ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 16:26 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM mostly.  <Insert same comment about the same names as in the other patches>

> -(define* (grub-configuration #:optional (config (bootloader-configuration)))
> -  (bootloader-configuration
> -   (inherit config)
> -   (bootloader (@ (gnu packages bootloaders) grub))

Hmm.  Does that mean the user can't replace the bootloader package in the configuration?

> -(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
> -  (bootloader-configuration
> -   (inherit (grub-configuration config))
> -   (bootloader (@ (gnu packages bootloaders) grub-efi))))

Oh, so that's how.  I think it would be nice-to-have if the user could also override the bootloader package used.

> -   (install-procedure install-syslinux)))

Wait, so install-syslinux wouldn't need to be exported from this module at all, right?

Still nice that the user can use it - though is it worth exposing the installers?

Otherwise LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 08/18] bootloader: Stop using grub module.
  2017-04-02 13:52   ` bug#26339: [PATCH 08/18] bootloader: Stop using grub module Mathieu Othacehe
  2017-04-15 13:33     ` Danny Milosavljevic
@ 2017-04-15 16:44     ` Danny Milosavljevic
  1 sibling, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 16:44 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM.  Holding off merging that patch until some other patches that patch needs in the series were merged.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-04-02 13:52   ` bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
@ 2017-04-15 16:47     ` Danny Milosavljevic
  2017-04-15 17:27       ` Mathieu Othacehe
  2017-04-15 18:17       ` problem with commit abae042 Mathieu Othacehe
  0 siblings, 2 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 16:47 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

On Sun,  2 Apr 2017 15:52:41 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> * guix/scripts/system.scm (profile-grub-entries): [...]
>   (reinstall-grub): Rename to reinstall-bootloader. Read boot-device and
>   boot-type from parameters file to be able to restore the correct bootloader
>   on specified device.

Wait.  So that's the only reason for boot-type ?  I guess it works like that too, but couldn't we check the operating-system bootloader-configuration directly ?  Or is it for something completely different ?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them.
  2017-04-15 16:22     ` Danny Milosavljevic
@ 2017-04-15 17:15       ` Mathieu Othacehe
  2017-04-16 21:37         ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-15 17:15 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> Is that safe? Will there only be one bootloader configuration at all times? What if the user uses multiple "guix system"s on the same machine?

Well you can have only one bootloader in MBR at a time, so even if you
have multiple system generations with various bootloaders, only one is
installed. But I might be wrong here ...

>> +            dd
>
> Errrr... was that exported on purpose? Sounds very implementation-detaily to me.

Yes you're right, no need to export dd.

> Rather #:bootloader-installer or #:bootloader-installation ?  Or leave it as is, doesn't matter much, I guess.  I think a non-substantive for this is strange.

#:bootloader-installer seems fine, I'll update.

>
>> +                                   #$(bootloader-configuration-install-procedure
>
> If it's not installing a procedure it should be bootloader-configuration-installation-procedure or bootloader-configuration-installer, I think.

Ok for bootloader-configuration-installer then.

>
> Otherwise LGTM!

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 07/18] system: Add bootloader type.
  2017-04-15 16:26     ` Danny Milosavljevic
@ 2017-04-15 17:23       ` Mathieu Othacehe
  2017-04-15 20:16         ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-15 17:23 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> Oh, so that's how.  I think it would be nice-to-have if the user could also override the bootloader package used.

The user could already write :

--8<---------------cut here---------------start------------->8---
(bootloader-configuration
 (inherit %grub-configuration)
 (bootloader my-grub))
--8<---------------cut here---------------end--------------->8---

Or am I wrong here ?

>
>> -   (install-procedure install-syslinux)))
>
> Wait, so install-syslinux wouldn't need to be exported from this module at all, right?
>
> Still nice that the user can use it - though is it worth exposing the installers?

I'm not sure here, maybe not exposing installers would be better here.

>
> Otherwise LGTM!

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-04-15 16:47     ` Danny Milosavljevic
@ 2017-04-15 17:27       ` Mathieu Othacehe
  2017-05-05  7:13         ` Danny Milosavljevic
  2017-04-15 18:17       ` problem with commit abae042 Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-15 17:27 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Thanks again for your patience Danny !

> Wait.  So that's the only reason for boot-type ?  I guess it works like that too, but couldn't we check the operating-system bootloader-configuration directly ?  Or is it for something completely different ?

Yes my idea was to use the boot-type to keep track of the installed
bootloader, for each system generation (and to restore it if needed).

I tried to find a better idea but I didn't. I'm not sure what you mean
by checking "bootloader-configuration" ?

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* problem with commit abae042
  2017-04-15 16:47     ` Danny Milosavljevic
  2017-04-15 17:27       ` Mathieu Othacehe
@ 2017-04-15 18:17       ` Mathieu Othacehe
  2017-04-15 18:56         ` Danny Milosavljevic
                           ` (2 more replies)
  1 sibling, 3 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-15 18:17 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339, guix-devel


I think there's a problem with commit abae042 :

* profile-grub-entries become unused and is still present.
* When using switch-generation, operating-system-bootcfg is not
* called. So, the kernel arguments are not correctly set (--root,
* --system and --load), and the resulting entries in grub.cfg are broken.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: problem with commit abae042
  2017-04-15 18:17       ` problem with commit abae042 Mathieu Othacehe
@ 2017-04-15 18:56         ` Danny Milosavljevic
  2017-04-15 19:13           ` Mathieu Othacehe
  2017-04-15 19:50         ` bootloader and kernel arguments "--root", "--system", "--load" Danny Milosavljevic
  2017-04-15 23:18         ` bug#26339: problem with commit abae042 Leo Famulari
  2 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 18:56 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, guix-devel

Hi,

On Sat, 15 Apr 2017 20:17:59 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> I think there's a problem with commit abae042 :
> 
> * profile-grub-entries become unused and is still present.

I know, I can't remove it without review, far too dangerous.

> * When using switch-generation, operating-system-bootcfg is not
> * called. So, the kernel arguments are not correctly set (--root,
> * --system and --load), and the resulting entries in grub.cfg are broken.

Yes, indeed.  I'm working on it.  If I can't get it to work today I'll back it out again.

Too bad this is such a huge changeset - it's quite difficult to find a safe path.

Do you have an idea how to fix it? 

Would it be good to press forward with the other patches or should I back it out?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: problem with commit abae042
  2017-04-15 18:56         ` Danny Milosavljevic
@ 2017-04-15 19:13           ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-15 19:13 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339, guix-devel


> Too bad this is such a huge changeset - it's quite difficult to find a safe path.

Yes, and my split between commit isn't great, sorry about that.

> Do you have an idea how to fix it? 

Nothing trivial. Plus I didn't notice before that
profile-bootloader-entries and operating-system-bootcfg had parts that
could have been factorized.

>
> Would it be good to press forward with the other patches or should I back it out?

Maybe the safer approch would be to revert this commit. I'll publish new
patches and try to find a better approach for
profile-bootloader-entries, if you're ok ?

Thank you,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bootloader and kernel arguments "--root", "--system", "--load"
  2017-04-15 18:17       ` problem with commit abae042 Mathieu Othacehe
  2017-04-15 18:56         ` Danny Milosavljevic
@ 2017-04-15 19:50         ` Danny Milosavljevic
  2017-04-15 23:18         ` bug#26339: problem with commit abae042 Leo Famulari
  2 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 19:50 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, guix-devel

Ok, I'm in the process of reverting the patches to grub.

------

Problem analysis:

- (profile-boot-parameters ...) doesn't pick up the correct kernel-arguments.  It's reading them from a parameters file for the system generation back then, for example from /gnu/store/x8ymiksnhfyvjdi8ms38ysc4yr92lyk9-system/parameters, which contains:

(boot-parameters
  (version 0)
  (label "GNU with Linux-Libre 4.5.1 (beta)")
  (root-device "/dev/sda1")
  (kernel "/gnu/store/h977riqrp7c3w2v0mcpp48ldcapy09gx-linux-libre-4.5.1")
  (kernel-arguments ("crashkernel=256M" "modprobe.blacklist=pcspkr,snd_pcsp" "quiet" "acpi_osi=Linux" "clocksource=acpi_pm"))
  (initrd (string-append "/gnu/store/8w1abpwlhnilibiamcp6j01rhjh9k5ix-base-initrd" "/initrd")))

, which indeed doesn't contain the correct kernel arguments for it to boot.

Why not?  Shouldn't we just store the correct arguments in there eventually?

Those kernel arguments should include (in the front):

linux-arguments
        let root = (boot-parameters-root-device params) or #f
        let root-device = (if (bytevector? root) (uuid->string root) root)
        let system = "/gnu/store/x8ymiksnhfyvjdi8ms38ysc4yr92lyk9-system" in
        "--root=<root-device>"
        "--system=<system>"
        "--load=<system>/boot"
.

Or is it something grub-specific?

Or is it because we don't know system's own hash value in order to be able to write it there?

Would it be good to (later) replace the kernel-arguments accessor by a procedure that also takes system and root and prepends them on-the-fly?

i.e.

(define (boot-parameters-all-kernel-arguments params system root)
  (cons
    (string-append "--root=" root)
    (cons
      (string-append "--system=" system)
      ... load etc
      (boot-parameters-kernel-arguments params))))

... and only use this one, never boot-parameters-kernel-arguments anywhere else?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 07/18] system: Add bootloader type.
  2017-04-15 17:23       ` Mathieu Othacehe
@ 2017-04-15 20:16         ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 20:16 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> > Oh, so that's how.  I think it would be nice-to-have if the user could also override the bootloader package used.  
> 
> The user could already write :
> 
> --8<---------------cut here---------------start------------->8---
> (bootloader-configuration
>  (inherit %grub-configuration)
>  (bootloader my-grub))
> --8<---------------cut here---------------end--------------->8---

Yes, indeed.  Okay.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub.
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (19 preceding siblings ...)
  2017-04-15 13:58   ` Danny Milosavljevic
@ 2017-04-15 20:17   ` Danny Milosavljevic
  20 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 20:17 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, David Craven

I've reverted most of this patch in commit 958a1fda9e0ad41468cbdb88766e7c854dd32df4 to master.  Sorry for the churn.

Still in is: (first all-entries) instead of (first entries) which is a legitimate bugfix.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: bug#26339: problem with commit abae042
  2017-04-15 18:17       ` problem with commit abae042 Mathieu Othacehe
  2017-04-15 18:56         ` Danny Milosavljevic
  2017-04-15 19:50         ` bootloader and kernel arguments "--root", "--system", "--load" Danny Milosavljevic
@ 2017-04-15 23:18         ` Leo Famulari
  2017-04-15 23:22           ` Danny Milosavljevic
  2 siblings, 1 reply; 204+ messages in thread
From: Leo Famulari @ 2017-04-15 23:18 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, guix-devel

[-- Attachment #1: Type: text/plain, Size: 534 bytes --]

On Sat, Apr 15, 2017 at 08:17:59PM +0200, Mathieu Othacehe wrote:
> 
> I think there's a problem with commit abae042 :
> 
> * profile-grub-entries become unused and is still present.
> * When using switch-generation, operating-system-bootcfg is not
> * called. So, the kernel arguments are not correctly set (--root,
> * --system and --load), and the resulting entries in grub.cfg are broken.

This should be reverted immediately, since the master branch is what
users get from `guix pull`, so we really must not break it.

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

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: bug#26339: problem with commit abae042
  2017-04-15 23:18         ` bug#26339: problem with commit abae042 Leo Famulari
@ 2017-04-15 23:22           ` Danny Milosavljevic
  2017-04-15 23:56             ` Leo Famulari
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-15 23:22 UTC (permalink / raw)
  To: Leo Famulari; +Cc: 26339, guix-devel

It has been reverted.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: problem with commit abae042
  2017-04-15 23:22           ` Danny Milosavljevic
@ 2017-04-15 23:56             ` Leo Famulari
  0 siblings, 0 replies; 204+ messages in thread
From: Leo Famulari @ 2017-04-15 23:56 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

[-- Attachment #1: Type: text/plain, Size: 173 bytes --]

On Sun, Apr 16, 2017 at 01:22:25AM +0200, Danny Milosavljevic wrote:
> It has been reverted.

Thanks! Let's get these valuable changes merged after a little more
testing :)

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

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 03/18] scripts: system: Rename --no-grub option to --no-bootloader.
  2017-04-15 10:10     ` Danny Milosavljevic
@ 2017-04-16  9:58       ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-04-16  9:58 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> Hi,
>
>> -         (option '("no-grub") #f #f
>> +         (option '("no-bootloader") #f #f
>
> I'd prefer if it accepted both options - for backward compatibility.  We don't know what scripts people use on top of guix - and it's likely that many user scripts already pass "--no-grub", especially since the less-dangerous choice is to pass it (as opposed to not pass it).  There is no harm in supporting both options.

Agreed.  So:

  (option '("no-bootloader" "no-grub") …)

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them.
  2017-04-15 17:15       ` Mathieu Othacehe
@ 2017-04-16 21:37         ` Danny Milosavljevic
  2017-04-17  8:49           ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-16 21:37 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

On Sat, 15 Apr 2017 19:15:46 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> Well you can have only one bootloader in MBR at a time, so even if you
> have multiple system generations with various bootloaders, only one is
> installed. But I might be wrong here ...

It's possible to install Grub to a partition.  So there could be one bootloader in the MBR and another bootloader chainloaded in the partition.  Also for multiple partitions.

If we decide that this use case isn't supported, that's fine.  Many other distros make the assumption that there's only one bootloader - which is sometimes good because you can have another bootloader the distribution doesn't know about (in addition to the one the distribution does know about) that supervises all the others.

Not sure how Grub finds its config file in the first place.  Does Grub itself support that scenario?  At least in my Libreboot BIOS I can chainload Grub from Grub - although I think the primary Grub is just picking up the secondary's config file and reloading or something.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them.
  2017-04-16 21:37         ` Danny Milosavljevic
@ 2017-04-17  8:49           ` Mathieu Othacehe
  2017-04-18  8:23             ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  8:49 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi Danny,

> If we decide that this use case isn't supported, that's fine.  Many other distros make the assumption that there's only one bootloader - which is sometimes good because you can have another bootloader the distribution doesn't know about (in addition to the one the distribution does know about) that supervises all the others.

Well you're right multiple bootloader may co-exist on multiple
partitions. However I'm not sure how guix would manage more than one
bootloader at a time ?

Ludo, Leo, any thoughts ?

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 00/12] Support for non grub bootloaders.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
@ 2017-04-17  9:01 ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
                     ` (11 more replies)
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
                   ` (7 subsequent siblings)
  9 siblings, 12 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

Hi,

Here's a v2 of the serie to address problems
pointed out by Danny.

Thanks,

Mathieu

David Craven (1):
  bootloader: Add install procedures and use them.

Mathieu Othacehe (11):
  system: Pass <bootloader-parameter> to grub.
  system: Add extlinux support.
  scripts: system: Rename --no-grub option to --no-bootloader.
  system: Add bootloader type.
  bootloader: Stop using grub module.
  bootloader: Add device and type to bootloader-configuration record.
  scripts: system: Remove unused variables.
  scripts: system: Adapt "reconfigure" to new bootloader API.
  scripts: system: Adapt "init" to new bootloader API.
  scripts: system: Adapt "switch-generation" to new bootloader API.
  scripts: system: Display bootloader device and type in
    "list-generations".

 gnu.scm                   |   3 +-
 gnu/build/install.scm     |  36 ++----
 gnu/build/vm.scm          |  17 ++-
 gnu/local.mk              |   1 +
 gnu/system.scm            |  50 +++++++--
 gnu/system/bootloader.scm | 254 ++++++++++++++++++++++++++++++++++++++++++
 gnu/system/grub.scm       |  35 ++++--
 gnu/system/vm.scm         |  37 ++++--
 gnu/tests.scm             |   3 +-
 gnu/tests/nfs.scm         |   3 +-
 gnu/tests/web.scm         |   1 +
 guix/scripts/system.scm   | 278 +++++++++++++++++++++++++---------------------
 tests/guix-system.sh      |   2 -
 tests/system.scm          |   2 -
 14 files changed, 519 insertions(+), 203 deletions(-)
 create mode 100644 gnu/system/bootloader.scm

-- 
2.12.2

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17 17:08     ` Danny Milosavljevic
  2017-05-08  9:37     ` Ludovic Courtès
  2017-04-17  9:01   ` bug#26339: [PATCH v2 02/12] system: Add extlinux support Mathieu Othacehe
                     ` (10 subsequent siblings)
  11 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (operating-system-grub.cfg): Pass <bootloader-parameter>.
* gnu/system/grub.scm (boot-parameters->menu-entry): New variable.
  (grub-configuration-file): Use boot-parameters->menu-entry.
---
 gnu/system.scm      | 11 ++++++-----
 gnu/system/grub.scm | 13 +++++++++++--
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 89c4150f9..7c66f6088 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -742,16 +742,17 @@ populate the \"old entries\" menu."
        (root-device -> (if (eq? 'uuid (file-system-title root-fs))
                            (uuid->string (file-system-device root-fs))
                            (file-system-device root-fs)))
-       (entries ->  (list (menu-entry
+       (entries ->  (list (boot-parameters
                            (label label)
+                           (root-device root-device)
 
                            ;; The device where the kernel and initrd live.
-                           (device (fs->boot-device store-fs))
-                           (device-mount-point
+                           (store-device (fs->boot-device store-fs))
+                           (store-mount-point
                             (file-system-mount-point store-fs))
 
-                           (linux kernel)
-                           (linux-arguments
+                           (kernel kernel)
+                           (kernel-arguments
                             (cons* (string-append "--root=" root-device)
                                    #~(string-append "--system=" #$system)
                                    #~(string-append "--load=" #$system
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index cde4b9e23..f2838d633 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -267,6 +267,15 @@ code."
         (#f
          #~(format #f "search --file --set ~a" #$file)))))
 
+(define (boot-parameters->menu-entry conf)
+  (menu-entry
+   (label (boot-parameters-label conf))
+   (device (boot-parameters-store-device conf))
+   (device-mount-point (boot-parameters-store-mount-point conf))
+   (linux (boot-parameters-kernel conf))
+   (linux-arguments (boot-parameters-kernel-arguments conf))
+   (initrd (boot-parameters-initrd conf))))
+
 (define* (grub-configuration-file config entries
                                   #:key
                                   (system (%current-system))
@@ -276,7 +285,7 @@ code."
 <file-system> object.  OLD-ENTRIES is taken to be a list of menu entries
 corresponding to old generations of the system."
   (define all-entries
-    (append entries
+    (append (map boot-parameters->menu-entry entries)
             (grub-configuration-menu-entries config)))
 
   (define entry->gexp
@@ -323,7 +332,7 @@ set timeout=~a~%"
             #$@(if (pair? old-entries)
                    #~((format port "
 submenu \"GNU system, old configurations...\" {~%")
-                      #$@(map entry->gexp old-entries)
+                      #$@(map entry->gexp (map boot-parameters->menu-entry old-entries))
                       (format port "}~%"))
                    #~()))))
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 02/12] system: Add extlinux support.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 03/12] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (operating-system): Add default bootloader.
  (operating-system-grub.cfg): Use bootloader-configuration-file-generator.
* gnu/system/grub.scm (bootloader-configuration->grub-configuration): New
  variable.
  (grub-configuration-file): Use bootloader-configuration->grub-configuration.
* guix/scripts/system.scm (profile-grub-entries): Rename system->grub-entry to
  system->boot-parameters and adjust accordingly.
  (perform-action): Make bootloader optional. Use
  bootloader-configuration-device.
* gnu/system/bootloader.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* tests/system.scm: Adjust operating-system to new API.
* tests/guix-system.sh: Adjust operating-system to new API.
---
 gnu/local.mk              |   1 +
 gnu/system.scm            |  10 +--
 gnu/system/bootloader.scm | 161 ++++++++++++++++++++++++++++++++++++++++++++++
 gnu/system/grub.scm       |  22 ++++---
 guix/scripts/system.scm   |  44 ++++++-------
 tests/guix-system.sh      |   2 -
 tests/system.scm          |   2 -
 7 files changed, 200 insertions(+), 42 deletions(-)
 create mode 100644 gnu/system/bootloader.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index cf9f5c719..8ba2e4721 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -439,6 +439,7 @@ GNU_SYSTEM_MODULES =				\
 						\
   %D%/system.scm				\
   %D%/system/file-systems.scm			\
+  %D%/system/bootloader.scm			\
   %D%/system/grub.scm				\
   %D%/system/install.scm			\
   %D%/system/linux-container.scm		\
diff --git a/gnu/system.scm b/gnu/system.scm
index 7c66f6088..ce0a4a00e 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -48,7 +48,7 @@
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services base)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system nss)
   #:use-module (gnu system locale)
@@ -131,8 +131,8 @@
           (default linux-libre))
   (kernel-arguments operating-system-kernel-arguments
                     (default '()))                ; list of gexps/strings
-  (bootloader operating-system-bootloader)        ; <grub-configuration>
-
+  (bootloader operating-system-bootloader         ; <bootloader-configuration>
+              (default (extlinux-configuration)))
   (initrd operating-system-initrd                 ; (list fs) -> M derivation
           (default base-initrd))
   (firmware operating-system-firmware             ; list of packages
@@ -759,8 +759,8 @@ populate the \"old entries\" menu."
                                                     "/boot")
                                    (operating-system-kernel-arguments os)))
                            (initrd initrd)))))
-    (grub-configuration-file (operating-system-bootloader os) entries
-                             #:old-entries old-entries)))
+    ((bootloader-configuration-file-generator (operating-system-bootloader os))
+     (operating-system-bootloader os) entries #:old-entries old-entries)))
 
 (define (fs->boot-device fs)
   "Given FS, a <file-system> object, return a value suitable for use as the
diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
new file mode 100644
index 000000000..ea067bf73
--- /dev/null
+++ b/gnu/system/bootloader.scm
@@ -0,0 +1,161 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 David Craven <david@craven.ch>
+;;;
+;;; 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/>.
+
+(define-module (gnu system bootloader)
+  #:use-module (gnu system)
+  #:use-module (gnu system grub)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix records)
+  #:use-module (ice-9 match)
+  #:export (bootloader-configuration
+            bootloader-configuration?
+            bootloader-configuration-bootloader
+            bootloader-configuration-device
+            bootloader-configuration-menu-entries
+            bootloader-configuration-default-entry
+            bootloader-configuration-timeout
+            bootloader-configuration-file-generator
+            bootloader-configuration-file-name
+            bootloader-configuration-installer
+            bootloader-configuration-additional-configuration
+
+            extlinux-configuration
+            grub-configuration
+            grub-efi-configuration
+            syslinux-configuration))
+
+;;; Commentary:
+;;;
+;;; Generic configuration for bootloaders.
+;;;
+;;; Code:
+
+(define-record-type* <bootloader-configuration>
+  bootloader-configuration make-bootloader-configuration
+  bootloader-configuration?
+  (bootloader                      bootloader-configuration-bootloader     ; package
+                                   (default #f))
+  (device                          bootloader-configuration-device         ; string
+                                   (default #f))
+  (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
+                                   (default '()))
+  (default-entry                   bootloader-configuration-default-entry  ; integer
+                                   (default 0))
+  (timeout                         bootloader-configuration-timeout        ; integer
+                                   (default 5))
+  (configuration-file-name         bootloader-configuration-file-name
+                                   (default #f))
+  (configuration-file-generator    bootloader-configuration-file-generator ; procedure
+                                   (default #f))
+  (installer                       bootloader-configuration-installer ; procedure
+                                   (default #f))
+  (additional-configuration        bootloader-configuration-additional-configuration ; record
+                                   (default #f)))
+
+\f
+
+;;;
+;;; Extlinux configuration file.
+;;;
+
+(define* (extlinux-configuration-file config entries
+                                      #:key
+                                      (system (%current-system))
+                                      (old-entries '()))
+  "Return the U-Boot configuration file corresponding to CONFIG, a
+<u-boot-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."
+
+  (define all-entries
+    (append entries (bootloader-configuration-menu-entries config)))
+
+  (define (boot-parameters->gexp params)
+    (let ((label (boot-parameters-label params))
+          (kernel (boot-parameters-kernel params))
+          (kernel-arguments (boot-parameters-kernel-arguments params))
+          (initrd (boot-parameters-initrd params)))
+      #~(format port "LABEL ~a
+  MENU LABEL ~a
+  KERNEL ~a
+  FDTDIR ~a/lib/dtbs
+  INITRD ~a
+  APPEND ~a
+~%"
+                #$label #$label
+                #$kernel #$kernel #$initrd
+                (string-join (list #$@kernel-arguments)))))
+
+  (define builder
+    #~(call-with-output-file #$output
+        (lambda (port)
+          (let ((timeout #$(bootloader-configuration-timeout config)))
+            (format port "
+UI menu.c32
+PROMPT ~a
+TIMEOUT ~a~%"
+                    (if (> timeout 0) 1 0)
+                    ;; timeout is expressed in 1/10s of seconds.
+                    (* 10 timeout))
+            #$@(map boot-parameters->gexp all-entries)
+
+            #$@(if (pair? old-entries)
+                   #~((format port "~%")
+                      #$@(map boot-parameters->gexp old-entries)
+                      (format port "~%"))
+                   #~())))))
+
+  (gexp->derivation "extlinux.conf" builder))
+
+
+\f
+
+;;;
+;;; Bootloader configurations.
+;;;
+
+(define* (extlinux-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit config)
+   (configuration-file-name "/boot/extlinux/extlinux.conf")
+   (configuration-file-generator extlinux-configuration-file)))
+
+(define* (grub-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit config)
+   (bootloader (@ (gnu packages bootloaders) grub))
+   (configuration-file-name "/boot/grub/grub.cfg")
+   (configuration-file-generator grub-configuration-file)
+   (installer install-grub)
+   (additional-configuration
+    (let ((additional-config (bootloader-configuration-additional-configuration config)))
+      (if additional-config additional-config %default-theme)))))
+
+(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit (grub-configuration config))
+   (bootloader (@ (gnu packages bootloaders) grub-efi))))
+
+(define* (syslinux-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit (extlinux-configuration config))
+   (bootloader (@ (gnu packages bootloaders) syslinux))
+   (installer install-syslinux)))
+
+;;; bootloader.scm ends here
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index f2838d633..0b52e3e7e 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -27,6 +27,7 @@
   #:use-module (guix download)
   #:use-module (gnu artwork)
   #:use-module (gnu system)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:autoload   (gnu packages bootloaders) (grub)
   #:autoload   (gnu packages compression) (gzip)
@@ -49,14 +50,6 @@
             %background-image
             %default-theme
 
-            grub-configuration
-            grub-configuration?
-            grub-configuration-device
-            grub-configuration-grub
-
-            menu-entry
-            menu-entry?
-
             grub-configuration-file))
 
 ;;; Commentary:
@@ -276,7 +269,16 @@ code."
    (linux-arguments (boot-parameters-kernel-arguments conf))
    (initrd (boot-parameters-initrd conf))))
 
-(define* (grub-configuration-file config entries
+(define (bootloader-configuration->grub-configuration config)
+  (grub-configuration
+   (grub (bootloader-configuration-bootloader config))
+   (device (bootloader-configuration-device config))
+   (menu-entries (bootloader-configuration-menu-entries config))
+   (default-entry (bootloader-configuration-default-entry config))
+   (timeout (bootloader-configuration-timeout config))
+   (theme (bootloader-configuration-additional-configuration config))))
+
+(define* (grub-configuration-file bootloader-config entries
                                   #:key
                                   (system (%current-system))
                                   (old-entries '()))
@@ -284,6 +286,8 @@ code."
 <grub-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."
+  (define config (bootloader-configuration->grub-configuration bootloader-config))
+
   (define all-entries
     (append (map boot-parameters->menu-entry entries)
             (grub-configuration-menu-entries config)))
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 9ffdc15ab..3ec100032 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -38,10 +38,10 @@
   #:use-module (guix build utils)
   #:use-module (gnu build install)
   #:use-module (gnu system)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system linux-container)
   #:use-module (gnu system vm)
-  #:use-module (gnu system grub)
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services herd)
@@ -385,32 +385,25 @@ NUMBERS, which is a list of generation numbers."
                                   (numbers (generation-numbers profile)))
   "Return a list of 'menu-entry' for the generations of PROFILE specified by
 NUMBERS, which is a list of generation numbers."
-  (define (system->grub-entry system number time)
+  (define (system->boot-parameters system number time)
     (unless-file-not-found
      (let* ((file             (string-append system "/parameters"))
             (params           (call-with-input-file file
                                 read-boot-parameters))
-            (label            (boot-parameters-label params))
             (root             (boot-parameters-root-device params))
             (root-device      (if (bytevector? root)
                                   (uuid->string root)
-                                  root))
-            (kernel           (boot-parameters-kernel params))
-            (kernel-arguments (boot-parameters-kernel-arguments params))
-            (initrd           (boot-parameters-initrd params)))
-       (menu-entry
-        (label (string-append label " (#"
+                                  root)))
+       (boot-parameters
+        (inherit params)
+        (label (string-append (boot-parameters-label params) " (#"
                               (number->string number) ", "
                               (seconds->string time) ")"))
-        (device (boot-parameters-store-device params))
-        (device-mount-point (boot-parameters-store-mount-point params))
-        (linux kernel)
-        (linux-arguments
-         (cons* (string-append "--root=" root-device)
+        (kernel-arguments
+         (cons* (string-append "--root=" (boot-parameters-root-device params))
                 (string-append "--system=" system)
                 (string-append "--load=" system "/boot")
-                kernel-arguments))
-        (initrd initrd)))))
+                (boot-parameters-kernel-arguments params)))))))
 
   (let* ((systems (map (cut generation-file-name profile <>)
                        numbers))
@@ -418,7 +411,7 @@ NUMBERS, which is a list of generation numbers."
                          (unless-file-not-found
                           (stat:mtime (lstat system))))
                        systems)))
-    (filter-map system->grub-entry systems numbers times)))
+    (filter-map system->boot-parameters systems numbers times)))
 
 \f
 ;;;
@@ -636,8 +629,11 @@ output when building a system derivation, such as a disk image."
                                                 #:image-size image-size
                                                 #:full-boot? full-boot?
                                                 #:mappings mappings))
-       (grub      (package->derivation (grub-configuration-grub
-                                        (operating-system-bootloader os))))
+       (bootloader (let ((bootloader (bootloader-configuration-bootloader
+                                      (operating-system-bootloader os))))
+                     (if bootloader
+                         (package->derivation bootloader)
+                         (return #f))))
        (grub.cfg  (if (eq? 'container action)
                       (return #f)
                       (operating-system-bootcfg os
@@ -649,8 +645,8 @@ output when building a system derivation, such as a disk image."
        ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
        ;; root.  See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if bootloader?
-                          (list sys grub.cfg grub)
+                      (if (and bootloader? bootloader)
+                          (list sys grub.cfg bootloader)
                           (list sys grub.cfg))
                       (list sys)))
        (%         (if derivations-only?
@@ -666,8 +662,8 @@ output when building a system derivation, such as a disk image."
                     drvs)
 
           ;; Make sure GRUB is accessible.
-          (when bootloader?
-            (let ((prefix (derivation->output-path grub)))
+          (when (and bootloader? bootloader)
+            (let ((prefix (derivation->output-path bootloader)))
               (setenv "PATH"
                       (string-append  prefix "/bin:" prefix "/sbin:"
                                       (getenv "PATH")))))
@@ -870,7 +866,7 @@ resulting from command-line parsing."
                         ((first second) second)
                         (_ #f)))
          (device      (and bootloader?
-                           (grub-configuration-device
+                           (bootloader-configuration-device
                             (operating-system-bootloader os)))))
 
     (with-store store
diff --git a/tests/guix-system.sh b/tests/guix-system.sh
index de6db0928..525480a11 100644
--- a/tests/guix-system.sh
+++ b/tests/guix-system.sh
@@ -91,7 +91,6 @@ OS_BASE='
   (timezone "Europe/Paris")
   (locale "en_US.UTF-8")
 
-  (bootloader (grub-configuration (device "/dev/sdX")))
   (file-systems (cons (file-system
                         (device "root")
                         (title (string->symbol "label"))
@@ -162,7 +161,6 @@ make_user_config ()
   (timezone "Europe/Paris")
   (locale "en_US.UTF-8")
 
-  (bootloader (grub-configuration (device "/dev/sdX")))
   (file-systems (cons (file-system
                         (device "root")
                         (title 'label)
diff --git a/tests/system.scm b/tests/system.scm
index ca34409be..bdda08e18 100644
--- a/tests/system.scm
+++ b/tests/system.scm
@@ -36,7 +36,6 @@
     (host-name "komputilo")
     (timezone "Europe/Berlin")
     (locale "en_US.utf8")
-    (bootloader (grub-configuration (device "/dev/sdX")))
     (file-systems (cons %root-fs %base-file-systems))
 
     (users %base-user-accounts)))
@@ -51,7 +50,6 @@
     (host-name "komputilo")
     (timezone "Europe/Berlin")
     (locale "en_US.utf8")
-    (bootloader (grub-configuration (device "/dev/sdX")))
     (mapped-devices (list %luks-device))
     (file-systems (cons (file-system
                           (inherit %root-fs)
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 03/12] scripts: system: Rename --no-grub option to --no-bootloader.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 02/12] system: Add extlinux support Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17 15:54     ` Danny Milosavljevic
  2017-04-17  9:01   ` bug#26339: [PATCH v2 04/12] bootloader: Add install procedures and use them Mathieu Othacehe
                     ` (8 subsequent siblings)
  11 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (%options, show-help): Adjust accordingly.
Keep "--no-grub" for compatibility reasons, but do not mention it in the help.
---
 guix/scripts/system.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 3ec100032..c2212ed14 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -761,7 +761,7 @@ Some ACTIONS support additional ARGS.\n"))
   (display (_ "
       --image-size=SIZE  for 'vm-image', produce an image of SIZE"))
   (display (_ "
-      --no-grub          for 'init', do not install GRUB"))
+      --no-bootloader    for 'init', do not install a bootloader"))
   (display (_ "
       --share=SPEC       for 'vm', share host file system according to SPEC"))
   (display (_ "
@@ -800,7 +800,7 @@ Some ACTIONS support additional ARGS.\n"))
                  (lambda (opt name arg result)
                    (alist-cons 'image-size (size->number arg)
                                result)))
-         (option '("no-grub") #f #f
+         (option '("no-bootloader" "no-grub") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'install-bootloader? #f result)))
          (option '("full-boot") #f #f
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 04/12] bootloader: Add install procedures and use them.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (2 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 03/12] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 05/12] system: Add bootloader type Mathieu Othacehe
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339; +Cc: David Craven

From: David Craven <david@craven.ch>

* gnu/system/bootloader.scm (dd, install-grub, install-syslinux): New
  procedures.
* gnu/build/install.scm (install-boot-config): New procedure.
  (install-grub): Move to (gnu system bootloader).
* gnu/build/vm.scm (register-bootcfg-root): Rename register-grub.cfg-root and
  adjust accordingly.
  (initialize-hard-disk): Takes a bootloader, bootcfg, bootcfg-location and
  bootloader-installer procedure. Adjust accordingly.
* gnu/system/vm.scm (qemu-image): Adjust to initialize-hard-disk.
  (system-disk-image, system-qemu-image, system-qemu-image/shared-store):
  Adjust to qemu-image.
---
 gnu/build/install.scm     | 36 ++++++++---------------------------
 gnu/build/vm.scm          | 17 +++++++++++------
 gnu/system/bootloader.scm | 48 ++++++++++++++++++++++++++++++++++++++++++++++-
 gnu/system/vm.scm         | 37 ++++++++++++++++++++++++------------
 4 files changed, 91 insertions(+), 47 deletions(-)

diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index 5cb6055a0..9e30c0d23 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -22,8 +22,7 @@
   #:use-module (guix build store-copy)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
-  #:export (install-grub
-            install-grub-config
+  #:export (install-boot-config
             evaluate-populate-directive
             populate-root-file-system
             reset-timestamps
@@ -39,36 +38,17 @@
 ;;;
 ;;; Code:
 
-(define (install-grub grub.cfg device mount-point)
-  "Install GRUB with GRUB.CFG on DEVICE, which is assumed to be mounted on
-MOUNT-POINT.
-
-Note that the caller must make sure that GRUB.CFG is registered as a GC root
-so that the fonts, background images, etc. referred to by GRUB.CFG are not
-GC'd."
-  (install-grub-config grub.cfg mount-point)
-
-  ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or root
-  ;; partition.
-  (setenv "GRUB_ENABLE_CRYPTODISK" "y")
-
-  (unless (zero? (system* "grub-install" "--no-floppy"
-                          "--boot-directory"
-                          (string-append mount-point "/boot")
-                          device))
-    (error "failed to install GRUB")))
-
-(define (install-grub-config grub.cfg mount-point)
-  "Atomically copy GRUB.CFG into boot/grub/grub.cfg on the MOUNT-POINT.  Note
-that the caller must make sure that GRUB.CFG is registered as a GC root so
-that the fonts, background images, etc. referred to by GRUB.CFG are not GC'd."
-  (let* ((target (string-append mount-point "/boot/grub/grub.cfg"))
+(define (install-boot-config bootcfg bootcfg-location mount-point)
+  "Atomically copy BOOTCFG into BOOTCFG-LOCATION on the MOUNT-POINT.  Note
+that the caller must make sure that BOOTCFG is registered as a GC root so
+that the fonts, background images, etc. referred to by BOOTCFG are not GC'd."
+  (let* ((target (string-append mount-point bootcfg-location))
          (pivot  (string-append target ".new")))
     (mkdir-p (dirname target))
 
-    ;; Copy GRUB.CFG instead of just symlinking it, because symlinks won't
+    ;; Copy BOOTCFG instead of just symlinking it, because symlinks won't
     ;; work when /boot is on a separate partition.  Do that atomically.
-    (copy-file grub.cfg pivot)
+    (copy-file bootcfg pivot)
     (rename-file pivot target)))
 
 (define (evaluate-populate-directive directive target)
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 1eb9a4c45..440596a40 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -285,15 +285,18 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
     (unless register-closures?
       (reset-timestamps target))))
 
-(define (register-grub.cfg-root target bootcfg)
+(define (register-bootcfg-root target bootcfg)
   "On file system TARGET, register BOOTCFG as a GC root."
   (let ((directory (string-append target "/var/guix/gcroots")))
     (mkdir-p directory)
-    (symlink bootcfg (string-append directory "/grub.cfg"))))
+    (symlink bootcfg (string-append directory "/bootcfg"))))
 
 (define* (initialize-hard-disk device
                                #:key
-                               grub.cfg
+                               bootloader
+                               bootcfg
+                               bootcfg-location
+                               bootloader-installer
                                (partitions '()))
   "Initialize DEVICE as a disk containing all the <partition> objects listed
 in PARTITIONS, and using BOOTCFG as its bootloader configuration file.
@@ -311,10 +314,12 @@ passing it a directory name where it is mounted."
     (display "mounting root partition...\n")
     (mkdir-p target)
     (mount (partition-device root) target (partition-file-system root))
-    (install-grub grub.cfg device target)
+    (install-boot-config bootcfg bootcfg-location target)
+    (when bootloader-installer
+      (bootloader-installer bootloader device target))
 
-    ;; Register GRUB.CFG as a GC root.
-    (register-grub.cfg-root target grub.cfg)
+    ;; Register BOOTCFG as a GC root.
+    (register-bootcfg-root target bootcfg)
 
     (umount target)))
 
diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
index ea067bf73..fddf038b8 100644
--- a/gnu/system/bootloader.scm
+++ b/gnu/system/bootloader.scm
@@ -38,7 +38,10 @@
             extlinux-configuration
             grub-configuration
             grub-efi-configuration
-            syslinux-configuration))
+            syslinux-configuration
+
+            install-grub
+            install-syslinux))
 
 ;;; Commentary:
 ;;;
@@ -158,4 +161,47 @@ TIMEOUT ~a~%"
    (bootloader (@ (gnu packages bootloaders) syslinux))
    (installer install-syslinux)))
 
+\f
+
+;;;
+;;; Bootloader install procedures.
+;;;
+
+(define dd
+  #~(lambda (bs count if of)
+      (zero? (system* "dd"
+                      (string-append "bs=" (number->string bs))
+                      (string-append "count=" (number->string count))
+                      (string-append "if=" if)
+                      (string-append "of=" of)))))
+
+(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")
+
+        (unless (zero? (system* grub "--no-floppy"
+                                "--boot-directory" install-dir
+                                device))
+          (error "failed to install GRUB")))))
+
+(define install-syslinux
+  #~(lambda (bootloader device mount-point)
+      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
+            (install-dir (string-append mount-point "/boot/extlinux"))
+            (syslinux-dir (string-append bootloader "/share/syslinux")))
+        (mkdir-p install-dir)
+        (for-each (lambda (file)
+                    (copy-file file
+                               (string-append install-dir "/" (basename file))))
+                  (find-files syslinux-dir "\\.c32$"))
+
+        (unless (and (zero? (system* extlinux "--install" install-dir))
+                     (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
+          (error "failed to install SYSLINUX")))))
+
 ;;; bootloader.scm ends here
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 374d8b663..65955b010 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -46,10 +46,10 @@
                 #:select (%guile-static-stripped))
   #:use-module (gnu packages admin)
 
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system pam)
   #:use-module (gnu system linux-initrd)
-  #:use-module (gnu system grub)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system)
   #:use-module (gnu services)
@@ -176,8 +176,9 @@ made available under the /xchg CIFS share."
                      (disk-image-format "qcow2")
                      (file-system-type "ext4")
                      file-system-label
-                     os-derivation
-                     grub-configuration
+                     os.drv
+                     bootcfg.drv
+                     bootloader-configuration
                      (register-closures? #t)
                      (inputs '())
                      copy-inputs?)
@@ -201,7 +202,7 @@ the image."
                       (guix build utils))
 
          (let ((inputs
-                '#$(append (list qemu parted grub e2fsprogs)
+                '#$(append (list qemu parted e2fsprogs)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -223,7 +224,7 @@ the image."
                                #:closures graphs
                                #:copy-closures? #$copy-inputs?
                                #:register-closures? #$register-closures?
-                               #:system-directory #$os-derivation))
+                               #:system-directory #$os.drv))
                   (partitions (list (partition
                                      (size #$(- disk-image-size
                                                 (* 10 (expt 2 20))))
@@ -233,7 +234,16 @@ the image."
                                      (initializer initialize)))))
              (initialize-hard-disk "/dev/vda"
                                    #:partitions partitions
-                                   #:grub.cfg #$grub-configuration)
+                                   #:bootloader
+                                   #$(bootloader-configuration-bootloader
+                                      bootloader-configuration)
+                                   #:bootcfg #$bootcfg.drv
+                                   #:bootcfg-location
+                                   #$(bootloader-configuration-file-name
+                                      bootloader-configuration)
+                                   #:bootloader-installer
+                                   #$(bootloader-configuration-installer
+                                      bootloader-configuration))
              (reboot)))))
    #:system system
    #:make-disk-image? #t
@@ -287,8 +297,9 @@ to USB sticks meant to be read-only."
     (mlet* %store-monad ((os-drv   (operating-system-derivation os))
                          (bootcfg  (operating-system-bootcfg os)))
       (qemu-image #:name name
-                  #:os-derivation os-drv
-                  #:grub-configuration bootcfg
+                  #:os.drv os-drv
+                  #:bootcfg.drv bootcfg
+                  #:bootloader-configuration (operating-system-bootloader os)
                   #:disk-image-size disk-image-size
                   #:disk-image-format "raw"
                   #:file-system-type file-system-type
@@ -330,8 +341,9 @@ of the GNU system as described by OS."
     (mlet* %store-monad
         ((os-drv      (operating-system-derivation os))
          (bootcfg     (operating-system-bootcfg os)))
-      (qemu-image  #:os-derivation os-drv
-                   #:grub-configuration bootcfg
+      (qemu-image  #:os.drv os-drv
+                   #:bootcfg.drv bootcfg
+                   #:bootloader-configuration (operating-system-bootloader os)
                    #:disk-image-size disk-image-size
                    #:file-system-type file-system-type
                    #:inputs `(("system" ,os-drv)
@@ -429,8 +441,9 @@ bootloader refers to: OS kernel, initrd, bootloader data, etc."
     ;; BOOTCFG and all its dependencies, including the output of OS-DRV.
     ;; This is more than needed (we only need the kernel, initrd, GRUB for its
     ;; font, and the background image), but it's hard to filter that.
-    (qemu-image #:os-derivation os-drv
-                #:grub-configuration bootcfg
+    (qemu-image #:os.drv os-drv
+                #:bootcfg.drv bootcfg
+                #:bootloader-configuration (operating-system-bootloader os)
                 #:disk-image-size disk-image-size
                 #:inputs (if full-boot?
                              `(("bootcfg" ,bootcfg))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 05/12] system: Add bootloader type.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (3 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 04/12] bootloader: Add install procedures and use them Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 06/12] bootloader: Stop using grub module Mathieu Othacehe
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* gnu/system/bootloader.scm
(<bootloader-configuration>)[type]: New field.
(%extlinux-configuration, %grub-configuration, %grub-efi-configuration,
%syslinux-configuration): New exported variables.
(extlinux-configuration, grub-configuration, grub-efi-configuration,
syslinux-configuration): New exported compatibility macros.
---
 gnu/system/bootloader.scm | 119 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 83 insertions(+), 36 deletions(-)

diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
index fddf038b8..bab6cfab3 100644
--- a/gnu/system/bootloader.scm
+++ b/gnu/system/bootloader.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 David Craven <david@craven.ch>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,10 +23,12 @@
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
+  #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
   #:export (bootloader-configuration
             bootloader-configuration?
             bootloader-configuration-bootloader
+            bootloader-configuration-type
             bootloader-configuration-device
             bootloader-configuration-menu-entries
             bootloader-configuration-default-entry
@@ -35,6 +38,13 @@
             bootloader-configuration-installer
             bootloader-configuration-additional-configuration
 
+            %extlinux-configuration
+            %grub-configuration
+            %grub-efi-configuration
+            %syslinux-configuration
+
+            lookup-bootloader-configuration
+
             extlinux-configuration
             grub-configuration
             grub-efi-configuration
@@ -54,6 +64,8 @@
   bootloader-configuration?
   (bootloader                      bootloader-configuration-bootloader     ; package
                                    (default #f))
+  (type                            bootloader-configuration-type
+                                   (default #f))                           ; symbol
   (device                          bootloader-configuration-device         ; string
                                    (default #f))
   (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
@@ -126,43 +138,7 @@ TIMEOUT ~a~%"
 
   (gexp->derivation "extlinux.conf" builder))
 
-
-\f
-
-;;;
-;;; Bootloader configurations.
-;;;
-
-(define* (extlinux-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit config)
-   (configuration-file-name "/boot/extlinux/extlinux.conf")
-   (configuration-file-generator extlinux-configuration-file)))
-
-(define* (grub-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit config)
-   (bootloader (@ (gnu packages bootloaders) grub))
-   (configuration-file-name "/boot/grub/grub.cfg")
-   (configuration-file-generator grub-configuration-file)
-   (installer install-grub)
-   (additional-configuration
-    (let ((additional-config (bootloader-configuration-additional-configuration config)))
-      (if additional-config additional-config %default-theme)))))
-
-(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit (grub-configuration config))
-   (bootloader (@ (gnu packages bootloaders) grub-efi))))
-
-(define* (syslinux-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit (extlinux-configuration config))
-   (bootloader (@ (gnu packages bootloaders) syslinux))
-   (installer install-syslinux)))
-
 \f
-
 ;;;
 ;;; Bootloader install procedures.
 ;;;
@@ -204,4 +180,75 @@ TIMEOUT ~a~%"
                      (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
           (error "failed to install SYSLINUX")))))
 
+\f
+;;;
+;;; Bootloader configurations.
+;;;
+
+(define* %extlinux-configuration
+  (bootloader-configuration
+   (type 'extlinux)
+   (configuration-file-name "/boot/extlinux/extlinux.conf")
+   (configuration-file-generator extlinux-configuration-file)))
+
+(define* %grub-configuration
+  (bootloader-configuration
+   (type 'grub)
+   (bootloader (@ (gnu packages bootloaders) grub))
+   (configuration-file-name "/boot/grub/grub.cfg")
+   (configuration-file-generator grub-configuration-file)
+   (installer install-grub)
+   (additional-configuration %default-theme)))
+
+(define* %grub-efi-configuration
+  (bootloader-configuration
+   (inherit %grub-configuration)
+   (type 'grub-efi)
+   (bootloader (@ (gnu packages bootloaders) grub-efi))))
+
+(define* %syslinux-configuration
+  (bootloader-configuration
+   (inherit %extlinux-configuration)
+   (type 'syslinux)
+   (bootloader (@ (gnu packages bootloaders) syslinux))
+   (installer install-syslinux)))
+
+(define %bootloader-configurations
+  (list %extlinux-configuration
+        %grub-configuration
+        %grub-efi-configuration
+        %syslinux-configuration))
+
+(define (lookup-bootloader-configuration type)
+  (or (find (lambda (conf)
+              (eq? (bootloader-configuration-type conf)
+                   type))
+            %bootloader-configurations)
+      (error "~a: unknown bootloader type" type)))
+
+\f
+;;;
+;;; Compatibility macros.
+;;;
+
+(define-syntax-rule (extlinux-configuration fields ...)
+  (bootloader-configuration
+   (inherit %extlinux-configuration)
+   fields ...))
+
+(define-syntax-rule (grub-configuration fields ...)
+  (bootloader-configuration
+   (inherit %grub-configuration)
+   fields ...))
+
+(define-syntax-rule (grub-efi-configuration fields ...)
+  (bootloader-configuration
+   (inherit %grub-efi-configuration)
+   fields ...))
+
+(define-syntax-rule (syslinux-configuration fields ...)
+  (bootloader-configuration
+   (inherit %syslinux-configuration)
+   fields ...))
+
 ;;; bootloader.scm ends here
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 06/12] bootloader: Stop using grub module.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (4 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 05/12] system: Add bootloader type Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 07/12] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* gnu.scm (%public-modules): Replace grub by bootloader.
* gnu/tests.scm (define-module): Ditto.
* gnu/tests/nfs.scm (define-module): Ditto.
* gnu/tests/web.scm (define-module): Ditto.
---
 gnu.scm           | 3 ++-
 gnu/tests.scm     | 3 ++-
 gnu/tests/nfs.scm | 3 ++-
 gnu/tests/web.scm | 1 +
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gnu.scm b/gnu.scm
index 932e4cdd5..56b84b74d 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Joshua S. Grant <jgrant@parenthetical.io>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,7 +35,7 @@
       '((gnu system)
         (gnu system mapped-devices)
         (gnu system file-systems)
-        (gnu system grub)                         ; 'grub-configuration'
+        (gnu system bootloader)
         (gnu system pam)
         (gnu system shadow)                       ; 'user-account'
         (gnu system linux-initrd)
diff --git a/gnu/tests.scm b/gnu/tests.scm
index e84d1ebb2..25c7c3fd3 100644
--- a/gnu/tests.scm
+++ b/gnu/tests.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,7 +22,7 @@
   #:use-module (guix utils)
   #:use-module (guix records)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu services)
diff --git a/gnu/tests/nfs.scm b/gnu/tests/nfs.scm
index 1f28f5a5b..432fc83a1 100644
--- a/gnu/tests/nfs.scm
+++ b/gnu/tests/nfs.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 John Darrington <jmd@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +21,7 @@
 (define-module (gnu tests nfs)
   #:use-module (gnu tests)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu system vm)
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index bc7e3b89a..0e98a128c 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 07/12] bootloader: Add device and type to bootloader-configuration record.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (5 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 06/12] bootloader: Stop using grub module Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 08/12] scripts: system: Remove unused variables Mathieu Othacehe
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (<boot-parameters>)[device, type]: New fields.
(boot-parameters-boot-device): New exported procedure.
(boot-parameters-boot-type): Ditto.
(operating-system-grub.cfg): Add new fields.
(operating-system-parameters-file): Add new fields and replace GRUB by
bootloader in doctype.
(read-boot-parameters): Ditto.
---
 gnu/system.scm | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index ce0a4a00e..8c5721491 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -104,6 +104,8 @@
             boot-parameters?
             boot-parameters-label
             boot-parameters-root-device
+            boot-parameters-boot-device
+            boot-parameters-boot-type
             boot-parameters-store-device
             boot-parameters-store-mount-point
             boot-parameters-kernel
@@ -735,8 +737,12 @@ populate the \"old entries\" menu."
   (mlet* %store-monad
       ((system      (operating-system-derivation os))
        (root-fs ->  (operating-system-root-file-system os))
+       (boot-device -> (bootloader-configuration-device
+                        (operating-system-bootloader os)))
        (store-fs -> (operating-system-store-file-system os))
        (label ->    (kernel->boot-label (operating-system-kernel os)))
+       (boot-type -> (bootloader-configuration-type
+                      (operating-system-bootloader os)))
        (kernel ->   (operating-system-kernel-file os))
        (initrd      (operating-system-initrd-file os))
        (root-device -> (if (eq? 'uuid (file-system-title root-fs))
@@ -745,12 +751,14 @@ populate the \"old entries\" menu."
        (entries ->  (list (boot-parameters
                            (label label)
                            (root-device root-device)
+                           (boot-device boot-device)
 
                            ;; The device where the kernel and initrd live.
                            (store-device (fs->boot-device store-fs))
                            (store-mount-point
                             (file-system-mount-point store-fs))
 
+                           (boot-type boot-type)
                            (kernel kernel)
                            (kernel-arguments
                             (cons* (string-append "--root=" root-device)
@@ -772,10 +780,15 @@ device in a <menu-entry>."
 
 (define (operating-system-parameters-file os)
   "Return a file that describes the boot parameters of OS.  The primary use of
-this file is the reconstruction of GRUB menu entries for old configurations."
+this file is the reconstruction of bootloader menu entries for old
+configurations."
   (mlet %store-monad ((initrd   (operating-system-initrd-file os))
                       (root ->  (operating-system-root-file-system os))
+                      (boot-device -> (bootloader-configuration-device
+                                       (operating-system-bootloader os)))
                       (store -> (operating-system-store-file-system os))
+                      (boot-type -> (bootloader-configuration-type
+                                     (operating-system-bootloader os)))
                       (label -> (kernel->boot-label
                                  (operating-system-kernel os))))
     (gexp->file "parameters"
@@ -787,6 +800,8 @@ this file is the reconstruction of GRUB menu entries for old configurations."
                    (kernel-arguments
                     #$(operating-system-kernel-arguments os))
                    (initrd #$initrd)
+                   (boot-device #$boot-device)
+                   (boot-type #$boot-type)
                    (store
                     (device #$(fs->boot-device store))
                     (mount-point #$(file-system-mount-point store))))
@@ -808,6 +823,8 @@ this file is the reconstruction of GRUB menu entries for old configurations."
   ;; exactly to the device field of the <file-system> object representing the
   ;; OS's root file system, so it might be a device path like "/dev/sda3".
   (root-device      boot-parameters-root-device)
+  (boot-device      boot-parameters-boot-device)
+  (boot-type        boot-parameters-boot-type)
   (store-device     boot-parameters-store-device)
   (store-mount-point boot-parameters-store-mount-point)
   (kernel           boot-parameters-kernel)
@@ -826,6 +843,16 @@ this file is the reconstruction of GRUB menu entries for old configurations."
       (label label)
       (root-device root)
 
+      (boot-device
+       (match (assq 'boot-device rest)
+         ((_ args) args)
+         (#f       #f))) ; for compatibility reasons.
+
+      (boot-type
+       (match (assq 'boot-type rest)
+         ((_ args) args)
+         (#f       'grub))) ; for compatibility reasons.
+
       ;; In the past, we would store the directory name of the kernel instead
       ;; of the absolute file name of its image.  Detect that and correct it.
       (kernel (if (string=? linux (direct-store-path linux))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 08/12] scripts: system: Remove unused variables.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (6 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 07/12] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 09/12] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (profile-bootloader-entries): Remove root and
  root-device unused variables.
---
 guix/scripts/system.scm | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index c2212ed14..b1104eb9b 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -389,11 +389,7 @@ NUMBERS, which is a list of generation numbers."
     (unless-file-not-found
      (let* ((file             (string-append system "/parameters"))
             (params           (call-with-input-file file
-                                read-boot-parameters))
-            (root             (boot-parameters-root-device params))
-            (root-device      (if (bytevector? root)
-                                  (uuid->string root)
-                                  root)))
+                                read-boot-parameters)))
        (boot-parameters
         (inherit params)
         (label (string-append (boot-parameters-label params) " (#"
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 09/12] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (7 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 08/12] scripts: system: Remove unused variables Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" " Mathieu Othacehe
                     ` (2 subsequent siblings)
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install-grub*): Rename to install-bootloader. Use
  keys to pass arguments. Pass a new argument, "install-procedure" which is
  a script in store dealing with bootloader-specific install actions.
  Also call "install-boot-config" to install the bootloader config file.
(install-bootloader-derivation): New procedure. It returns a derivation that
builds a file containing "install-procedure" gexp.
(perform-action): Build install-proc derivation and call install-bootloader
with the resulting file. Stop adding GRUB to PATH as bootloaders are called in
install-proc with direct store paths.
---
 guix/scripts/system.scm | 112 +++++++++++++++++++++++++++++-------------------
 1 file changed, 67 insertions(+), 45 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index b1104eb9b..1776dc00f 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -147,27 +147,34 @@ TARGET, and register them."
               (map (cut copy-item <> target #:log-port log-port)
                    to-copy))))
 
-(define (install-grub* grub.cfg device target)
-  "This is a variant of 'install-grub' with error handling, lifted in
-%STORE-MONAD"
-  (let* ((gc-root      (string-append target %gc-roots-directory
-                                      "/grub.cfg"))
-         (temp-gc-root (string-append gc-root ".new"))
-         (delete-file  (lift1 delete-file %store-monad))
-         (make-symlink (lift2 switch-symlinks %store-monad))
-         (rename       (lift2 rename-file %store-monad)))
-    (mbegin %store-monad
-      ;; Prepare the symlink to GRUB.CFG to make sure that it's a GC root when
-      ;; 'install-grub' completes (being a bit paranoid.)
-      (make-symlink temp-gc-root grub.cfg)
-
-      (munless (false-if-exception (install-grub grub.cfg device target))
+(define* (install-bootloader install-procedure
+                             #:key
+                             bootcfg bootcfg-location
+                             device target)
+  "Call INSTALL-PROCEDURE with error handling, in %STORE-MONAD."
+  (with-monad %store-monad
+    (let* ((gc-root      (string-append target %gc-roots-directory
+                                        "/bootcfg"))
+           (temp-gc-root (string-append gc-root ".new"))
+           (install (and install-procedure
+                         (derivation->output-path install-procedure)))
+           (bootcfg (derivation->output-path bootcfg)))
+      ;; Prepare the symlink to bootloader config file to make sure that it's
+      ;; a GC root when 'install-procedure' completes (being a bit paranoid.)
+      (switch-symlinks temp-gc-root bootcfg)
+
+      (unless (false-if-exception
+               (begin
+                 (install-boot-config bootcfg bootcfg-location target)
+                 (when install
+                   (save-load-path-excursion (primitive-load install)))))
         (delete-file temp-gc-root)
-        (leave (_ "failed to install GRUB on device '~a'~%") device))
+        (leave (_ "failed to install bootloader on device ~a '~a'~%") install device))
 
-      ;; Register GRUB.CFG as a GC root so that its dependencies (background
-      ;; image, font, etc.) are not reclaimed.
-      (rename temp-gc-root gc-root))))
+      ;; Register bootloader config file as a GC root so that its dependencies
+      ;; (background image, font, etc.) are not reclaimed.
+      (rename-file temp-gc-root gc-root)
+      (return #t))))
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
@@ -597,17 +604,28 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
     (warning (_ "Consider running 'guix pull' before 'reconfigure'.~%"))
     (warning (_ "Failing to do that may downgrade your system!~%"))))
 
+(define (install-bootloader-derivation install-procedure
+                                       bootloader device target)
+  (with-monad %store-monad
+    (gexp->file "install-bootloader"
+                (with-imported-modules '((guix build utils))
+                  #~(begin
+                      (use-modules (guix build utils))
+                      (#$install-procedure #$bootloader
+                                           #$device
+                                           #$target))))))
+
 (define* (perform-action action os
                          #:key bootloader? dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '())
                          (gc-root #f))
-  "Perform ACTION for OS.  GRUB? specifies whether to install GRUB; DEVICE is
-the target devices for GRUB; TARGET is the target root directory; IMAGE-SIZE
-is the size of the image to be built, for the 'vm-image' and 'disk-image'
-actions.  FULL-BOOT? is used for the 'vm' action; it determines whether to
-boot directly to the kernel or to the bootloader.
+  "Perform ACTION for OS.  BOOTLOADER? specifies whether to install
+bootloader; DEVICE is the target devices for bootloader; TARGET is the target
+root directory; IMAGE-SIZE is the size of the image to be built, for the
+'vm-image' and 'disk-image' actions.  FULL-BOOT? is used for the 'vm' action;
+it determines whether to boot directly to the kernel or to the bootloader.
 
 When DERIVATIONS-ONLY? is true, print the derivation file name(s) without
 building anything.
@@ -630,20 +648,28 @@ output when building a system derivation, such as a disk image."
                      (if bootloader
                          (package->derivation bootloader)
                          (return #f))))
-       (grub.cfg  (if (eq? 'container action)
-                      (return #f)
-                      (operating-system-bootcfg os
-                                                (if (eq? 'init action)
-                                                    '()
-                                                    (profile-grub-entries)))))
-
-       ;; For 'init' and 'reconfigure', always build GRUB.CFG, even if
-       ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
-       ;; root.  See <http://bugs.gnu.org/21068>.
+       (bootcfg  (if (eq? 'container action)
+                     (return #f)
+                     (operating-system-bootcfg
+                      os
+                      (if (eq? 'init action)
+                          '()
+                          (profile-bootloader-entries)))))
+       (bootcfg-location -> (bootloader-configuration-file-name
+                             (operating-system-bootloader os)))
+       (install-proc
+        (let ((procedure (bootloader-configuration-installer
+                          (operating-system-bootloader os)))
+              (target    (or target "/")))
+          (install-bootloader-derivation procedure bootloader device target)))
+
+       ;; For 'init' and 'reconfigure', always build BOOTCFG, even if
+       ;; --no-bootloader is passed, because we then use it as a GC root.
+       ;; See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
                       (if (and bootloader? bootloader)
-                          (list sys grub.cfg bootloader)
-                          (list sys grub.cfg))
+                          (list sys bootcfg bootloader install-proc)
+                          (list sys bootcfg))
                       (list sys)))
        (%         (if derivations-only?
                       (return (for-each (compose println derivation-file-name)
@@ -657,20 +683,16 @@ output when building a system derivation, such as a disk image."
           (for-each (compose println derivation->output-path)
                     drvs)
 
-          ;; Make sure GRUB is accessible.
-          (when (and bootloader? bootloader)
-            (let ((prefix (derivation->output-path bootloader)))
-              (setenv "PATH"
-                      (string-append  prefix "/bin:" prefix "/sbin:"
-                                      (getenv "PATH")))))
-
           (case action
             ((reconfigure)
              (mbegin %store-monad
                (switch-to-system os)
                (mwhen bootloader?
-                 (install-grub* (derivation->output-path grub.cfg)
-                                device "/"))))
+                 (install-bootloader install-proc
+                                     #:bootcfg bootcfg
+                                     #:bootcfg-location bootcfg-location
+                                     #:device device
+                                     #:target "/"))))
             ((init)
              (newline)
              (format #t (_ "initializing operating system under '~a'...~%")
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" to new bootloader API.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (8 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 09/12] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-23  8:39     ` Danny Milosavljevic
  2017-04-17  9:01   ` bug#26339: [PATCH v2 11/12] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 12/12] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
  11 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install): Pass install-proc as a new
argument. Rename other arguments.
Call install-bootloader instead of install-grub*.
(perform-action): Adapt.
---
 guix/scripts/system.scm | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 1776dc00f..880bd8b56 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -178,12 +178,14 @@ TARGET, and register them."
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
-                  grub? grub.cfg device)
-  "Copy the closure of GRUB.CFG, which includes the output of OS-DRV, to
+                  install-proc bootloader?
+                  bootcfg bootcfg-location
+                  device)
+  "Copy the closure of BOOTCFG, which includes the output of OS-DRV, to
 directory TARGET.  TARGET must be an absolute directory name since that's what
 'guix-register' expects.
 
-When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG."
+When BOOTLOADER? is true, install bootloader on DEVICE, using BOOTCFG."
   (define (maybe-copy to-copy)
     (with-monad %store-monad
       (if (string=? target "/")
@@ -212,16 +214,21 @@ the ownership of '~a' may be incorrect!~%")
         (populate (lift2 populate-root-file-system %store-monad)))
 
     (mbegin %store-monad
-      ;; Copy the closure of GRUB.CFG, which includes OS-DIR, GRUB's
-      ;; background image and so on.
-      (maybe-copy grub.cfg)
+      ;; Copy the closure of BOOTCFG, which includes OS-DIR,
+      ;; eventual background image and so on.
+      (maybe-copy
+       (derivation->output-path bootcfg))
 
       ;; Create a bunch of additional files.
       (format log-port "populating '~a'...~%" target)
       (populate os-dir target)
 
-      (mwhen grub?
-        (install-grub* grub.cfg device target)))))
+      (mwhen bootloader?
+        (install-bootloader install-proc
+                            #:bootcfg bootcfg
+                            #:bootcfg-location bootcfg-location
+                            #:device device
+                            #:target target)))))
 
 \f
 ;;;
@@ -698,8 +705,10 @@ output when building a system derivation, such as a disk image."
              (format #t (_ "initializing operating system under '~a'...~%")
                      target)
              (install sys (canonicalize-path target)
-                      #:grub? bootloader?
-                      #:grub.cfg (derivation->output-path grub.cfg)
+                      #:bootloader? bootloader?
+                      #:bootcfg bootcfg
+                      #:bootcfg-location bootcfg-location
+                      #:install-proc install-proc
                       #:device device))
             (else
              ;; All we had to do was to build SYS and maybe register an
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 11/12] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (9 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" " Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  2017-04-17  9:01   ` bug#26339: [PATCH v2 12/12] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (profile-grub-entries): Rename to
  profile-bootloader-entries.
  (reinstall-grub): Rename to reinstall-bootloader. Read boot-device and
  boot-type from parameters file to be able to restore the correct bootloader
  on specified device.
  Factorize bootloader installation code by calling install-bootloader.
 (switch-to-system-generation): Adapt.
---
 guix/scripts/system.scm | 91 +++++++++++++++++++++++--------------------------
 1 file changed, 43 insertions(+), 48 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 880bd8b56..a637f91aa 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -377,26 +377,8 @@ it atomically, and then run OS's activation script."
     (date->string (time-utc->date time)
                   "~Y-~m-~d ~H:~M")))
 
-(define* (profile-boot-parameters #:optional (profile %system-profile)
-                                  (numbers (generation-numbers profile)))
-  "Return a list of 'menu-entry' for the generations of PROFILE specified by
-NUMBERS, which is a list of generation numbers."
-  (define (system->boot-parameters system number time)
-    (unless-file-not-found
-     (let* ((file             (string-append system "/parameters"))
-            (params           (call-with-input-file file
-                                read-boot-parameters)))
-       params)))
-  (let* ((systems (map (cut generation-file-name profile <>)
-                       numbers))
-         (times   (map (lambda (system)
-                         (unless-file-not-found
-                          (stat:mtime (lstat system))))
-                       systems)))
-    (filter-map system->boot-parameters systems numbers times)))
-
-(define* (profile-grub-entries #:optional (profile %system-profile)
-                                  (numbers (generation-numbers profile)))
+(define* (profile-bootloader-entries #:optional (profile %system-profile)
+                                     (numbers (generation-numbers profile)))
   "Return a list of 'menu-entry' for the generations of PROFILE specified by
 NUMBERS, which is a list of generation numbers."
   (define (system->boot-parameters system number time)
@@ -437,50 +419,63 @@ connection to the store."
 ;;;
 (define (switch-to-system-generation store spec)
   "Switch the system profile to the generation specified by SPEC, and
-re-install grub with a grub configuration file that uses the specified system
+re-install bootloader with a configuration file that uses the specified system
 generation as its default entry.  STORE is an open connection to the store."
   (let ((number (relative-generation-spec->number %system-profile spec)))
     (if number
         (begin
-          (reinstall-grub store number)
+          (reinstall-bootloader store number)
           (switch-to-generation* %system-profile number))
         (leave (_ "cannot switch to system generation '~a'~%") spec))))
 
-(define (reinstall-grub store number)
-  "Re-install grub for existing system profile generation NUMBER.  STORE is an
-open connection to the store."
+(define (reinstall-bootloader store number)
+  "Re-install bootloader for existing system profile generation NUMBER.
+STORE is an open connection to the store."
   (let* ((generation (generation-file-name %system-profile number))
          (file (string-append generation "/parameters"))
          (params (unless-file-not-found
                   (call-with-input-file file read-boot-parameters)))
-         (root-device (boot-parameters-root-device params))
+         (boot-device (boot-parameters-boot-device params))
          ;; We don't currently keep track of past menu entries' details.  The
          ;; default values will allow the system to boot, even if they differ
          ;; from the actual past values for this generation's entry.
-         (grub-config (grub-configuration (device root-device)))
+         (boot-config (bootloader-configuration
+                       (inherit (lookup-bootloader-configuration
+                                 (boot-parameters-boot-type params)))
+                       (device boot-device)))
          ;; Make the specified system generation the default entry.
-         (entries (profile-grub-entries %system-profile (list number)))
+         (entries (profile-bootloader-entries %system-profile (list number)))
          (old-generations (delv number (generation-numbers %system-profile)))
-         (old-entries (profile-grub-entries %system-profile old-generations))
-         (grub.cfg (run-with-store store
-                     (grub-configuration-file grub-config
-                                              entries
-                                              #:old-entries old-entries))))
-    (show-what-to-build store (list grub.cfg))
-    (build-derivations store (list grub.cfg))
-    ;; This is basically the same as install-grub*, but for now we avoid
-    ;; re-installing the GRUB boot loader itself onto a device, mainly because
-    ;; we don't in general have access to the same version of the GRUB package
-    ;; which was used when installing this other system generation.
-    (let* ((grub.cfg-path (derivation->output-path grub.cfg))
-           (gc-root (string-append %gc-roots-directory "/grub.cfg"))
-           (temp-gc-root (string-append gc-root ".new")))
-      (switch-symlinks temp-gc-root grub.cfg-path)
-      (unless (false-if-exception (install-grub-config grub.cfg-path "/"))
-        (delete-file temp-gc-root)
-        (leave (_ "failed to re-install GRUB configuration file: '~a'~%")
-               grub.cfg-path))
-      (rename-file temp-gc-root gc-root))))
+         (old-entries (profile-bootloader-entries
+                       %system-profile old-generations)))
+    (run-with-store store
+      (mlet* %store-monad
+          ((bootcfg ((bootloader-configuration-file-generator boot-config)
+                     boot-config entries
+                     #:old-entries old-entries))
+           (bootcfg-location -> (bootloader-configuration-file-name
+                                 boot-config))
+           (bootloader (package->derivation
+                        (bootloader-configuration-bootloader boot-config)))
+           (target -> "/")
+           (install-proc
+            (let ((procedure (bootloader-configuration-installer
+                              boot-config)))
+              (install-bootloader-derivation
+               procedure bootloader boot-device target)))
+           (drvs -> (list bootcfg bootloader install-proc)))
+        (mbegin %store-monad
+          (show-what-to-build* drvs)
+          (built-derivations drvs)
+          ;; PARAMS file may not contain a suitable BOOT-DEVICE. If BOOT-DEVICE
+          ;; is #f do not run INSTALL-PROC during bootloader installation.
+          (install-bootloader (if boot-device
+                                  install-proc
+                                  #f)
+                              #:bootcfg bootcfg
+                              #:bootcfg-location bootcfg-location
+                              #:device boot-device
+                              #:target target))))))
 
 \f
 ;;;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 12/12] scripts: system: Display bootloader device and type in "list-generations".
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
                     ` (10 preceding siblings ...)
  2017-04-17  9:01   ` bug#26339: [PATCH v2 11/12] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
@ 2017-04-17  9:01   ` Mathieu Othacehe
  11 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-17  9:01 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (display-system-generation): Display bootloader
  device and bootloader type.
---
 guix/scripts/system.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index a637f91aa..2ccfbb445 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -534,17 +534,21 @@ list of services."
            (param-file  (string-append generation "/parameters"))
            (params      (call-with-input-file param-file read-boot-parameters))
            (label       (boot-parameters-label params))
+           (boot-type   (boot-parameters-boot-type params))
            (root        (boot-parameters-root-device params))
            (root-device (if (bytevector? root)
                             (uuid->string root)
                             root))
+           (boot-device (boot-parameters-boot-device params))
            (kernel      (boot-parameters-kernel params)))
       (display-generation profile number)
       (format #t (_ "  file name: ~a~%") generation)
       (format #t (_ "  canonical file name: ~a~%") (readlink* generation))
       ;; TRANSLATORS: Please preserve the two-space indentation.
       (format #t (_ "  label: ~a~%") label)
+      (format #t (_ "  bootloader type: ~a~%") boot-type)
       (format #t (_ "  root device: ~a~%") root-device)
+      (format #t (_ "  boot device: ~a~%") boot-device)
       (format #t (_ "  kernel: ~a~%") kernel))))
 
 (define* (list-generations pattern #:optional (profile %system-profile))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 03/12] scripts: system: Rename --no-grub option to --no-bootloader.
  2017-04-17  9:01   ` bug#26339: [PATCH v2 03/12] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
@ 2017-04-17 15:54     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-17 15:54 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Pushed this patch to master as a9eadc06ac57846aaa8fdeb550b32e44f59c9437 (since it's trivial).

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-04-17  9:01   ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
@ 2017-04-17 17:08     ` Danny Milosavljevic
  2017-05-08  9:37     ` Ludovic Courtès
  1 sibling, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-17 17:08 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

Note to self: Ascertain that guix adds "--load" entries to put into grub.cfg after that patch is eventually applied.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them.
  2017-04-17  8:49           ` Mathieu Othacehe
@ 2017-04-18  8:23             ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-04-18  8:23 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hello,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> If we decide that this use case isn't supported, that's fine.  Many other distros make the assumption that there's only one bootloader - which is sometimes good because you can have another bootloader the distribution doesn't know about (in addition to the one the distribution does know about) that supervises all the others.
>
> Well you're right multiple bootloader may co-exist on multiple
> partitions. However I'm not sure how guix would manage more than one
> bootloader at a time ?

I’d be in favor of sticking with the only-one-bootloader assumption.

Maybe we can revisit that later if there’s a need, but for now it seems
much safer to just stick to that (and not block this patch set.)

Thoughts?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" to new bootloader API.
  2017-04-17  9:01   ` bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" " Mathieu Othacehe
@ 2017-04-23  8:39     ` Danny Milosavljevic
  2017-04-23  8:53       ` Danny Milosavljevic
  2017-04-23 16:34       ` Mathieu Othacehe
  0 siblings, 2 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-23  8:39 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> +                  install-proc bootloader?

"installer" instead of "install-proc" ?

> +                  bootcfg bootcfg-location

bootloader-configuration ?
bootloader-configuration-file-name ?

Or is that too verbose ? Hmm...

>      (mbegin %store-monad
> -      ;; Copy the closure of GRUB.CFG, which includes OS-DIR, GRUB's
> -      ;; background image and so on.
> -      (maybe-copy grub.cfg)
> +      ;; Copy the closure of BOOTCFG, which includes OS-DIR,
> +      ;; eventual background image and so on.
> +      (maybe-copy
> +       (derivation->output-path bootcfg))

Does derivation->output-path change anything?

>+                      #:bootloader? bootloader?

What about the bootloader? :)

"install-bootloader?" ?

>+                      #:install-proc

#:bootloader-installer ?

Otherwise LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" to new bootloader API.
  2017-04-23  8:39     ` Danny Milosavljevic
@ 2017-04-23  8:53       ` Danny Milosavljevic
  2017-04-23 16:38         ` Mathieu Othacehe
  2017-04-23 16:34       ` Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-04-23  8:53 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> bootloader-configuration ?
> bootloader-configuration-file-name ?

Probably bad idea.  bootloader-configuration here is something else, right?

Maybe bootloader-configuration-file.drv and bootloader-configuration-file-name ?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" to new bootloader API.
  2017-04-23  8:39     ` Danny Milosavljevic
  2017-04-23  8:53       ` Danny Milosavljevic
@ 2017-04-23 16:34       ` Mathieu Othacehe
  1 sibling, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-23 16:34 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> "installer" instead of "install-proc" ?

Ok for "installer".

>> +      (maybe-copy
>> +       (derivation->output-path bootcfg))
>
> Does derivation->output-path change anything?

Well I guess yes, because maybe-copy is expecting a path and not a
derivation.

>
>>+                      #:bootloader? bootloader?
>
> What about the bootloader? :)
>
> "install-bootloader?" ?

Ok for install-bootloader? :)

>
>>+                      #:install-proc
>
> #:bootloader-installer ?

Seems ok to me.

>
> Otherwise LGTM!

Thanks, I'll publish a rebased version, maybe when your own bootloader
serie will be pushed !

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" to new bootloader API.
  2017-04-23  8:53       ` Danny Milosavljevic
@ 2017-04-23 16:38         ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-04-23 16:38 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> Probably bad idea.  bootloader-configuration here is something else, right?

Yes it's the record name so it might be confusing :).

>
> Maybe bootloader-configuration-file.drv and bootloader-configuration-file-name ?

Ok I'll rename them.

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-04-15 17:27       ` Mathieu Othacehe
@ 2017-05-05  7:13         ` Danny Milosavljevic
  2017-05-05  7:21           ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-05  7:13 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

On Sat, 15 Apr 2017 19:27:09 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> Yes my idea was to use the boot-type to keep track of the installed
> bootloader, for each system generation (and to restore it if needed).

Ah, so this is trying to restore the correct bootloader to the correct device, should the user have switched bootloader of the guix system and then switched back.

OK!

What happens if the user switches to an old generation which doesn't have this new-style parameters file?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-05  7:13         ` Danny Milosavljevic
@ 2017-05-05  7:21           ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-05  7:21 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hey Danny !

> Ah, so this is trying to restore the correct bootloader to the correct device, should the user have switched bootloader of the guix system and then switched back.

That's it.

> What happens if the user switches to an old generation which doesn't have this new-style parameters file?

Well, by default the bootloader is assumed to be grub (because grub is
the only supported bootloader in pre-rework guix).

For the boot-device, it is set to #f if not read in parameter
file. During a switch-genereation if boot-device is #f, the
configuration is updated, but the bootloader is not reinstalled.

It was already what happended before my rework. The bootloader was not
reinstalled because we cannot be certain to reinstall the same grub
version as the one installed.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 0/9] Support non-grub bootloaders.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
  2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
  2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
@ 2017-05-06 15:41 ` Mathieu Othacehe
  2017-05-06 15:41   ` bug#26339: [PATCH v3 1/9] system: Add extlinux support Mathieu Othacehe
                     ` (8 more replies)
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
                   ` (6 subsequent siblings)
  9 siblings, 9 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

Hi,

Here is the third version of the serie. Is is rebased on top
of Danny recent work on bootloaders.

It also take last Danny review into account.

Everything seems to play nice and I can change easily between
syslinux and grub (s/grub-configuration/syslinux-configuration/
in config.scm).

Please note that the documentation still has to be written.

Thanks,

Mathieu

David Craven (1):
  bootloader: Add install procedures and use them.

Mathieu Othacehe (8):
  system: Add extlinux support.
  system: Add bootloader type.
  bootloader: Stop using grub module.
  bootloader: Add device and type to bootloader-configuration record.
  scripts: system: Adapt "reconfigure" to new bootloader API.
  scripts: system: Adapt "init" to new bootloader API.
  scripts: system: Adapt "switch-generation" to new bootloader API.
  scripts: system: Display bootloader device and type in
    "list-generations".

 gnu.scm                   |   3 +-
 gnu/build/install.scm     |  36 ++-----
 gnu/build/vm.scm          |  17 ++--
 gnu/local.mk              |   1 +
 gnu/system.scm            |  33 ++++--
 gnu/system/bootloader.scm | 254 ++++++++++++++++++++++++++++++++++++++++++++++
 gnu/system/grub.scm       |  22 ++--
 gnu/system/vm.scm         |  37 ++++---
 gnu/tests.scm             |   3 +-
 gnu/tests/nfs.scm         |   3 +-
 guix/scripts/system.scm   | 232 ++++++++++++++++++++++++++----------------
 11 files changed, 487 insertions(+), 154 deletions(-)
 create mode 100644 gnu/system/bootloader.scm

-- 
2.12.2

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 1/9] system: Add extlinux support.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 16:41     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 2/9] bootloader: Add install procedures and use them Mathieu Othacehe
                     ` (7 subsequent siblings)
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (operating-system): Add default bootloader.
  (operating-system-grub.cfg): Use bootloader-configuration-file-generator.
* gnu/system/grub.scm (bootloader-configuration->grub-configuration): New
  variable.
  (grub-configuration-file): Use bootloader-configuration->grub-configuration.
* guix/scripts/system.scm (profile-grub-entries): Rename system->grub-entry to
  system->boot-parameters and adjust accordingly.
  (perform-action): Make bootloader optional. Use
  bootloader-configuration-device.
* gnu/system/bootloader.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk              |   1 +
 gnu/system.scm            |  11 ++--
 gnu/system/bootloader.scm | 161 ++++++++++++++++++++++++++++++++++++++++++++++
 gnu/system/grub.scm       |  22 ++++---
 guix/scripts/system.scm   |  19 +++---
 5 files changed, 191 insertions(+), 23 deletions(-)
 create mode 100644 gnu/system/bootloader.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index c93dca64c..e2730a466 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -443,6 +443,7 @@ GNU_SYSTEM_MODULES =				\
 						\
   %D%/system.scm				\
   %D%/system/file-systems.scm			\
+  %D%/system/bootloader.scm			\
   %D%/system/grub.scm				\
   %D%/system/install.scm			\
   %D%/system/linux-container.scm		\
diff --git a/gnu/system.scm b/gnu/system.scm
index 189a13262..b947d982d 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -48,7 +48,7 @@
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services base)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system nss)
   #:use-module (gnu system locale)
@@ -139,8 +139,8 @@ booted from ROOT-DEVICE"
           (default linux-libre))
   (kernel-arguments operating-system-user-kernel-arguments
                     (default '()))                ; list of gexps/strings
-  (bootloader operating-system-bootloader)        ; <grub-configuration>
-
+  (bootloader operating-system-bootloader         ; <bootloader-configuration>
+              (default (extlinux-configuration)))
   (initrd operating-system-initrd                 ; (list fs) -> M derivation
           (default base-initrd))
   (firmware operating-system-firmware             ; list of packages
@@ -754,9 +754,8 @@ populate the \"old entries\" menu."
                            (uuid->string (file-system-device root-fs))
                            (file-system-device root-fs)))
        (entry (operating-system-boot-parameters os system root-device)))
-    (grub-configuration-file (operating-system-bootloader os)
-                             (list entry)
-                              #:old-entries old-entries)))
+    ((bootloader-configuration-file-generator (operating-system-bootloader os))
+     (operating-system-bootloader os) (list entry) #:old-entries old-entries)))
 
 (define (fs->boot-device fs)
   "Given FS, a <file-system> object, return a value suitable for use as the
diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
new file mode 100644
index 000000000..ea067bf73
--- /dev/null
+++ b/gnu/system/bootloader.scm
@@ -0,0 +1,161 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 David Craven <david@craven.ch>
+;;;
+;;; 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/>.
+
+(define-module (gnu system bootloader)
+  #:use-module (gnu system)
+  #:use-module (gnu system grub)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix records)
+  #:use-module (ice-9 match)
+  #:export (bootloader-configuration
+            bootloader-configuration?
+            bootloader-configuration-bootloader
+            bootloader-configuration-device
+            bootloader-configuration-menu-entries
+            bootloader-configuration-default-entry
+            bootloader-configuration-timeout
+            bootloader-configuration-file-generator
+            bootloader-configuration-file-name
+            bootloader-configuration-installer
+            bootloader-configuration-additional-configuration
+
+            extlinux-configuration
+            grub-configuration
+            grub-efi-configuration
+            syslinux-configuration))
+
+;;; Commentary:
+;;;
+;;; Generic configuration for bootloaders.
+;;;
+;;; Code:
+
+(define-record-type* <bootloader-configuration>
+  bootloader-configuration make-bootloader-configuration
+  bootloader-configuration?
+  (bootloader                      bootloader-configuration-bootloader     ; package
+                                   (default #f))
+  (device                          bootloader-configuration-device         ; string
+                                   (default #f))
+  (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
+                                   (default '()))
+  (default-entry                   bootloader-configuration-default-entry  ; integer
+                                   (default 0))
+  (timeout                         bootloader-configuration-timeout        ; integer
+                                   (default 5))
+  (configuration-file-name         bootloader-configuration-file-name
+                                   (default #f))
+  (configuration-file-generator    bootloader-configuration-file-generator ; procedure
+                                   (default #f))
+  (installer                       bootloader-configuration-installer ; procedure
+                                   (default #f))
+  (additional-configuration        bootloader-configuration-additional-configuration ; record
+                                   (default #f)))
+
+\f
+
+;;;
+;;; Extlinux configuration file.
+;;;
+
+(define* (extlinux-configuration-file config entries
+                                      #:key
+                                      (system (%current-system))
+                                      (old-entries '()))
+  "Return the U-Boot configuration file corresponding to CONFIG, a
+<u-boot-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."
+
+  (define all-entries
+    (append entries (bootloader-configuration-menu-entries config)))
+
+  (define (boot-parameters->gexp params)
+    (let ((label (boot-parameters-label params))
+          (kernel (boot-parameters-kernel params))
+          (kernel-arguments (boot-parameters-kernel-arguments params))
+          (initrd (boot-parameters-initrd params)))
+      #~(format port "LABEL ~a
+  MENU LABEL ~a
+  KERNEL ~a
+  FDTDIR ~a/lib/dtbs
+  INITRD ~a
+  APPEND ~a
+~%"
+                #$label #$label
+                #$kernel #$kernel #$initrd
+                (string-join (list #$@kernel-arguments)))))
+
+  (define builder
+    #~(call-with-output-file #$output
+        (lambda (port)
+          (let ((timeout #$(bootloader-configuration-timeout config)))
+            (format port "
+UI menu.c32
+PROMPT ~a
+TIMEOUT ~a~%"
+                    (if (> timeout 0) 1 0)
+                    ;; timeout is expressed in 1/10s of seconds.
+                    (* 10 timeout))
+            #$@(map boot-parameters->gexp all-entries)
+
+            #$@(if (pair? old-entries)
+                   #~((format port "~%")
+                      #$@(map boot-parameters->gexp old-entries)
+                      (format port "~%"))
+                   #~())))))
+
+  (gexp->derivation "extlinux.conf" builder))
+
+
+\f
+
+;;;
+;;; Bootloader configurations.
+;;;
+
+(define* (extlinux-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit config)
+   (configuration-file-name "/boot/extlinux/extlinux.conf")
+   (configuration-file-generator extlinux-configuration-file)))
+
+(define* (grub-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit config)
+   (bootloader (@ (gnu packages bootloaders) grub))
+   (configuration-file-name "/boot/grub/grub.cfg")
+   (configuration-file-generator grub-configuration-file)
+   (installer install-grub)
+   (additional-configuration
+    (let ((additional-config (bootloader-configuration-additional-configuration config)))
+      (if additional-config additional-config %default-theme)))))
+
+(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit (grub-configuration config))
+   (bootloader (@ (gnu packages bootloaders) grub-efi))))
+
+(define* (syslinux-configuration #:optional (config (bootloader-configuration)))
+  (bootloader-configuration
+   (inherit (extlinux-configuration config))
+   (bootloader (@ (gnu packages bootloaders) syslinux))
+   (installer install-syslinux)))
+
+;;; bootloader.scm ends here
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index d2fa984ec..b06336cec 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -27,6 +27,7 @@
   #:use-module (guix download)
   #:use-module (gnu artwork)
   #:use-module (gnu system)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:autoload   (gnu packages bootloaders) (grub)
   #:autoload   (gnu packages compression) (gzip)
@@ -49,14 +50,6 @@
             %background-image
             %default-theme
 
-            grub-configuration
-            grub-configuration?
-            grub-configuration-device
-            grub-configuration-grub
-
-            menu-entry
-            menu-entry?
-
             grub-configuration-file))
 
 ;;; Commentary:
@@ -277,7 +270,16 @@ code."
    (linux-arguments (boot-parameters-kernel-arguments conf))
    (initrd (boot-parameters-initrd conf))))
 
-(define* (grub-configuration-file config entries
+(define (bootloader-configuration->grub-configuration config)
+  (grub-configuration
+   (grub (bootloader-configuration-bootloader config))
+   (device (bootloader-configuration-device config))
+   (menu-entries (bootloader-configuration-menu-entries config))
+   (default-entry (bootloader-configuration-default-entry config))
+   (timeout (bootloader-configuration-timeout config))
+   (theme (bootloader-configuration-additional-configuration config))))
+
+(define* (grub-configuration-file bootloader-config entries
                                   #:key
                                   (system (%current-system))
                                   (old-entries '()))
@@ -285,6 +287,8 @@ code."
 <grub-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."
+  (define config (bootloader-configuration->grub-configuration bootloader-config))
+
   (define all-entries
     (append (map boot-parameters->menu-entry entries)
             (grub-configuration-menu-entries config)))
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 2872bcae6..b96836576 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -38,10 +38,10 @@
   #:use-module (guix build utils)
   #:use-module (gnu build install)
   #:use-module (gnu system)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system linux-container)
   #:use-module (gnu system vm)
-  #:use-module (gnu system grub)
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services herd)
@@ -598,8 +598,11 @@ output when building a system derivation, such as a disk image."
                                                 #:image-size image-size
                                                 #:full-boot? full-boot?
                                                 #:mappings mappings))
-       (grub      (package->derivation (grub-configuration-grub
-                                        (operating-system-bootloader os))))
+       (bootloader (let ((bootloader (bootloader-configuration-bootloader
+                                      (operating-system-bootloader os))))
+                     (if bootloader
+                         (package->derivation bootloader)
+                         (return #f))))
        (grub.cfg  (if (eq? 'container action)
                       (return #f)
                       (operating-system-bootcfg os
@@ -611,8 +614,8 @@ output when building a system derivation, such as a disk image."
        ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
        ;; root.  See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if bootloader?
-                          (list sys grub.cfg grub)
+                      (if (and bootloader? bootloader)
+                          (list sys grub.cfg bootloader)
                           (list sys grub.cfg))
                       (list sys)))
        (%         (if derivations-only?
@@ -628,8 +631,8 @@ output when building a system derivation, such as a disk image."
                     drvs)
 
           ;; Make sure GRUB is accessible.
-          (when bootloader?
-            (let ((prefix (derivation->output-path grub)))
+          (when (and bootloader? bootloader)
+            (let ((prefix (derivation->output-path bootloader)))
               (setenv "PATH"
                       (string-append  prefix "/bin:" prefix "/sbin:"
                                       (getenv "PATH")))))
@@ -832,7 +835,7 @@ resulting from command-line parsing."
                         ((first second) second)
                         (_ #f)))
          (device      (and bootloader?
-                           (grub-configuration-device
+                           (bootloader-configuration-device
                             (operating-system-bootloader os)))))
 
     (with-store store
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 2/9] bootloader: Add install procedures and use them.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
  2017-05-06 15:41   ` bug#26339: [PATCH v3 1/9] system: Add extlinux support Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 16:52     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 3/9] system: Add bootloader type Mathieu Othacehe
                     ` (6 subsequent siblings)
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339; +Cc: David Craven

From: David Craven <david@craven.ch>

* gnu/system/bootloader.scm (dd, install-grub, install-syslinux): New
  procedures.
* gnu/build/install.scm (install-boot-config): New procedure.
  (install-grub): Move to (gnu system bootloader).
* gnu/build/vm.scm (register-bootcfg-root): Rename register-grub.cfg-root and
  adjust accordingly.
  (initialize-hard-disk): Takes a bootloader, bootcfg, bootcfg-location and
  bootloader-installer procedure. Adjust accordingly.
* gnu/system/vm.scm (qemu-image): Adjust to initialize-hard-disk.
  (system-disk-image, system-qemu-image, system-qemu-image/shared-store):
  Adjust to qemu-image.
---
 gnu/build/install.scm     | 36 ++++++++---------------------------
 gnu/build/vm.scm          | 17 +++++++++++------
 gnu/system/bootloader.scm | 48 ++++++++++++++++++++++++++++++++++++++++++++++-
 gnu/system/vm.scm         | 37 ++++++++++++++++++++++++------------
 4 files changed, 91 insertions(+), 47 deletions(-)

diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index 5cb6055a0..9e30c0d23 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -22,8 +22,7 @@
   #:use-module (guix build store-copy)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
-  #:export (install-grub
-            install-grub-config
+  #:export (install-boot-config
             evaluate-populate-directive
             populate-root-file-system
             reset-timestamps
@@ -39,36 +38,17 @@
 ;;;
 ;;; Code:
 
-(define (install-grub grub.cfg device mount-point)
-  "Install GRUB with GRUB.CFG on DEVICE, which is assumed to be mounted on
-MOUNT-POINT.
-
-Note that the caller must make sure that GRUB.CFG is registered as a GC root
-so that the fonts, background images, etc. referred to by GRUB.CFG are not
-GC'd."
-  (install-grub-config grub.cfg mount-point)
-
-  ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or root
-  ;; partition.
-  (setenv "GRUB_ENABLE_CRYPTODISK" "y")
-
-  (unless (zero? (system* "grub-install" "--no-floppy"
-                          "--boot-directory"
-                          (string-append mount-point "/boot")
-                          device))
-    (error "failed to install GRUB")))
-
-(define (install-grub-config grub.cfg mount-point)
-  "Atomically copy GRUB.CFG into boot/grub/grub.cfg on the MOUNT-POINT.  Note
-that the caller must make sure that GRUB.CFG is registered as a GC root so
-that the fonts, background images, etc. referred to by GRUB.CFG are not GC'd."
-  (let* ((target (string-append mount-point "/boot/grub/grub.cfg"))
+(define (install-boot-config bootcfg bootcfg-location mount-point)
+  "Atomically copy BOOTCFG into BOOTCFG-LOCATION on the MOUNT-POINT.  Note
+that the caller must make sure that BOOTCFG is registered as a GC root so
+that the fonts, background images, etc. referred to by BOOTCFG are not GC'd."
+  (let* ((target (string-append mount-point bootcfg-location))
          (pivot  (string-append target ".new")))
     (mkdir-p (dirname target))
 
-    ;; Copy GRUB.CFG instead of just symlinking it, because symlinks won't
+    ;; Copy BOOTCFG instead of just symlinking it, because symlinks won't
     ;; work when /boot is on a separate partition.  Do that atomically.
-    (copy-file grub.cfg pivot)
+    (copy-file bootcfg pivot)
     (rename-file pivot target)))
 
 (define (evaluate-populate-directive directive target)
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 1eb9a4c45..440596a40 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -285,15 +285,18 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
     (unless register-closures?
       (reset-timestamps target))))
 
-(define (register-grub.cfg-root target bootcfg)
+(define (register-bootcfg-root target bootcfg)
   "On file system TARGET, register BOOTCFG as a GC root."
   (let ((directory (string-append target "/var/guix/gcroots")))
     (mkdir-p directory)
-    (symlink bootcfg (string-append directory "/grub.cfg"))))
+    (symlink bootcfg (string-append directory "/bootcfg"))))
 
 (define* (initialize-hard-disk device
                                #:key
-                               grub.cfg
+                               bootloader
+                               bootcfg
+                               bootcfg-location
+                               bootloader-installer
                                (partitions '()))
   "Initialize DEVICE as a disk containing all the <partition> objects listed
 in PARTITIONS, and using BOOTCFG as its bootloader configuration file.
@@ -311,10 +314,12 @@ passing it a directory name where it is mounted."
     (display "mounting root partition...\n")
     (mkdir-p target)
     (mount (partition-device root) target (partition-file-system root))
-    (install-grub grub.cfg device target)
+    (install-boot-config bootcfg bootcfg-location target)
+    (when bootloader-installer
+      (bootloader-installer bootloader device target))
 
-    ;; Register GRUB.CFG as a GC root.
-    (register-grub.cfg-root target grub.cfg)
+    ;; Register BOOTCFG as a GC root.
+    (register-bootcfg-root target bootcfg)
 
     (umount target)))
 
diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
index ea067bf73..fddf038b8 100644
--- a/gnu/system/bootloader.scm
+++ b/gnu/system/bootloader.scm
@@ -38,7 +38,10 @@
             extlinux-configuration
             grub-configuration
             grub-efi-configuration
-            syslinux-configuration))
+            syslinux-configuration
+
+            install-grub
+            install-syslinux))
 
 ;;; Commentary:
 ;;;
@@ -158,4 +161,47 @@ TIMEOUT ~a~%"
    (bootloader (@ (gnu packages bootloaders) syslinux))
    (installer install-syslinux)))
 
+\f
+
+;;;
+;;; Bootloader install procedures.
+;;;
+
+(define dd
+  #~(lambda (bs count if of)
+      (zero? (system* "dd"
+                      (string-append "bs=" (number->string bs))
+                      (string-append "count=" (number->string count))
+                      (string-append "if=" if)
+                      (string-append "of=" of)))))
+
+(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")
+
+        (unless (zero? (system* grub "--no-floppy"
+                                "--boot-directory" install-dir
+                                device))
+          (error "failed to install GRUB")))))
+
+(define install-syslinux
+  #~(lambda (bootloader device mount-point)
+      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
+            (install-dir (string-append mount-point "/boot/extlinux"))
+            (syslinux-dir (string-append bootloader "/share/syslinux")))
+        (mkdir-p install-dir)
+        (for-each (lambda (file)
+                    (copy-file file
+                               (string-append install-dir "/" (basename file))))
+                  (find-files syslinux-dir "\\.c32$"))
+
+        (unless (and (zero? (system* extlinux "--install" install-dir))
+                     (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
+          (error "failed to install SYSLINUX")))))
+
 ;;; bootloader.scm ends here
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 2c8b954c8..cc13abe2a 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -46,10 +46,10 @@
                 #:select (%guile-static-stripped))
   #:use-module (gnu packages admin)
 
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system pam)
   #:use-module (gnu system linux-initrd)
-  #:use-module (gnu system grub)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system)
   #:use-module (gnu services)
@@ -176,8 +176,9 @@ made available under the /xchg CIFS share."
                      (disk-image-format "qcow2")
                      (file-system-type "ext4")
                      file-system-label
-                     os-derivation
-                     grub-configuration
+                     os.drv
+                     bootcfg.drv
+                     bootloader-configuration
                      (register-closures? #t)
                      (inputs '())
                      copy-inputs?)
@@ -201,7 +202,7 @@ the image."
                       (guix build utils))
 
          (let ((inputs
-                '#$(append (list qemu parted grub e2fsprogs)
+                '#$(append (list qemu parted e2fsprogs)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -223,7 +224,7 @@ the image."
                                #:closures graphs
                                #:copy-closures? #$copy-inputs?
                                #:register-closures? #$register-closures?
-                               #:system-directory #$os-derivation))
+                               #:system-directory #$os.drv))
                   (partitions (list (partition
                                      (size #$(- disk-image-size
                                                 (* 10 (expt 2 20))))
@@ -233,7 +234,16 @@ the image."
                                      (initializer initialize)))))
              (initialize-hard-disk "/dev/vda"
                                    #:partitions partitions
-                                   #:grub.cfg #$grub-configuration)
+                                   #:bootloader
+                                   #$(bootloader-configuration-bootloader
+                                      bootloader-configuration)
+                                   #:bootcfg #$bootcfg.drv
+                                   #:bootcfg-location
+                                   #$(bootloader-configuration-file-name
+                                      bootloader-configuration)
+                                   #:bootloader-installer
+                                   #$(bootloader-configuration-installer
+                                      bootloader-configuration))
              (reboot)))))
    #:system system
    #:make-disk-image? #t
@@ -287,8 +297,9 @@ to USB sticks meant to be read-only."
     (mlet* %store-monad ((os-drv   (operating-system-derivation os))
                          (bootcfg  (operating-system-bootcfg os)))
       (qemu-image #:name name
-                  #:os-derivation os-drv
-                  #:grub-configuration bootcfg
+                  #:os.drv os-drv
+                  #:bootcfg.drv bootcfg
+                  #:bootloader-configuration (operating-system-bootloader os)
                   #:disk-image-size disk-image-size
                   #:disk-image-format "raw"
                   #:file-system-type file-system-type
@@ -330,8 +341,9 @@ of the GNU system as described by OS."
     (mlet* %store-monad
         ((os-drv      (operating-system-derivation os))
          (bootcfg     (operating-system-bootcfg os)))
-      (qemu-image  #:os-derivation os-drv
-                   #:grub-configuration bootcfg
+      (qemu-image  #:os.drv os-drv
+                   #:bootcfg.drv bootcfg
+                   #:bootloader-configuration (operating-system-bootloader os)
                    #:disk-image-size disk-image-size
                    #:file-system-type file-system-type
                    #:inputs `(("system" ,os-drv)
@@ -429,8 +441,9 @@ bootloader refers to: OS kernel, initrd, bootloader data, etc."
     ;; BOOTCFG and all its dependencies, including the output of OS-DRV.
     ;; This is more than needed (we only need the kernel, initrd, GRUB for its
     ;; font, and the background image), but it's hard to filter that.
-    (qemu-image #:os-derivation os-drv
-                #:grub-configuration bootcfg
+    (qemu-image #:os.drv os-drv
+                #:bootcfg.drv bootcfg
+                #:bootloader-configuration (operating-system-bootloader os)
                 #:disk-image-size disk-image-size
                 #:inputs (if full-boot?
                              `(("bootcfg" ,bootcfg))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 3/9] system: Add bootloader type.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
  2017-05-06 15:41   ` bug#26339: [PATCH v3 1/9] system: Add extlinux support Mathieu Othacehe
  2017-05-06 15:41   ` bug#26339: [PATCH v3 2/9] bootloader: Add install procedures and use them Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 16:55     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 4/9] bootloader: Stop using grub module Mathieu Othacehe
                     ` (5 subsequent siblings)
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* gnu/system/bootloader.scm
(<bootloader-configuration>)[type]: New field.
(%extlinux-configuration, %grub-configuration, %grub-efi-configuration,
%syslinux-configuration): New exported variables.
(extlinux-configuration, grub-configuration, grub-efi-configuration,
syslinux-configuration): New exported compatibility macros.
---
 gnu/system/bootloader.scm | 119 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 83 insertions(+), 36 deletions(-)

diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm
index fddf038b8..bab6cfab3 100644
--- a/gnu/system/bootloader.scm
+++ b/gnu/system/bootloader.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 David Craven <david@craven.ch>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,10 +23,12 @@
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
+  #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
   #:export (bootloader-configuration
             bootloader-configuration?
             bootloader-configuration-bootloader
+            bootloader-configuration-type
             bootloader-configuration-device
             bootloader-configuration-menu-entries
             bootloader-configuration-default-entry
@@ -35,6 +38,13 @@
             bootloader-configuration-installer
             bootloader-configuration-additional-configuration
 
+            %extlinux-configuration
+            %grub-configuration
+            %grub-efi-configuration
+            %syslinux-configuration
+
+            lookup-bootloader-configuration
+
             extlinux-configuration
             grub-configuration
             grub-efi-configuration
@@ -54,6 +64,8 @@
   bootloader-configuration?
   (bootloader                      bootloader-configuration-bootloader     ; package
                                    (default #f))
+  (type                            bootloader-configuration-type
+                                   (default #f))                           ; symbol
   (device                          bootloader-configuration-device         ; string
                                    (default #f))
   (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
@@ -126,43 +138,7 @@ TIMEOUT ~a~%"
 
   (gexp->derivation "extlinux.conf" builder))
 
-
-\f
-
-;;;
-;;; Bootloader configurations.
-;;;
-
-(define* (extlinux-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit config)
-   (configuration-file-name "/boot/extlinux/extlinux.conf")
-   (configuration-file-generator extlinux-configuration-file)))
-
-(define* (grub-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit config)
-   (bootloader (@ (gnu packages bootloaders) grub))
-   (configuration-file-name "/boot/grub/grub.cfg")
-   (configuration-file-generator grub-configuration-file)
-   (installer install-grub)
-   (additional-configuration
-    (let ((additional-config (bootloader-configuration-additional-configuration config)))
-      (if additional-config additional-config %default-theme)))))
-
-(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit (grub-configuration config))
-   (bootloader (@ (gnu packages bootloaders) grub-efi))))
-
-(define* (syslinux-configuration #:optional (config (bootloader-configuration)))
-  (bootloader-configuration
-   (inherit (extlinux-configuration config))
-   (bootloader (@ (gnu packages bootloaders) syslinux))
-   (installer install-syslinux)))
-
 \f
-
 ;;;
 ;;; Bootloader install procedures.
 ;;;
@@ -204,4 +180,75 @@ TIMEOUT ~a~%"
                      (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
           (error "failed to install SYSLINUX")))))
 
+\f
+;;;
+;;; Bootloader configurations.
+;;;
+
+(define* %extlinux-configuration
+  (bootloader-configuration
+   (type 'extlinux)
+   (configuration-file-name "/boot/extlinux/extlinux.conf")
+   (configuration-file-generator extlinux-configuration-file)))
+
+(define* %grub-configuration
+  (bootloader-configuration
+   (type 'grub)
+   (bootloader (@ (gnu packages bootloaders) grub))
+   (configuration-file-name "/boot/grub/grub.cfg")
+   (configuration-file-generator grub-configuration-file)
+   (installer install-grub)
+   (additional-configuration %default-theme)))
+
+(define* %grub-efi-configuration
+  (bootloader-configuration
+   (inherit %grub-configuration)
+   (type 'grub-efi)
+   (bootloader (@ (gnu packages bootloaders) grub-efi))))
+
+(define* %syslinux-configuration
+  (bootloader-configuration
+   (inherit %extlinux-configuration)
+   (type 'syslinux)
+   (bootloader (@ (gnu packages bootloaders) syslinux))
+   (installer install-syslinux)))
+
+(define %bootloader-configurations
+  (list %extlinux-configuration
+        %grub-configuration
+        %grub-efi-configuration
+        %syslinux-configuration))
+
+(define (lookup-bootloader-configuration type)
+  (or (find (lambda (conf)
+              (eq? (bootloader-configuration-type conf)
+                   type))
+            %bootloader-configurations)
+      (error "~a: unknown bootloader type" type)))
+
+\f
+;;;
+;;; Compatibility macros.
+;;;
+
+(define-syntax-rule (extlinux-configuration fields ...)
+  (bootloader-configuration
+   (inherit %extlinux-configuration)
+   fields ...))
+
+(define-syntax-rule (grub-configuration fields ...)
+  (bootloader-configuration
+   (inherit %grub-configuration)
+   fields ...))
+
+(define-syntax-rule (grub-efi-configuration fields ...)
+  (bootloader-configuration
+   (inherit %grub-efi-configuration)
+   fields ...))
+
+(define-syntax-rule (syslinux-configuration fields ...)
+  (bootloader-configuration
+   (inherit %syslinux-configuration)
+   fields ...))
+
 ;;; bootloader.scm ends here
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 4/9] bootloader: Stop using grub module.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
                     ` (2 preceding siblings ...)
  2017-05-06 15:41   ` bug#26339: [PATCH v3 3/9] system: Add bootloader type Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 16:53     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 5/9] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
                     ` (4 subsequent siblings)
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* gnu.scm (%public-modules): Replace grub by bootloader.
* gnu/tests.scm (define-module): Ditto.
* gnu/tests/nfs.scm (define-module): Ditto.
---
 gnu.scm           | 3 ++-
 gnu/tests.scm     | 3 ++-
 gnu/tests/nfs.scm | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gnu.scm b/gnu.scm
index 932e4cdd5..56b84b74d 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Joshua S. Grant <jgrant@parenthetical.io>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,7 +35,7 @@
       '((gnu system)
         (gnu system mapped-devices)
         (gnu system file-systems)
-        (gnu system grub)                         ; 'grub-configuration'
+        (gnu system bootloader)
         (gnu system pam)
         (gnu system shadow)                       ; 'user-account'
         (gnu system linux-initrd)
diff --git a/gnu/tests.scm b/gnu/tests.scm
index 810711ab9..d162f441f 100644
--- a/gnu/tests.scm
+++ b/gnu/tests.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,7 +22,7 @@
   #:use-module (guix utils)
   #:use-module (guix records)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu services)
diff --git a/gnu/tests/nfs.scm b/gnu/tests/nfs.scm
index 1f28f5a5b..432fc83a1 100644
--- a/gnu/tests/nfs.scm
+++ b/gnu/tests/nfs.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 John Darrington <jmd@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +21,7 @@
 (define-module (gnu tests nfs)
   #:use-module (gnu tests)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
+  #:use-module (gnu system bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu system vm)
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 5/9] bootloader: Add device and type to bootloader-configuration record.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
                     ` (3 preceding siblings ...)
  2017-05-06 15:41   ` bug#26339: [PATCH v3 4/9] bootloader: Stop using grub module Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 20:59     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
                     ` (3 subsequent siblings)
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (<boot-parameters>)[device, type]: New fields.
(boot-parameters-boot-device): New exported procedure.
(boot-parameters-boot-type): Ditto.
(operating-system-grub.cfg): Add new fields.
(operating-system-parameters-file): Add new fields and replace GRUB by
bootloader in doctype.
(read-boot-parameters): Ditto.
---
 gnu/system.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gnu/system.scm b/gnu/system.scm
index b947d982d..6d4cbf737 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -104,6 +104,8 @@
             boot-parameters?
             boot-parameters-label
             boot-parameters-root-device
+            boot-parameters-boot-device
+            boot-parameters-boot-type
             boot-parameters-store-device
             boot-parameters-store-mount-point
             boot-parameters-kernel
@@ -772,6 +774,10 @@ kernel arguments for that derivation to <boot-parameters>."
   (mlet* %store-monad
       ((initrd (operating-system-initrd-file os))
        (store -> (operating-system-store-file-system os))
+       (boot-device -> (bootloader-configuration-device
+                        (operating-system-bootloader os)))
+       (boot-type -> (bootloader-configuration-type
+                      (operating-system-bootloader os)))
        (label -> (kernel->boot-label (operating-system-kernel os))))
     (return (boot-parameters
              (label label)
@@ -782,6 +788,8 @@ kernel arguments for that derivation to <boot-parameters>."
                 (operating-system-kernel-arguments os system.drv root-device)
                 (operating-system-user-kernel-arguments os)))
              (initrd initrd)
+             (boot-device boot-device)
+             (boot-type boot-type)
              (store-device (fs->boot-device store))
              (store-mount-point (file-system-mount-point store))))))
 
@@ -807,6 +815,8 @@ being stored into the \"parameters\" file)."
                     (kernel-arguments
                      #$(boot-parameters-kernel-arguments params))
                     (initrd #$(boot-parameters-initrd params))
+                    (boot-device #$(boot-parameters-boot-device params))
+                    (boot-type #$(boot-parameters-boot-type params))
                     (store
                      (device #$(boot-parameters-store-device params))
                      (mount-point #$(boot-parameters-store-mount-point params))))
@@ -828,6 +838,8 @@ being stored into the \"parameters\" file)."
   ;; exactly to the device field of the <file-system> object representing the
   ;; OS's root file system, so it might be a device path like "/dev/sda3".
   (root-device      boot-parameters-root-device)
+  (boot-device      boot-parameters-boot-device)
+  (boot-type        boot-parameters-boot-type)
   (store-device     boot-parameters-store-device)
   (store-mount-point boot-parameters-store-mount-point)
   (kernel           boot-parameters-kernel)
@@ -846,6 +858,16 @@ being stored into the \"parameters\" file)."
       (label label)
       (root-device root)
 
+      (boot-device
+       (match (assq 'boot-device rest)
+         ((_ args) args)
+         (#f       #f))) ; for compatibility reasons.
+
+      (boot-type
+       (match (assq 'boot-type rest)
+         ((_ args) args)
+         (#f       'grub))) ; for compatibility reasons.
+
       ;; In the past, we would store the directory name of the kernel instead
       ;; of the absolute file name of its image.  Detect that and correct it.
       (kernel (if (string=? linux (direct-store-path linux))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
                     ` (4 preceding siblings ...)
  2017-05-06 15:41   ` bug#26339: [PATCH v3 5/9] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 20:33     ` Danny Milosavljevic
  2017-05-07 21:14     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 7/9] scripts: system: Adapt "init" " Mathieu Othacehe
                     ` (2 subsequent siblings)
  8 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install-grub*): Rename to install-bootloader. Use
  keys to pass arguments. Pass a new argument, "install-procedure" which is
  a script in store dealing with bootloader-specific install actions.
  Also call "install-boot-config" to install the bootloader config file.
(install-bootloader-derivation): New procedure. It returns a derivation that
builds a file containing "install-procedure" gexp.
(perform-action): Build install-proc derivation and call install-bootloader
with the resulting file. Stop adding GRUB to PATH as bootloaders are called in
install-proc with direct store paths.
---
 guix/scripts/system.scm | 112 +++++++++++++++++++++++++++++-------------------
 1 file changed, 67 insertions(+), 45 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index b96836576..0a066853a 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -147,27 +147,34 @@ TARGET, and register them."
               (map (cut copy-item <> target #:log-port log-port)
                    to-copy))))
 
-(define (install-grub* grub.cfg device target)
-  "This is a variant of 'install-grub' with error handling, lifted in
-%STORE-MONAD"
-  (let* ((gc-root      (string-append target %gc-roots-directory
-                                      "/grub.cfg"))
-         (temp-gc-root (string-append gc-root ".new"))
-         (delete-file  (lift1 delete-file %store-monad))
-         (make-symlink (lift2 switch-symlinks %store-monad))
-         (rename       (lift2 rename-file %store-monad)))
-    (mbegin %store-monad
-      ;; Prepare the symlink to GRUB.CFG to make sure that it's a GC root when
-      ;; 'install-grub' completes (being a bit paranoid.)
-      (make-symlink temp-gc-root grub.cfg)
-
-      (munless (false-if-exception (install-grub grub.cfg device target))
+(define* (install-bootloader install-procedure
+                             #:key
+                             bootcfg bootcfg-location
+                             device target)
+  "Call INSTALL-PROCEDURE with error handling, in %STORE-MONAD."
+  (with-monad %store-monad
+    (let* ((gc-root      (string-append target %gc-roots-directory
+                                        "/bootcfg"))
+           (temp-gc-root (string-append gc-root ".new"))
+           (install (and install-procedure
+                         (derivation->output-path install-procedure)))
+           (bootcfg (derivation->output-path bootcfg)))
+      ;; Prepare the symlink to bootloader config file to make sure that it's
+      ;; a GC root when 'install-procedure' completes (being a bit paranoid.)
+      (switch-symlinks temp-gc-root bootcfg)
+
+      (unless (false-if-exception
+               (begin
+                 (install-boot-config bootcfg bootcfg-location target)
+                 (when install
+                   (save-load-path-excursion (primitive-load install)))))
         (delete-file temp-gc-root)
-        (leave (G_ "failed to install GRUB on device '~a'~%") device))
+        (leave (G_ "failed to install bootloader on device ~a '~a'~%") install device))
 
-      ;; Register GRUB.CFG as a GC root so that its dependencies (background
-      ;; image, font, etc.) are not reclaimed.
-      (rename temp-gc-root gc-root))))
+      ;; Register bootloader config file as a GC root so that its dependencies
+      ;; (background image, font, etc.) are not reclaimed.
+      (rename-file temp-gc-root gc-root)
+      (return #t))))
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
@@ -570,17 +577,28 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
     (warning (G_ "Consider running 'guix pull' before 'reconfigure'.~%"))
     (warning (G_ "Failing to do that may downgrade your system!~%"))))
 
+(define (install-bootloader-derivation install-procedure
+                                       bootloader device target)
+  (with-monad %store-monad
+    (gexp->file "install-bootloader"
+                (with-imported-modules '((guix build utils))
+                  #~(begin
+                      (use-modules (guix build utils))
+                      (#$install-procedure #$bootloader
+                                           #$device
+                                           #$target))))))
+
 (define* (perform-action action os
                          #:key bootloader? dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '())
                          (gc-root #f))
-  "Perform ACTION for OS.  GRUB? specifies whether to install GRUB; DEVICE is
-the target devices for GRUB; TARGET is the target root directory; IMAGE-SIZE
-is the size of the image to be built, for the 'vm-image' and 'disk-image'
-actions.  FULL-BOOT? is used for the 'vm' action; it determines whether to
-boot directly to the kernel or to the bootloader.
+  "Perform ACTION for OS.  BOOTLOADER? specifies whether to install
+bootloader; DEVICE is the target devices for bootloader; TARGET is the target
+root directory; IMAGE-SIZE is the size of the image to be built, for the
+'vm-image' and 'disk-image' actions.  FULL-BOOT? is used for the 'vm' action;
+it determines whether to boot directly to the kernel or to the bootloader.
 
 When DERIVATIONS-ONLY? is true, print the derivation file name(s) without
 building anything.
@@ -603,20 +621,28 @@ output when building a system derivation, such as a disk image."
                      (if bootloader
                          (package->derivation bootloader)
                          (return #f))))
-       (grub.cfg  (if (eq? 'container action)
-                      (return #f)
-                      (operating-system-bootcfg os
-                                                (if (eq? 'init action)
-                                                    '()
-                                                    (profile-boot-parameters)))))
-
-       ;; For 'init' and 'reconfigure', always build GRUB.CFG, even if
-       ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
-       ;; root.  See <http://bugs.gnu.org/21068>.
+       (bootcfg  (if (eq? 'container action)
+                     (return #f)
+                     (operating-system-bootcfg
+                      os
+                      (if (eq? 'init action)
+                          '()
+                          (profile-boot-parameters)))))
+       (bootcfg-location -> (bootloader-configuration-file-name
+                             (operating-system-bootloader os)))
+       (install-proc
+        (let ((procedure (bootloader-configuration-installer
+                          (operating-system-bootloader os)))
+              (target    (or target "/")))
+          (install-bootloader-derivation procedure bootloader device target)))
+
+       ;; For 'init' and 'reconfigure', always build BOOTCFG, even if
+       ;; --no-bootloader is passed, because we then use it as a GC root.
+       ;; See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
                       (if (and bootloader? bootloader)
-                          (list sys grub.cfg bootloader)
-                          (list sys grub.cfg))
+                          (list sys bootcfg bootloader install-proc)
+                          (list sys bootcfg))
                       (list sys)))
        (%         (if derivations-only?
                       (return (for-each (compose println derivation-file-name)
@@ -630,20 +656,16 @@ output when building a system derivation, such as a disk image."
           (for-each (compose println derivation->output-path)
                     drvs)
 
-          ;; Make sure GRUB is accessible.
-          (when (and bootloader? bootloader)
-            (let ((prefix (derivation->output-path bootloader)))
-              (setenv "PATH"
-                      (string-append  prefix "/bin:" prefix "/sbin:"
-                                      (getenv "PATH")))))
-
           (case action
             ((reconfigure)
              (mbegin %store-monad
                (switch-to-system os)
                (mwhen bootloader?
-                 (install-grub* (derivation->output-path grub.cfg)
-                                device "/"))))
+                 (install-bootloader install-proc
+                                     #:bootcfg bootcfg
+                                     #:bootcfg-location bootcfg-location
+                                     #:device device
+                                     #:target "/"))))
             ((init)
              (newline)
              (format #t (G_ "initializing operating system under '~a'...~%")
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 7/9] scripts: system: Adapt "init" to new bootloader API.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
                     ` (5 preceding siblings ...)
  2017-05-06 15:41   ` bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 21:08     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 8/9] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
  2017-05-06 15:41   ` bug#26339: [PATCH v3 9/9] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install): Pass installer a new
argument. Rename other arguments.
Call install-bootloader instead of install-grub*.
(perform-action): Adapt.
---
 guix/scripts/system.scm | 46 ++++++++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 0a066853a..b3e2d7b72 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -178,12 +178,14 @@ TARGET, and register them."
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
-                  grub? grub.cfg device)
-  "Copy the closure of GRUB.CFG, which includes the output of OS-DRV, to
+                  installer install-bootloader?
+                  bootcfg bootcfg-location
+                  device)
+  "Copy the closure of BOOTCFG, which includes the output of OS-DRV, to
 directory TARGET.  TARGET must be an absolute directory name since that's what
 'guix-register' expects.
 
-When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG."
+When INSTALL-BOOTLOADER? is true, install bootloader on DEVICE, using BOOTCFG."
   (define (maybe-copy to-copy)
     (with-monad %store-monad
       (if (string=? target "/")
@@ -212,16 +214,21 @@ the ownership of '~a' may be incorrect!~%")
         (populate (lift2 populate-root-file-system %store-monad)))
 
     (mbegin %store-monad
-      ;; Copy the closure of GRUB.CFG, which includes OS-DIR, GRUB's
-      ;; background image and so on.
-      (maybe-copy grub.cfg)
+      ;; Copy the closure of BOOTCFG, which includes OS-DIR,
+      ;; eventual background image and so on.
+      (maybe-copy
+       (derivation->output-path bootcfg))
 
       ;; Create a bunch of additional files.
       (format log-port "populating '~a'...~%" target)
       (populate os-dir target)
 
-      (mwhen grub?
-        (install-grub* grub.cfg device target)))))
+      (mwhen install-bootloader?
+        (install-bootloader installer
+                            #:bootcfg bootcfg
+                            #:bootcfg-location bootcfg-location
+                            #:device device
+                            #:target target)))))
 
 \f
 ;;;
@@ -589,12 +596,13 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
                                            #$target))))))
 
 (define* (perform-action action os
-                         #:key bootloader? dry-run? derivations-only?
+                         #:key install-bootloader?
+                         dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '())
                          (gc-root #f))
-  "Perform ACTION for OS.  BOOTLOADER? specifies whether to install
+  "Perform ACTION for OS.  INSTALL-BOOTLOADER? specifies whether to install
 bootloader; DEVICE is the target devices for bootloader; TARGET is the target
 root directory; IMAGE-SIZE is the size of the image to be built, for the
 'vm-image' and 'disk-image' actions.  FULL-BOOT? is used for the 'vm' action;
@@ -630,7 +638,7 @@ output when building a system derivation, such as a disk image."
                           (profile-boot-parameters)))))
        (bootcfg-location -> (bootloader-configuration-file-name
                              (operating-system-bootloader os)))
-       (install-proc
+       (installer
         (let ((procedure (bootloader-configuration-installer
                           (operating-system-bootloader os)))
               (target    (or target "/")))
@@ -640,8 +648,8 @@ output when building a system derivation, such as a disk image."
        ;; --no-bootloader is passed, because we then use it as a GC root.
        ;; See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if (and bootloader? bootloader)
-                          (list sys bootcfg bootloader install-proc)
+                      (if (and install-bootloader? bootloader)
+                          (list sys bootcfg bootloader installer)
                           (list sys bootcfg))
                       (list sys)))
        (%         (if derivations-only?
@@ -660,8 +668,8 @@ output when building a system derivation, such as a disk image."
             ((reconfigure)
              (mbegin %store-monad
                (switch-to-system os)
-               (mwhen bootloader?
-                 (install-bootloader install-proc
+               (mwhen install-bootloader?
+                 (install-bootloader installer
                                      #:bootcfg bootcfg
                                      #:bootcfg-location bootcfg-location
                                      #:device device
@@ -671,8 +679,10 @@ output when building a system derivation, such as a disk image."
              (format #t (G_ "initializing operating system under '~a'...~%")
                      target)
              (install sys (canonicalize-path target)
-                      #:grub? bootloader?
-                      #:grub.cfg (derivation->output-path grub.cfg)
+                      #:install-bootloader? install-bootloader?
+                      #:bootcfg bootcfg
+                      #:bootcfg-location bootcfg-location
+                      #:installer installer
                       #:device device))
             (else
              ;; All we had to do was to build SYS and maybe register an
@@ -884,7 +894,7 @@ resulting from command-line parsing."
                                                        m)
                                                       (_ #f))
                                                     opts)
-                             #:bootloader? bootloader?
+                             #:install-bootloader? bootloader?
                              #:target target #:device device
                              #:gc-root (assoc-ref opts 'gc-root)))))
         #:system system))))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 8/9] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
                     ` (6 preceding siblings ...)
  2017-05-06 15:41   ` bug#26339: [PATCH v3 7/9] scripts: system: Adapt "init" " Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 20:54     ` Danny Milosavljevic
  2017-05-06 15:41   ` bug#26339: [PATCH v3 9/9] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (reinstall-grub): Rename to
  reinstall-bootloader. Read boot-device and boot-type from parameters file to
  be able to restore the correct bootloader on specified device.
  Factorize bootloader installation code by calling install-bootloader.
 (switch-to-system-generation): Adapt.
---
 guix/scripts/system.scm | 67 +++++++++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 27 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index b3e2d7b72..adab1cedb 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -412,49 +412,62 @@ connection to the store."
 ;;;
 (define (switch-to-system-generation store spec)
   "Switch the system profile to the generation specified by SPEC, and
-re-install grub with a grub configuration file that uses the specified system
+re-install bootloader with a configuration file that uses the specified system
 generation as its default entry.  STORE is an open connection to the store."
   (let ((number (relative-generation-spec->number %system-profile spec)))
     (if number
         (begin
-          (reinstall-grub store number)
+          (reinstall-bootloader store number)
           (switch-to-generation* %system-profile number))
         (leave (G_ "cannot switch to system generation '~a'~%") spec))))
 
-(define (reinstall-grub store number)
-  "Re-install grub for existing system profile generation NUMBER.  STORE is an
-open connection to the store."
+(define (reinstall-bootloader store number)
+  "Re-install bootloader for existing system profile generation NUMBER.
+STORE is an open connection to the store."
   (let* ((generation (generation-file-name %system-profile number))
          (params (unless-file-not-found
                   (read-boot-parameters-file generation)))
-         (root-device (boot-parameters-root-device params))
+         (boot-device (boot-parameters-boot-device params))
          ;; We don't currently keep track of past menu entries' details.  The
          ;; default values will allow the system to boot, even if they differ
          ;; from the actual past values for this generation's entry.
-         (grub-config (grub-configuration (device root-device)))
+         (boot-config (bootloader-configuration
+                       (inherit (lookup-bootloader-configuration
+                                 (boot-parameters-boot-type params)))
+                       (device boot-device)))
          ;; Make the specified system generation the default entry.
          (entries (profile-boot-parameters %system-profile (list number)))
          (old-generations (delv number (generation-numbers %system-profile)))
-         (old-entries (profile-boot-parameters %system-profile old-generations))
-         (grub.cfg (run-with-store store
-                     (grub-configuration-file grub-config
-                                              entries
-                                              #:old-entries old-entries))))
-    (show-what-to-build store (list grub.cfg))
-    (build-derivations store (list grub.cfg))
-    ;; This is basically the same as install-grub*, but for now we avoid
-    ;; re-installing the GRUB boot loader itself onto a device, mainly because
-    ;; we don't in general have access to the same version of the GRUB package
-    ;; which was used when installing this other system generation.
-    (let* ((grub.cfg-path (derivation->output-path grub.cfg))
-           (gc-root (string-append %gc-roots-directory "/grub.cfg"))
-           (temp-gc-root (string-append gc-root ".new")))
-      (switch-symlinks temp-gc-root grub.cfg-path)
-      (unless (false-if-exception (install-grub-config grub.cfg-path "/"))
-        (delete-file temp-gc-root)
-        (leave (G_ "failed to re-install GRUB configuration file: '~a'~%")
-               grub.cfg-path))
-      (rename-file temp-gc-root gc-root))))
+         (old-entries (profile-boot-parameters
+                       %system-profile old-generations)))
+    (run-with-store store
+      (mlet* %store-monad
+          ((bootcfg ((bootloader-configuration-file-generator boot-config)
+                     boot-config entries
+                     #:old-entries old-entries))
+           (bootcfg-location -> (bootloader-configuration-file-name
+                                 boot-config))
+           (bootloader (package->derivation
+                        (bootloader-configuration-bootloader boot-config)))
+           (target -> "/")
+           (install-proc
+            (let ((procedure (bootloader-configuration-installer
+                              boot-config)))
+              (install-bootloader-derivation
+               procedure bootloader boot-device target)))
+           (drvs -> (list bootcfg bootloader install-proc)))
+        (mbegin %store-monad
+          (show-what-to-build* drvs)
+          (built-derivations drvs)
+          ;; PARAMS file may not contain a suitable BOOT-DEVICE. If BOOT-DEVICE
+          ;; is #f do not run INSTALL-PROC during bootloader installation.
+          (install-bootloader (if boot-device
+                                  install-proc
+                                  #f)
+                              #:bootcfg bootcfg
+                              #:bootcfg-location bootcfg-location
+                              #:device boot-device
+                              #:target target))))))
 
 \f
 ;;;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 9/9] scripts: system: Display bootloader device and type in "list-generations".
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
                     ` (7 preceding siblings ...)
  2017-05-06 15:41   ` bug#26339: [PATCH v3 8/9] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
@ 2017-05-06 15:41   ` Mathieu Othacehe
  2017-05-07 16:57     ` Danny Milosavljevic
  8 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-06 15:41 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (display-system-generation): Display bootloader
  device and bootloader type.
---
 guix/scripts/system.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index adab1cedb..63993a885 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -525,17 +525,21 @@ list of services."
     (let* ((generation  (generation-file-name profile number))
            (params      (read-boot-parameters-file generation))
            (label       (boot-parameters-label params))
+           (boot-type   (boot-parameters-boot-type params))
            (root        (boot-parameters-root-device params))
            (root-device (if (bytevector? root)
                             (uuid->string root)
                             root))
+           (boot-device (boot-parameters-boot-device params))
            (kernel      (boot-parameters-kernel params)))
       (display-generation profile number)
       (format #t (G_ "  file name: ~a~%") generation)
       (format #t (G_ "  canonical file name: ~a~%") (readlink* generation))
       ;; TRANSLATORS: Please preserve the two-space indentation.
       (format #t (G_ "  label: ~a~%") label)
+      (format #t (G_ "  bootloader type: ~a~%") boot-type)
       (format #t (G_ "  root device: ~a~%") root-device)
+      (format #t (G_ "  boot device: ~a~%") boot-device)
       (format #t (G_ "  kernel: ~a~%") kernel))))
 
 (define* (list-generations pattern #:optional (profile %system-profile))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 1/9] system: Add extlinux support.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 1/9] system: Add extlinux support Mathieu Othacehe
@ 2017-05-07 16:41     ` Danny Milosavljevic
  2017-05-07 20:01       ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 16:41 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

>guix/scripts/system.scm (profile-grub-entries): 
>Rename system->grub-entry to system->boot-parameters and adjust accordingly.

Not really - because I did this part already :)

That part of the commit message is outdated.

> +       (bootloader (let ((bootloader (bootloader-configuration-bootloader
> +                                      (operating-system-bootloader os))))
> +                     (if bootloader
> +                         (package->derivation bootloader)
> +                         (return #f))))
[...]

> +                      (if (and bootloader? bootloader)

Hmm, is it possible to (usefully) check monadic values that way?

> +          (when (and bootloader? bootloader)

Likewise.

Otherwise LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 2/9] bootloader: Add install procedures and use them.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 2/9] bootloader: Add install procedures and use them Mathieu Othacehe
@ 2017-05-07 16:52     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 16:52 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 4/9] bootloader: Stop using grub module.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 4/9] bootloader: Stop using grub module Mathieu Othacehe
@ 2017-05-07 16:53     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 16:53 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 3/9] system: Add bootloader type.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 3/9] system: Add bootloader type Mathieu Othacehe
@ 2017-05-07 16:55     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 16:55 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 9/9] scripts: system: Display bootloader device and type in "list-generations".
  2017-05-06 15:41   ` bug#26339: [PATCH v3 9/9] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
@ 2017-05-07 16:57     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 16:57 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 1/9] system: Add extlinux support.
  2017-05-07 16:41     ` Danny Milosavljevic
@ 2017-05-07 20:01       ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-07 20:01 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi Danny,

> Not really - because I did this part already :)

I'll remove it ;)

>> +                      (if (and bootloader? bootloader)
>
> Hmm, is it possible to (usefully) check monadic values that way?

Monads are still misterious for me, so I could be completely wrong
here but I think that bootloader may be #f so it makes sense to check it
here and in the following lines.

>
>> +          (when (and bootloader? bootloader)
>
> Likewise.

I wrote the few lines bellow to better understand what's going on :

--8<---------------cut here---------------start------------->8---
(run-with-store (open-connection) (mlet* %store-monad ((test (return #f)) (disp -> (if test "true" "false"))) (return (display disp))))
--8<---------------cut here---------------end--------------->8---

You can ,expand it and make test return #t instead.

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
@ 2017-05-07 20:33     ` Danny Milosavljevic
  2017-05-07 20:56       ` Danny Milosavljevic
  2017-05-08 16:21       ` Mathieu Othacehe
  2017-05-07 21:14     ` Danny Milosavljevic
  1 sibling, 2 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 20:33 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

> +(define* (install-bootloader install-procedure
> +                             #:key
> +                             bootcfg bootcfg-location
> +                             device target)

Maybe "installer" instead of "install-procedure"?  It's not that important but it reads better I think...

>+(define (install-bootloader-derivation install-procedure
>+                                       bootloader device target)
>+  (with-monad %store-monad
>+    (gexp->file "install-bootloader"
>+                (with-imported-modules '((guix build utils))
>+                  #~(begin
>+                      (use-modules (guix build utils))
>+                      (#$install-procedure #$bootloader
>+                                           #$device
>+                                           #$target))))))

Hmm, importing (guix build utils) twice (on different sides, I guess)?  Could use a comment...

> +       (install-proc
> +        (let ((procedure (bootloader-configuration-installer
> +                          (operating-system-bootloader os)))
> +              (target    (or target "/")))
> +          (install-bootloader-derivation procedure bootloader device target)))

Here, I'd use "bootloader-installer" instead of "install-proc" - because this specific procedure could install lots of things - it's the main entry point in a sense.

Otherwise LGTM!  I also think the general approach is good.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 8/9] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 8/9] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
@ 2017-05-07 20:54     ` Danny Milosavljevic
  2017-05-08 16:22       ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 20:54 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> +           (install-proc

"installer.drv" instead of "install-proc"?

> +            (let ((procedure (bootloader-configuration-installer
> +                              boot-config)))

"installer" instead of "procedure"?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-07 20:33     ` Danny Milosavljevic
@ 2017-05-07 20:56       ` Danny Milosavljevic
  2017-05-08 16:24         ` Mathieu Othacehe
  2017-05-08 16:21       ` Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 20:56 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339


> > +(define* (install-bootloader install-procedure
> > +                             #:key
> > +                             bootcfg bootcfg-location
> > +                             device target)  
> 
> Maybe "installer" instead of "install-procedure"?  It's not that important but it reads better I think...

This is actually a derivation, right? So "installer.drv" ...

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 5/9] bootloader: Add device and type to bootloader-configuration record.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 5/9] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
@ 2017-05-07 20:59     ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 20:59 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 7/9] scripts: system: Adapt "init" to new bootloader API.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 7/9] scripts: system: Adapt "init" " Mathieu Othacehe
@ 2017-05-07 21:08     ` Danny Milosavljevic
  2017-05-08 16:26       ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 21:08 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

On Sat,  6 May 2017 17:41:52 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> --- a/guix/scripts/system.scm
> +++ b/guix/scripts/system.scm
> @@ -178,12 +178,14 @@ TARGET, and register them."
>  
>  (define* (install os-drv target
>                    #:key (log-port (current-output-port))
> -                  grub? grub.cfg device)
> -  "Copy the closure of GRUB.CFG, which includes the output of OS-DRV, to
> +                  installer install-bootloader?

"bootloader-installer.drv" instead of "installer"?

>[reinstall-bootloader]
> -       (install-proc
> +       (installer
>          (let ((procedure (bootloader-configuration-installer
>                            (operating-system-bootloader os)))
>                (target    (or target "/")))

"installer.drv" instead of "installer", and "installer" instead of "procedure".  Also, deja vu.  Patch 6/9 also includes something of this part.

Otherwise LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-06 15:41   ` bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
  2017-05-07 20:33     ` Danny Milosavljevic
@ 2017-05-07 21:14     ` Danny Milosavljevic
  2017-05-08 16:27       ` Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-07 21:14 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> +(define (install-bootloader-derivation install-procedure
> +                                       bootloader device target)

That doesn't actually install a bootloader derivation, right?

Maybe call it "bootloader-installer-derivation" instead? I hesitate to use ".drv" because it isn't a derivation yet - it just returns one.

Also, can you add a docstring?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-04-17  9:01   ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
  2017-04-17 17:08     ` Danny Milosavljevic
@ 2017-05-08  9:37     ` Ludovic Courtès
  2017-05-08 13:51       ` Danny Milosavljevic
  2017-05-08 14:53       ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
  1 sibling, 2 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-08  9:37 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/system.scm (operating-system-grub.cfg): Pass <bootloader-parameter>.
> * gnu/system/grub.scm (boot-parameters->menu-entry): New variable.
>   (grub-configuration-file): Use boot-parameters->menu-entry.

This patch as applied in 2e58e05bb6 causes a circular dependency between
(gnu system) and (gnu system grub), which is not OK given that they rely
on macros (actually record accessors) coming from each others.  This
causes evaluation to fail (see
<https://hydra.gnu.org/jobset/gnu/master#tabs-errors>):

--8<---------------cut here---------------start------------->8---
In gnu/system/grub.scm:
 272: 1 [boot-parameters->menu-entry #]
In unknown file:
   ?: 0 [# #]

ERROR: In procedure #<syntax-transformer boot-parameters-label>:
ERROR: Wrong type to apply: #<syntax-transformer boot-parameters-label>
--8<---------------cut here---------------end--------------->8---

Since the goal of this patch set was to support multiple bootloaders,
the right fix would be for (gnu system) to not use (gnu system grub).
Instead there should probably be a (gnu system bootloaders) module
providing a bootloader abstraction.

However, I’m not sure about the details of all this.  If we cannot fix
it today, we’ll have to revert this change, though I’m unsure exactly
how many commits depend on it.

Thoughts?

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-08  9:37     ` Ludovic Courtès
@ 2017-05-08 13:51       ` Danny Milosavljevic
  2017-05-08 15:00         ` Mathieu Othacehe
  2017-05-08 19:47         ` Ludovic Courtès
  2017-05-08 14:53       ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
  1 sibling, 2 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-08 13:51 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

Hi Ludo,

I've pushed 087efec496b91e3763be2e11e208d4a8f4ef3d43 to master which is a two-line change removing this circular dependency.

Can you please start another evaluation on Hydra?

Also, you are right, this will eventually support other bootloaders - but right now the remainder is in review.  The parts that are pushed already just make boot-parameters not weird.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-08  9:37     ` Ludovic Courtès
  2017-05-08 13:51       ` Danny Milosavljevic
@ 2017-05-08 14:53       ` Mathieu Othacehe
  1 sibling, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-08 14:53 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


Hi Ludo,

> Since the goal of this patch set was to support multiple bootloaders,
> the right fix would be for (gnu system) to not use (gnu system grub).
> Instead there should probably be a (gnu system bootloaders) module
> providing a bootloader abstraction.

The still in review serie adds a (gnu system bootloader) module offering
the abstraction you're talking about. The file is added in "[PATCH v3
1/9] system: Add extlinux support"[1] and modified by following patches.

Thanks,

Mathieu

[1] : https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26339#268

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-08 13:51       ` Danny Milosavljevic
@ 2017-05-08 15:00         ` Mathieu Othacehe
  2017-05-09 14:16           ` Marius Bakke
  2017-05-08 19:47         ` Ludovic Courtès
  1 sibling, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-08 15:00 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi Danny,

> Also, you are right, this will eventually support other bootloaders - but right now the remainder is in review.  The parts that are pushed already just make boot-parameters not weird.

Thanks for the patch. I should be able to remove those lines in the v4
of my bootloader serie if everything is going ok.

I'll submit it tomorrow with the other renamings you suggested in v3.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-07 20:33     ` Danny Milosavljevic
  2017-05-07 20:56       ` Danny Milosavljevic
@ 2017-05-08 16:21       ` Mathieu Othacehe
  1 sibling, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-08 16:21 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi,

> Hi Mathieu,
>
>> +(define* (install-bootloader install-procedure
>> +                             #:key
>> +                             bootcfg bootcfg-location
>> +                             device target)
>
> Maybe "installer" instead of "install-procedure"?  It's not that important but it reads better I think...
>

Ok for installer.

> Hmm, importing (guix build utils) twice (on different sides, I guess)?  Could use a comment...

Actually it's something pretty common, grep "guix build utils" in
gnu/services for example.

>
>> +       (install-proc
>> +        (let ((procedure (bootloader-configuration-installer
>> +                          (operating-system-bootloader os)))
>> +              (target    (or target "/")))
>> +          (install-bootloader-derivation procedure bootloader device target)))
>
> Here, I'd use "bootloader-installer" instead of "install-proc" - because this specific procedure could install lots of things - it's the main entry point in a sense.

Ok for install-proc -> bootloader-installer.
       
>
> Otherwise LGTM!  I also think the general approach is good.

Nice !

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 8/9] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-07 20:54     ` Danny Milosavljevic
@ 2017-05-08 16:22       ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-08 16:22 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Danny Milosavljevic writes:

>> +           (install-proc
>
> "installer.drv" instead of "install-proc"?

Maybe install-proc -> bootloader-installer to be coherent with previous
reconfigure.

>
>> +            (let ((procedure (bootloader-configuration-installer
>> +                              boot-config)))
>
> "installer" instead of "procedure"?

Ok for installer.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-07 20:56       ` Danny Milosavljevic
@ 2017-05-08 16:24         ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-08 16:24 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> This is actually a derivation, right? So "installer.drv" ...

Ok for installer.drv.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 7/9] scripts: system: Adapt "init" to new bootloader API.
  2017-05-07 21:08     ` Danny Milosavljevic
@ 2017-05-08 16:26       ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-08 16:26 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> "bootloader-installer.drv" instead of "installer"?

I think that bootloader-installer is fine as per reconfigure.
>
>>[reinstall-bootloader]
>> -       (install-proc
>> +       (installer
>>          (let ((procedure (bootloader-configuration-installer
>>                            (operating-system-bootloader os)))
>>                (target    (or target "/")))
>
> "installer.drv" instead of "installer", and "installer" instead of "procedure".  Also, deja vu.  Patch 6/9 also includes something of this part.

Ok for install-proc -> bootloader-install and procedure -> installer as
per reconfigure.
>
> Otherwise LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-07 21:14     ` Danny Milosavljevic
@ 2017-05-08 16:27       ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-08 16:27 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> That doesn't actually install a bootloader derivation, right?

Nope it just returns a derivation.

> Maybe call it "bootloader-installer-derivation" instead? I hesitate to use ".drv" because it isn't a derivation yet - it just returns one.

bootloader-installer-derivation is fine for me.

>
> Also, can you add a docstring?

Sure !

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-08 13:51       ` Danny Milosavljevic
  2017-05-08 15:00         ` Mathieu Othacehe
@ 2017-05-08 19:47         ` Ludovic Courtès
  2017-05-08 20:04           ` Danny Milosavljevic
  2017-05-08 20:16           ` bug#26339: [PATCH] system: Remove circular dependency between (gnu system) and (gnu system grub) Danny Milosavljevic
  1 sibling, 2 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-08 19:47 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> I've pushed 087efec496b91e3763be2e11e208d4a8f4ef3d43 to master which is a two-line change removing this circular dependency.

This does not remove the circular dependency, it just expresses it
differently, so I don’t think it will help.  Using

  (module-ref (resolve-interface '(gnu system grub))
              'grub-configuration-file)

would have achieved the effect you wanted.

However, that’s pretty much a band-aid, so we should look for a way to
improve this.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-08 19:47         ` Ludovic Courtès
@ 2017-05-08 20:04           ` Danny Milosavljevic
  2017-05-09  7:03             ` Ludovic Courtès
  2017-05-08 20:16           ` bug#26339: [PATCH] system: Remove circular dependency between (gnu system) and (gnu system grub) Danny Milosavljevic
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-08 20:04 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

Hi Ludo,

On Mon, 08 May 2017 21:47:29 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> This does not remove the circular dependency, it just expresses it
> differently, so I don’t think it will help.  Using
> 
>   (module-ref (resolve-interface '(gnu system grub))
>               'grub-configuration-file)
> 
> would have achieved the effect you wanted.

Hmm.... I've tested the @@-version locally by removing all the .go files and then doing guix system reconfigure ... which took ages every time.  And it worked just fine, no errors, no warnings, nothing.  Did I test it wrong?

> However, that’s pretty much a band-aid, so we should look for a way to
> improve this.

Yes, but as soon as the other bootloader patches are merged the band-aid would be gone.

We have multiple choices here, 
(1) revert all ~12 commits, or
(2) do the band-aid, leave the commits in and review and merge the remainder later, or
(3) review and merge all the other bootloader patches now...

I don't have a strong preference.  If I knew how flaky even simple changes in these modules are I wouldn't have been in favor of refactoring them at all... (really, just having u-boot with Grub as payload - and grub-efi as part of regular grub - would have been much simpler than this, in retrospect)

Note that there are now two other patch series by two different people which depend on these.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-04-02 13:52   ` bug#26339: [PATCH 02/18] system: Add extlinux support Mathieu Othacehe
  2017-04-15 16:03     ` Danny Milosavljevic
@ 2017-05-08 20:06     ` Ludovic Courtès
  2017-05-09  7:38       ` Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-08 20:06 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, David Craven

Hello!

Sorry for the delay, and thanks for reminding me of this patch.

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> From: David Craven <david@craven.ch>
>
> * gnu/system.scm (operating-system): Add default bootloader.
>   (operating-system-grub.cfg): Use bootloader-configuration-file-procedure.
> * gnu/system/grub.scm (bootloader-configuration->grub-configuration): New
>   variable.
>   (grub-configuration-file): Use bootloader-configuration->grub-configuration.
> * guix/scripts/system.scm (profile-grub-entries): Rename system->grub-entry to
>   system->boot-parameters and adjust accordingly.
>   (perform-action): Make bootloader optional. Use
>   bootloader-configuration-device.
> * gnu/system/bootloader.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * tests/system.scm: Adjust operating-system to new API.
> * tests/guix-system.sh: Adjust operating-system to new API.

[...]

> +(define-record-type* <bootloader-configuration>
> +  bootloader-configuration make-bootloader-configuration
> +  bootloader-configuration?
> +  (bootloader                      bootloader-configuration-bootloader     ; package
> +                                   (default #f))
> +  (device                          bootloader-configuration-device         ; string
> +                                   (default #f))
> +  (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
> +                                   (default '()))
> +  (default-entry                   bootloader-configuration-default-entry  ; integer
> +                                   (default 0))
> +  (timeout                         bootloader-configuration-timeout        ; integer
> +                                   (default 5))
> +  (configuration-file-location     bootloader-configuration-file-location
> +                                   (default #f))
> +  (configuration-file-procedure    bootloader-configuration-file-procedure ; procedure
> +                                   (default #f))
> +  (install-procedure               bootloader-configuration-install-procedure ; procedure
> +                                   (default #f))
> +  (additional-configuration        bootloader-configuration-additional-configuration ; record
> +                                   (default #f)))
> +

To avoid mistakes, I think we should remove default values for fields
that really need to be set.  For example, ‘configuration-file-location’
and ‘install-procedure’ should probably not have a default value.

I would rename ‘configuration-file-location’ to ‘configuration-file’.

I’m fine with ‘configuration-file-procedure’, but ‘generator’ is OK too.

I would make ‘bootloader’ a delayed field (see the ‘patches’ field of
<origin> for an example of that.)  That would avoid loading the package
modules upfront.

> +;;;
> +;;; Bootloader configurations.
> +;;;
> +
> +(define* (extlinux-configuration #:optional (config (bootloader-configuration)))
> +  (bootloader-configuration
> +   (inherit config)
> +   (configuration-file-location "/boot/extlinux/extlinux.conf")
> +   (configuration-file-procedure extlinux-configuration-file)))
> +
> +(define* (grub-configuration #:optional (config (bootloader-configuration)))
> +  (bootloader-configuration
> +   (inherit config)
> +   (bootloader (@ (gnu packages bootloaders) grub))
> +   (configuration-file-location "/boot/grub/grub.cfg")
> +   (configuration-file-procedure grub-configuration-file)
> +   (install-procedure install-grub)
> +   (additional-configuration
> +    (let ((additional-config (bootloader-configuration-additional-configuration config)))
> +      (if additional-config additional-config %default-theme)))))
> +
> +(define* (grub-efi-configuration #:optional (config (bootloader-configuration)))
> +  (bootloader-configuration
> +   (inherit (grub-configuration config))
> +   (bootloader (@ (gnu packages bootloaders) grub-efi))))
> +
> +(define* (syslinux-configuration #:optional (config (bootloader-configuration)))
> +  (bootloader-configuration
> +   (inherit (extlinux-configuration config))
> +   (bootloader (@ (gnu packages bootloaders) syslinux))
> +   (install-procedure install-syslinux)))

So it looks like this is the reason for all the default values.

What about distinguishing two things: bootloader configuration, and
bootloader implementation?  This would be akin to the relation between
<package> and <build-system>.

We’d have <bootloader-configuration>, but without the ‘bootloader’,
‘install-procedure’, ‘configuration-file-procedure’, and
‘configuration-file’ fields.  Instead of those 4 fields, we’d have a
single ‘bootloader’ field whose value would be a <bootloader> record.

The <bootloader> record would contain these 4 fields (package,
install-procedure, configuration-file, configuration-file-procedure),
maybe along with a ‘name’ field to aid debugging.

The <bootloader> record would define the implementation (GRUB, extlinux,
u-boot, etc.) while <bootloader-configuration> would be purely
configuration.

How does that sound?

We could do:

  (define grub-bootloader
    (bootloader
      (package grub)
      …))

in (gnu bootloader grub).

Likewise we’d define ‘extlinux-bootloader’ in (gnu bootloader extlinux).

The (gnu system) module would include (gnu bootloader), but it would not
include (gnu bootloader grub) nor (gnu bootloader extlinux).  Users
would include one of these in their config file instead.

> --- a/tests/system.scm
> +++ b/tests/system.scm
> @@ -36,7 +36,6 @@
>      (host-name "komputilo")
>      (timezone "Europe/Berlin")
>      (locale "en_US.utf8")
> -    (bootloader (grub-configuration (device "/dev/sdX")))
>      (file-systems (cons %root-fs %base-file-systems))

In gnu/system.scm, there’s:

> +  (bootloader operating-system-bootloader         ; <bootloader-configuration>
> +              (default (extlinux-configuration)))


If there was a default value here, I think it’d rather be GRUB ;-), but
probably we’d better not have a default at all.  How would the
installation device be found?

Thanks a lot, and sorry for the loooong delay!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] system: Remove circular dependency between (gnu system) and (gnu system grub).
  2017-05-08 19:47         ` Ludovic Courtès
  2017-05-08 20:04           ` Danny Milosavljevic
@ 2017-05-08 20:16           ` Danny Milosavljevic
  2017-05-08 21:01             ` Danny Milosavljevic
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-08 20:16 UTC (permalink / raw)
  To: 26339, ludo

Followup to 087efec496b91e3763be2e11e208d4a8f4ef3d43.

* gnu/system.scm: (operating-system-bootcfg): Refer to (gnu system grub)
by module-ref.
---
 gnu/system.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index baba0b5df..9fc6cc5e7 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -847,9 +847,11 @@ populate the \"old entries\" menu."
                            (uuid->string (file-system-device root-fs))
                            (file-system-device root-fs)))
        (entry (operating-system-boot-parameters os system root-device)))
-    ((@@ (gnu system grub) grub-configuration-file) (operating-system-bootloader os)
-                             (list entry)
-                              #:old-entries old-entries)))
+    ((module-ref (resolve-interface '(gnu system grub))
+                 'grub-configuration-file)
+     (operating-system-bootloader os)
+     (list entry)
+     #:old-entries old-entries)))
 
 (define (fs->boot-device fs)
   "Given FS, a <file-system> object, return a value suitable for use as the

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] system: Remove circular dependency between (gnu system) and (gnu system grub).
  2017-05-08 20:16           ` bug#26339: [PATCH] system: Remove circular dependency between (gnu system) and (gnu system grub) Danny Milosavljevic
@ 2017-05-08 21:01             ` Danny Milosavljevic
  0 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-08 21:01 UTC (permalink / raw)
  To: 26339, ludo

Pushed this one patch to master after a successful local test (also without .go files).

Let me know when it still doesn't work / we decide to, then I can revert all of them.  I know which they are...

But I think it's going to work now - and we are gonna need them regardless.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-08 20:04           ` Danny Milosavljevic
@ 2017-05-09  7:03             ` Ludovic Courtès
  2017-05-09  7:21               ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-09  7:03 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Hi,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> On Mon, 08 May 2017 21:47:29 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> This does not remove the circular dependency, it just expresses it
>> differently, so I don’t think it will help.  Using
>> 
>>   (module-ref (resolve-interface '(gnu system grub))
>>               'grub-configuration-file)
>> 
>> would have achieved the effect you wanted.
>
> Hmm.... I've tested the @@-version locally by removing all the .go files and then doing guix system reconfigure ... which took ages every time.  And it worked just fine, no errors, no warnings, nothing.  Did I test it wrong?

No apparently it worked on Hydra (but as I wrote before, the way
build-aux/compile-all.scm builds things doesn’t catch
macro-used-before-defined errors, so testing locally doesn’t help much).

I was concerned that @@ would effectively cause the same problem as
#:use-module, but apparently that’s fine.

>> However, that’s pretty much a band-aid, so we should look for a way to
>> improve this.
>
> Yes, but as soon as the other bootloader patches are merged the band-aid would be gone.
>
> We have multiple choices here, 
> (1) revert all ~12 commits, or
> (2) do the band-aid, leave the commits in and review and merge the remainder later, or
> (3) review and merge all the other bootloader patches now...

I think we’re fine with the band-aid for now.  ;-)

We’ll keep reviewing/merging the rest of the series, which apparently
provides a nicer bootloader abstraction.

> I don't have a strong preference.  If I knew how flaky even simple changes in these modules are I wouldn't have been in favor of refactoring them at all... (really, just having u-boot with Grub as payload - and grub-efi as part of regular grub - would have been much simpler than this, in retrospect)

There’s some flakiness, but I think the circular dependency in this case
was the consequence of a half-baked abstraction.  Fortunately the rest
of the patch series appears to address this, so we’re all good!

I think it remains easy to refactor GuixSD, especially now that we have
system tests.  Let’s not throw the baby out with the bath water.  ;-)

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-09  7:03             ` Ludovic Courtès
@ 2017-05-09  7:21               ` Danny Milosavljevic
  2017-05-09  9:45                 ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-09  7:21 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

Hi Ludo,

On Tue, 09 May 2017 09:03:00 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> No apparently it worked on Hydra (but as I wrote before, the way
> build-aux/compile-all.scm builds things doesn’t catch
> macro-used-before-defined errors, so testing locally doesn’t help much).

Hmm, but aren't the .go files the compiled files?  I've removed those before testing.  And the guix script has "--no-auto-compile". I don't really understand this part yet...

> I was concerned that @@ would effectively cause the same problem as
> #:use-module, but apparently that’s fine.

The idea was that it would load the module just in time when the procedure is executed.  In any case, module-ref can't hurt either, so that's in master now.

> We’ll keep reviewing/merging the rest of the series, which apparently
> provides a nicer bootloader abstraction.

It does.  I think the state in master now is good and we can review the remainder at our leisure and I can stop hot-fixing things now.  Phiew... :)

> There’s some flakiness, but I think the circular dependency in this case
> was the consequence of a half-baked abstraction.

Yeah...

> I think it remains easy to refactor GuixSD, especially now that we have
> system tests.  Let’s not throw the baby out with the bath water.  ;-)

True, it's okay.

Though, it would be nice if there was a way to run the interpreted version locally - without it taking several hours each time.  Would it be possible for guile to have some static analysis that catches these things?  Doesn't seem that difficult: Just walk the modules, remember when you see record definitions, remember when you see record usage.  In fact I'll write a throwaway script to do just that for next time.  (I've already got my Makefile generator to find Guile module cycles :) )

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-08 20:06     ` Ludovic Courtès
@ 2017-05-09  7:38       ` Mathieu Othacehe
  2017-05-09  9:51         ` Ludovic Courtès
  2017-05-09 10:25         ` Ludovic Courtès
  0 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-09  7:38 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339, David Craven


Hi Ludo,

> Sorry for the delay, and thanks for reminding me of this patch.

No problem :)

> The <bootloader> record would define the implementation (GRUB, extlinux,
> u-boot, etc.) while <bootloader-configuration> would be purely
> configuration.
>
> How does that sound?
>

I implemented most of this split between
bootloader-configuration/bootloader and it's waaay better !

I still have one small concern. In following patches, I added boot-type
(and boot-device) to parameters file. This allows to re-install the
correct bootloader (on the correct device) when using "guix system
switch-generation".

What field could we store in parameters to be able to restore the
correct bootloader ? 

My initial idea was to add every <bootloader> to a list, a look it up by
name to restore the correct bootloader. So we could store the bootloader
name in the parameters file. This sounds a bit hack, do you have a
better idea ?

Thanks !

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-09  7:21               ` Danny Milosavljevic
@ 2017-05-09  9:45                 ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-09  9:45 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Heya,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> On Tue, 09 May 2017 09:03:00 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> No apparently it worked on Hydra (but as I wrote before, the way
>> build-aux/compile-all.scm builds things doesn’t catch
>> macro-used-before-defined errors, so testing locally doesn’t help much).
>
> Hmm, but aren't the .go files the compiled files?  I've removed those before testing.  And the guix script has "--no-auto-compile". I don't really understand this part yet...

Hydra does compile Scheme files, but not with compile-all.scm.  Instead
it simply relies on Guile’s auto-compilation mechanism.  So everything
is built in one process but differently, which can lead to this subtle
bug (essentially compile-all.scm has a load phase followed by a build
phases, whereas auto-compilation builds files on demand.)

>> I was concerned that @@ would effectively cause the same problem as
>> #:use-module, but apparently that’s fine.
>
> The idea was that it would load the module just in time when the procedure is executed.  In any case, module-ref can't hurt either, so that's in master now.

Yup, thanks for the quick hot fix!

>> We’ll keep reviewing/merging the rest of the series, which apparently
>> provides a nicer bootloader abstraction.
>
> It does.  I think the state in master now is good and we can review the remainder at our leisure and I can stop hot-fixing things now.  Phiew... :)

Indeed.  :-)

> Though, it would be nice if there was a way to run the interpreted version locally - without it taking several hours each time.  Would it be possible for guile to have some static analysis that catches these things?  Doesn't seem that difficult: Just walk the modules, remember when you see record definitions, remember when you see record usage.  In fact I'll write a throwaway script to do just that for next time.  (I've already got my Makefile generator to find Guile module cycles :) )

It’s not that simple to find macro-used-before-defined errors, I’m
afraid.  If you build each file separately (as in “for i in *.scm; do
guild compile $i; done”), you definitely catch this issue.

Circular dependencies could be caught and (guix modules) has some of the
tools for that, though they are not necessarily a problem.

Thanks for your responsiveness!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-09  7:38       ` Mathieu Othacehe
@ 2017-05-09  9:51         ` Ludovic Courtès
  2017-05-09 14:30           ` Mathieu Othacehe
  2017-05-09 10:25         ` Ludovic Courtès
  1 sibling, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-09  9:51 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, David Craven

Hi Mathieu,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> I implemented most of this split between
> bootloader-configuration/bootloader and it's waaay better !

Woow, that was fast!  :-)

> I still have one small concern. In following patches, I added boot-type
> (and boot-device) to parameters file. This allows to re-install the
> correct bootloader (on the correct device) when using "guix system
> switch-generation".
>
> What field could we store in parameters to be able to restore the
> correct bootloader ? 

Good question!  I guess we need to store the name of the bootloader type
in the “parameters” file, and then look it up upon switch-generation?
But maybe we also need to store a reference to the bootloader package so
that it isn’t GC’d?

> My initial idea was to add every <bootloader> to a list, a look it up by
> name to restore the correct bootloader. So we could store the bootloader
> name in the parameters file. This sounds a bit hack, do you have a
> better idea ?

No better idea, sounds like a good start.

I think the most important is to make sure that our current use case,
where people always use GRUB, doesn’t break.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-09  7:38       ` Mathieu Othacehe
  2017-05-09  9:51         ` Ludovic Courtès
@ 2017-05-09 10:25         ` Ludovic Courtès
  2017-05-09 14:32           ` Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-09 10:25 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, David Craven

Hello!

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> The <bootloader> record would define the implementation (GRUB, extlinux,
>> u-boot, etc.) while <bootloader-configuration> would be purely
>> configuration.
>>
>> How does that sound?
>>
>
> I implemented most of this split between
> bootloader-configuration/bootloader and it's waaay better !

Just to be clear: that will be “v4” of the patch series, right?

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-08 15:00         ` Mathieu Othacehe
@ 2017-05-09 14:16           ` Marius Bakke
  2017-05-09 14:36             ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Marius Bakke @ 2017-05-09 14:16 UTC (permalink / raw)
  To: Mathieu Othacehe, Danny Milosavljevic; +Cc: 26339

[-- Attachment #1: Type: text/plain, Size: 967 bytes --]

Mathieu Othacehe <m.othacehe@gmail.com> writes:

> Hi Danny,
>
>> Also, you are right, this will eventually support other bootloaders - but right now the remainder is in review.  The parts that are pushed already just make boot-parameters not weird.
>
> Thanks for the patch. I should be able to remove those lines in the v4
> of my bootloader serie if everything is going ok.
>
> I'll submit it tomorrow with the other renamings you suggested in v3.

Hi Mathieu,

Thanks a lot for working on this. I've tested it extensively while
working on UEFI support and it works great with native EFI grub[0]. Can
you push the updated patches to a "wip-bootloader" branch on Savannah?
Please also send a `git request-pull` here ;-)

No comments on the code, but I did notice many docstrings need to be
updated.

[0] I had that working, but since the native grub-install tries to
update EFI variables in qemu, the grub-mksnapshot trick was necessary
anyway for a generic image.

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

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-09  9:51         ` Ludovic Courtès
@ 2017-05-09 14:30           ` Mathieu Othacehe
  2017-05-09 20:40             ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-09 14:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339, David Craven


> Woow, that was fast!  :-)

I had time to kill during a train trip :)

> Good question!  I guess we need to store the name of the bootloader type
> in the “parameters” file, and then look it up upon switch-generation?
> But maybe we also need to store a reference to the bootloader package so
> that it isn’t GC’d?

We have three options for switch-generation :

1. Do not reinstall bootloader, only update config (current behaviour).

-> It was ok with one bootloader, it's more problematic with multiple
bootloaders. For example switching between two generations with two
different bootloaders.

2. Save the bootloader type in "parameters" and reinstall bootloader
(current bootloader build, not necessarily the one used when creating
this generation)

-> It's the option I choose in my series.

3. Same as 2. but also save bootloader used (store reference) and add a
gc-root to keep it around.

I can try to implement option 3 if you're ok ?

> No better idea, sounds like a good start.
>

Ok.

> I think the most important is to make sure that our current use case,
> where people always use GRUB, doesn’t break.

With my basic-one-unencrypted-partition setup it work fine, but it would
be great if people with more complex setup could try this serie :)

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-09 10:25         ` Ludovic Courtès
@ 2017-05-09 14:32           ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-09 14:32 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339, David Craven


> Just to be clear: that will be “v4” of the patch series, right?

Yes, with your review and the last one from Danny on v3 :)

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub.
  2017-05-09 14:16           ` Marius Bakke
@ 2017-05-09 14:36             ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-09 14:36 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 26339


Hi Marius,

> Thanks a lot for working on this. I've tested it extensively while
> working on UEFI support and it works great with native EFI grub[0]. Can
> you push the updated patches to a "wip-bootloader" branch on Savannah?
> Please also send a `git request-pull` here ;-)

Cool ! Thanks for your feedback !

I'll publish my v4 in wip-bootloader then.

> No comments on the code, but I did notice many docstrings need to be
> updated.

Ok, Danny pointed some of them, I'll add the missing ones.

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-09 14:30           ` Mathieu Othacehe
@ 2017-05-09 20:40             ` Ludovic Courtès
  2017-05-12  0:02               ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-09 20:40 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339, David Craven

Hello!

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> Woow, that was fast!  :-)
>
> I had time to kill during a train trip :)

I like train trips too.  :-)

>> Good question!  I guess we need to store the name of the bootloader type
>> in the “parameters” file, and then look it up upon switch-generation?
>> But maybe we also need to store a reference to the bootloader package so
>> that it isn’t GC’d?
>
> We have three options for switch-generation :
>
> 1. Do not reinstall bootloader, only update config (current behaviour).
>
> -> It was ok with one bootloader, it's more problematic with multiple
> bootloaders. For example switching between two generations with two
> different bootloaders.

OTOH, if it turns out to be safer to keep the current bootloader, which
is likely I think, then perhaps it’s best to not try to change.

I mean, I prefer a rollback that doesn’t roll back the bootloader over a
rollback that tries to do something smart and makes the system
unbootable.

Of course, if we can make it safe to reinstall the previous bootloader,
that’s optimal.

> 2. Save the bootloader type in "parameters" and reinstall bootloader
> (current bootloader build, not necessarily the one used when creating
> this generation)
>
> -> It's the option I choose in my series.

OK.  I guess I should read that part of the series.

> 3. Same as 2. but also save bootloader used (store reference) and add a
> gc-root to keep it around.
>
> I can try to implement option 3 if you're ok ?

Hmm maybe, I need to investigate.

>> I think the most important is to make sure that our current use case,
>> where people always use GRUB, doesn’t break.
>
> With my basic-one-unencrypted-partition setup it work fine, but it would
> be great if people with more complex setup could try this serie :)

Did you try something like:

  make check-system TESTS="encrypted-root-os btrfs-root-os"

?  It takes quite a bit of time to run, but it’s a good starting point
to test these things.

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-09 20:40             ` Ludovic Courtès
@ 2017-05-12  0:02               ` Danny Milosavljevic
  2017-05-12  8:26                 ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-12  0:02 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

Hi,

On Tue, 09 May 2017 22:40:23 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> > -> It was ok with one bootloader, it's more problematic with multiple  
> > bootloaders. For example switching between two generations with two
> > different bootloaders.  
> 
> OTOH, if it turns out to be safer to keep the current bootloader, which
> is likely I think, then perhaps it’s best to not try to change.
> 
> I mean, I prefer a rollback that doesn’t roll back the bootloader over a
> rollback that tries to do something smart and makes the system
> unbootable.

If there is a switch between extlinux and grub, the bootloader config file format (and name, too) will change.

So if you do switch the config file out but don't switch the actual bootloader out it will not boot, right?

That means we have to take care that this doesn't happen.

I still think an easy way would be to just always install the config files for all the bootloaders that we support.  That way if there is a bootloader that knows any of the configs, it will boot.  Can't think of a downside either.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-12  0:02               ` Danny Milosavljevic
@ 2017-05-12  8:26                 ` Ludovic Courtès
  2017-05-12 11:26                   ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-12  8:26 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Hello,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> On Tue, 09 May 2017 22:40:23 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> > -> It was ok with one bootloader, it's more problematic with multiple  
>> > bootloaders. For example switching between two generations with two
>> > different bootloaders.  
>> 
>> OTOH, if it turns out to be safer to keep the current bootloader, which
>> is likely I think, then perhaps it’s best to not try to change.
>> 
>> I mean, I prefer a rollback that doesn’t roll back the bootloader over a
>> rollback that tries to do something smart and makes the system
>> unbootable.
>
> If there is a switch between extlinux and grub, the bootloader config file format (and name, too) will change.
>
> So if you do switch the config file out but don't switch the actual bootloader out it will not boot, right?

Unless you regenerate the bootloader’s config file upon
‘switch-configuration’.

> That means we have to take care that this doesn't happen.
>
> I still think an easy way would be to just always install the config files for all the bootloaders that we support.  That way if there is a bootloader that knows any of the configs, it will boot.  Can't think of a downside either.

Yes, that’s also an option.  The downside would be that if we register
all of these as GC roots, then we end up retaining more than actually
needed.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-12  8:26                 ` Ludovic Courtès
@ 2017-05-12 11:26                   ` Danny Milosavljevic
  2017-05-12 11:36                     ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-12 11:26 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

Hi Ludo,

On Fri, 12 May 2017 10:26:53 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> > If there is a switch between extlinux and grub, the bootloader config file format (and name, too) will change.
> >
> > So if you do switch the config file out but don't switch the actual bootloader out it will not boot, right?  
> 
> Unless you regenerate the bootloader’s config file upon
> ‘switch-configuration’.

Yes, for the last-guix-installed bootloader (presumably the still-installed one).  Good point.

That would mean only the bootloader type of the newest system generation would be checked - also when restoring older generations.

Can the newest system generation be deleted?  Then eventually Guix could read the wrong bootloader type (of a bootloader which isn't actually installed at the time).

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-12 11:26                   ` Danny Milosavljevic
@ 2017-05-12 11:36                     ` Ludovic Courtès
  2017-05-12 12:18                       ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-12 11:36 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Hi,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> On Fri, 12 May 2017 10:26:53 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> > If there is a switch between extlinux and grub, the bootloader config file format (and name, too) will change.
>> >
>> > So if you do switch the config file out but don't switch the actual bootloader out it will not boot, right?  
>> 
>> Unless you regenerate the bootloader’s config file upon
>> ‘switch-configuration’.
>
> Yes, for the last-guix-installed bootloader (presumably the still-installed one).  Good point.
>
> That would mean only the bootloader type of the newest system generation would be checked - also when restoring older generations.
>
> Can the newest system generation be deleted?  Then eventually Guix could read the wrong bootloader type (of a bootloader which isn't actually installed at the time).

The newest generation can be deleted, but the current one cannot (it’s
possible that the current one is not the newest if you picked an old
entry in the boot menu.)

So it should probably pick the current (not the newest) bootloader type.

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-12 11:36                     ` Ludovic Courtès
@ 2017-05-12 12:18                       ` Mathieu Othacehe
  2017-05-13  9:53                         ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-12 12:18 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]

Hi !

> So it should probably pick the current (not the newest) bootloader type.

I'm not fan of installing every bootloader config because it means
multiple gcroots and filling /boot with possibly useless stuff.

However, reading the "parameters" of current system, extracting
bootloader type, and reinstalling *only* the bootloader configuration
file for this type seems a good idea to me.

I'll use this solution for v4. Plus we can come up later with a more
intelligent solution, storing bootloader store path in "parameters" and
creating a gcroot for it.

Thanks,

Mathieu


2017-05-12 13:36 GMT+02:00 Ludovic Courtès <ludo@gnu.org>:

> Hi,
>
> Danny Milosavljevic <dannym@scratchpost.org> skribis:
>
> > On Fri, 12 May 2017 10:26:53 +0200
> > ludo@gnu.org (Ludovic Courtès) wrote:
> >
> >> > If there is a switch between extlinux and grub, the bootloader config
> file format (and name, too) will change.
> >> >
> >> > So if you do switch the config file out but don't switch the actual
> bootloader out it will not boot, right?
> >>
> >> Unless you regenerate the bootloader’s config file upon
> >> ‘switch-configuration’.
> >
> > Yes, for the last-guix-installed bootloader (presumably the
> still-installed one).  Good point.
> >
> > That would mean only the bootloader type of the newest system generation
> would be checked - also when restoring older generations.
> >
> > Can the newest system generation be deleted?  Then eventually Guix could
> read the wrong bootloader type (of a bootloader which isn't actually
> installed at the time).
>
> The newest generation can be deleted, but the current one cannot (it’s
> possible that the current one is not the newest if you picked an old
> entry in the boot menu.)
>
> So it should probably pick the current (not the newest) bootloader type.
>
> Ludo’.
>

[-- Attachment #2: Type: text/html, Size: 2465 bytes --]

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-12 12:18                       ` Mathieu Othacehe
@ 2017-05-13  9:53                         ` Danny Milosavljevic
  2017-05-14  7:49                           ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-13  9:53 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

On Fri, 12 May 2017 14:18:37 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> Hi !
> 
> > So it should probably pick the current (not the newest) bootloader type.  
> 
> I'm not fan of installing every bootloader config because it means
> multiple gcroots and filling /boot with possibly useless stuff.
> 
> However, reading the "parameters" of current system, extracting
> bootloader type, and reinstalling *only* the bootloader configuration
> file for this type seems a good idea to me.
> 
> I'll use this solution for v4.

If you mean that for "switch-generation" you use the current generation's bootloader but for "reconfigure" you use the newly-specified bootloader, I agree :)

Otherwise one could never switch the bootloader.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 0/7] Support non grub bootloaders.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
                   ` (2 preceding siblings ...)
  2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
@ 2017-05-14  7:47 ` Mathieu Othacehe
  2017-05-14  7:47   ` bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support Mathieu Othacehe
                     ` (6 more replies)
  2017-05-16 13:03 ` bug#26339: [PATCH] doc: Adapt to multiple bootloader support Mathieu Othacehe
                   ` (5 subsequent siblings)
  9 siblings, 7 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:47 UTC (permalink / raw)
  To: 26339

Hi,

Here's v4 of the serie. It addresses Danny and Ludo comments on v3.

Changelog:
* Add gnu/bootloader.scm and instanciate bootloaders
in gnu/bootloader directory.
* Split <bootloader-configuration> in two records.
* Do not reinstall bootloader on switch-generation,
only update configuration file.
* Various renamings.

Thanks,

Mathieu

Mathieu Othacehe (7):
  bootloader: Add extlinux support.
  bootloader: Adapt vm to new bootloader API.
  bootloader: Add bootloader name to boot-parameters record.
  scripts: system: Adapt "reconfigure" to new bootloader API.
  scripts: system: Adapt "init" to new bootloader API.
  scripts: system: Adapt "switch-generation" to new bootloader API.
  scripts: system: Display bootloader name in "list-generations".

 gnu.scm                             |   4 +-
 gnu/bootloader.scm                  | 114 ++++++++++++++++++
 gnu/bootloader/extlinux.scm         | 147 +++++++++++++++++++++++
 gnu/{system => bootloader}/grub.scm | 105 ++++++++++++-----
 gnu/build/install.scm               |  36 ++----
 gnu/build/vm.scm                    |  17 ++-
 gnu/local.mk                        |   4 +-
 gnu/system.scm                      |  26 ++--
 gnu/system/vm.scm                   |  38 ++++--
 gnu/tests.scm                       |   3 +-
 gnu/tests/nfs.scm                   |   3 +-
 guix/scripts/system.scm             | 228 ++++++++++++++++++++++--------------
 12 files changed, 546 insertions(+), 179 deletions(-)
 create mode 100644 gnu/bootloader.scm
 create mode 100644 gnu/bootloader/extlinux.scm
 rename gnu/{system => bootloader}/grub.scm (83%)

-- 
2.13.0

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
@ 2017-05-14  7:47   ` Mathieu Othacehe
  2017-05-14  8:43     ` Danny Milosavljevic
                       ` (2 more replies)
  2017-05-14  7:47   ` bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API Mathieu Othacehe
                     ` (5 subsequent siblings)
  6 siblings, 3 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:47 UTC (permalink / raw)
  To: 26339

* gnu/bootloader.scm: New file.
* gnu/bootloader/extlinux.scm: New file.
* gnu/bootloader/grub.scm: New file.
* gnu/local.mk: Build new files.
* gnu/system.scm: Adapt to new bootloader api.
* gnu/scripts/system.scm: Adapt to new bootloader api.
* gnu.scm: Remove (gnu system grub) and replace by (gnu bootloader) and (gnu
bootloader grub) modules.
* gnu/system/grub.scm: Moved content to gnu/bootloader/grub.scm.
* gnu/system/vm: Replace (gnu system grub) module by (gnu bootloader).
* gnu/tests.scm: Ditto.
* gnu/tests/nfs.scm: Ditto.
---
 gnu.scm                             |   4 +-
 gnu/bootloader.scm                  | 114 ++++++++++++++++++++++++++++
 gnu/bootloader/extlinux.scm         | 147 ++++++++++++++++++++++++++++++++++++
 gnu/{system => bootloader}/grub.scm | 105 ++++++++++++++++++--------
 gnu/local.mk                        |   4 +-
 gnu/system.scm                      |  14 ++--
 gnu/system/vm.scm                   |   2 +-
 gnu/tests.scm                       |   3 +-
 gnu/tests/nfs.scm                   |   3 +-
 guix/scripts/system.scm             |  20 +++--
 10 files changed, 364 insertions(+), 52 deletions(-)
 create mode 100644 gnu/bootloader.scm
 create mode 100644 gnu/bootloader/extlinux.scm
 rename gnu/{system => bootloader}/grub.scm (83%)

diff --git a/gnu.scm b/gnu.scm
index 932e4cdd5..913ce6160 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Joshua S. Grant <jgrant@parenthetical.io>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,7 +35,8 @@
       '((gnu system)
         (gnu system mapped-devices)
         (gnu system file-systems)
-        (gnu system grub)                         ; 'grub-configuration'
+        (gnu bootloader)
+        (gnu bootloader grub)
         (gnu system pam)
         (gnu system shadow)                       ; 'user-account'
         (gnu system linux-initrd)
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
new file mode 100644
index 000000000..77f81d33a
--- /dev/null
+++ b/gnu/bootloader.scm
@@ -0,0 +1,114 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 David Craven <david@craven.ch>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
+;;;
+;;; 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/>.
+
+(define-module (gnu bootloader)
+  #:use-module (guix discovery)
+  #:use-module (guix records)
+  #:use-module (guix ui)
+  #:use-module (srfi srfi-1)
+  #:export (bootloader
+            bootloader?
+            bootloader-name
+            bootloader-package
+            bootloader-theme
+            bootloader-installer
+            bootloader-configuration-file
+            bootloader-configuration-file-generator
+
+            bootloader-configuration
+            bootloader-configuration?
+            bootloader-configuration-bootloader
+            bootloader-configuration-device
+            bootloader-configuration-menu-entries
+            bootloader-configuration-default-entry
+            bootloader-configuration-timeout
+
+            %bootloaders
+            lookup-bootloader-by-name))
+
+\f
+;;;
+;;; Bootloader record.
+;;;
+
+;;; The <bootloader> record contains fields expressing how the bootloader
+;;; should be installed. Every bootloader in gnu/bootloader/ directory
+;;; has to be described by this record.
+
+(define-record-type* <bootloader>
+  bootloader make-bootloader
+  bootloader?
+  (name                            bootloader-name)
+  (package                         bootloader-package)
+  (theme                           bootloader-theme
+                                   (default #f))
+  (installer                       bootloader-installer)
+  (configuration-file              bootloader-configuration-file)
+  (configuration-file-generator    bootloader-configuration-file-generator))
+
+\f
+;;;
+;;; Bootloader configuration record.
+;;;
+
+;;; The <bootloader-configuration> record contains bootloader independant
+;;; configuration used to fill bootloader configuration file.
+
+(define-record-type* <bootloader-configuration>
+  bootloader-configuration make-bootloader-configuration
+  bootloader-configuration?
+  (bootloader                      bootloader-configuration-bootloader)    ; <bootloader>
+  (device                          bootloader-configuration-device         ; string
+                                   (default #f))
+  (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
+                                   (default '()))
+  (default-entry                   bootloader-configuration-default-entry  ; integer
+                                   (default 0))
+  (timeout                         bootloader-configuration-timeout        ; integer
+                                   (default 5))
+  (additional-configuration        bootloader-configuration-additional-configuration ; record
+                                   (default #f)))
+
+\f
+;;;
+;;; Bootloaders.
+;;;
+
+(define (bootloader-modules)
+  "Return the list of bootloader modules."
+  (all-modules (map (lambda (entry)
+                      `(,entry . "gnu/bootloader"))
+                    %load-path)))
+
+(define %bootloaders
+  ;; The list of publically-known bootloaders.
+  (delay (fold-module-public-variables (lambda (obj result)
+                                         (if (bootloader? obj)
+                                             (cons obj result)
+                                             result))
+                                       '()
+                                       (bootloader-modules))))
+
+(define (lookup-bootloader-by-name name)
+  "Return the bootloader called NAME."
+  (or (find (lambda (bootloader)
+              (format #t "~a\n" (eq? name (bootloader-name bootloader)))
+              (eq? name (bootloader-name bootloader)))
+            (force %bootloaders))
+      (leave (G_ "~a: no such bootloader~%") name)))
diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm
new file mode 100644
index 000000000..002477c0c
--- /dev/null
+++ b/gnu/bootloader/extlinux.scm
@@ -0,0 +1,147 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 David Craven <david@craven.ch>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
+;;;
+;;; 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/>.
+
+(define-module (gnu bootloader extlinux)
+  #:use-module (gnu bootloader)
+  #:use-module (gnu system)
+  #:use-module (gnu packages bootloaders)
+  #:use-module (guix gexp)
+  #:use-module (guix monads)
+  #:use-module (guix records)
+  #:use-module (guix utils)
+  #:export (extlinux-bootloader
+            syslinux-bootloader
+
+            extlinux-configuration
+            syslinux-configuration))
+
+(define* (extlinux-configuration-file config entries
+                                      #:key
+                                      (system (%current-system))
+                                      (old-entries '()))
+  "Return the U-Boot configuration file corresponding to CONFIG, a
+<u-boot-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."
+
+  (define all-entries
+    (append entries (bootloader-configuration-menu-entries config)))
+
+  (define (boot-parameters->gexp params)
+    (let ((label (boot-parameters-label params))
+          (kernel (boot-parameters-kernel params))
+          (kernel-arguments (boot-parameters-kernel-arguments params))
+          (initrd (boot-parameters-initrd params)))
+      #~(format port "LABEL ~a
+  MENU LABEL ~a
+  KERNEL ~a
+  FDTDIR ~a/lib/dtbs
+  INITRD ~a
+  APPEND ~a
+~%"
+                #$label #$label
+                #$kernel #$kernel #$initrd
+                (string-join (list #$@kernel-arguments)))))
+
+  (define builder
+    #~(call-with-output-file #$output
+        (lambda (port)
+          (let ((timeout #$(bootloader-configuration-timeout config)))
+            (format port "
+UI menu.c32
+PROMPT ~a
+TIMEOUT ~a~%"
+                    (if (> timeout 0) 1 0)
+                    ;; timeout is expressed in 1/10s of seconds.
+                    (* 10 timeout))
+            #$@(map boot-parameters->gexp all-entries)
+
+            #$@(if (pair? old-entries)
+                   #~((format port "~%")
+                      #$@(map boot-parameters->gexp old-entries)
+                      (format port "~%"))
+                   #~())))))
+
+  (gexp->derivation "extlinux.conf" builder))
+
+
+\f
+
+;;;
+;;; Install procedures.
+;;;
+
+(define dd
+  #~(lambda (bs count if of)
+      (zero? (system* "dd"
+                      (string-append "bs=" (number->string bs))
+                      (string-append "count=" (number->string count))
+                      (string-append "if=" if)
+                      (string-append "of=" of)))))
+
+(define install-syslinux
+  #~(lambda (bootloader device mount-point)
+      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
+            (install-dir (string-append mount-point "/boot/extlinux"))
+            (syslinux-dir (string-append bootloader "/share/syslinux")))
+        (mkdir-p install-dir)
+        (for-each (lambda (file)
+                    (copy-file file
+                               (string-append install-dir "/" (basename file))))
+                  (find-files syslinux-dir "\\.c32$"))
+
+        (unless (and (zero? (system* extlinux "--install" install-dir))
+                     (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
+          (error "failed to install SYSLINUX")))))
+
+\f
+
+;;;
+;;; Bootloader definitions.
+;;;
+
+(define extlinux-bootloader
+  (bootloader
+   (name 'extlinux)
+   (package #f)
+   (installer #f)
+   (configuration-file "/boot/extlinux/extlinux.conf")
+   (configuration-file-generator extlinux-configuration-file)))
+
+(define syslinux-bootloader
+  (bootloader
+   (inherit extlinux-bootloader)
+   (name 'syslinux)
+   (package syslinux)
+   (installer install-syslinux)))
+
+\f
+;;;
+;;; Compatibility macros.
+;;;
+
+(define-syntax-rule (extlinux-configuration fields ...)
+  (bootloader-configuration
+   (bootloader extlinux-bootloader)
+   fields ...))
+
+(define-syntax-rule (syslinux-configuration fields ...)
+  (bootloader-configuration
+   (bootloader syslinux-bootloader)
+   fields ...))
diff --git a/gnu/system/grub.scm b/gnu/bootloader/grub.scm
similarity index 83%
rename from gnu/system/grub.scm
rename to gnu/bootloader/grub.scm
index 58096429f..1dd50e391 100644
--- a/gnu/system/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -17,7 +18,7 @@
 ;;; You should have received a copy of the GNU General Public License
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
-(define-module (gnu system grub)
+(define-module (gnu bootloader grub)
   #:use-module (guix store)
   #:use-module (guix packages)
   #:use-module (guix derivations)
@@ -27,6 +28,7 @@
   #:use-module (guix download)
   #:use-module (gnu artwork)
   #:use-module (gnu system)
+  #:use-module (gnu bootloader)
   #:use-module (gnu system file-systems)
   #:autoload   (gnu packages bootloaders) (grub)
   #:autoload   (gnu packages compression) (gzip)
@@ -49,15 +51,11 @@
             %background-image
             %default-theme
 
-            grub-configuration
-            grub-configuration?
-            grub-configuration-device
-            grub-configuration-grub
-
-            menu-entry
-            menu-entry?
+            grub-bootloader
+            grub-efi-bootloader
 
-            grub-configuration-file))
+            grub-configuration
+            grub-efi-configuration))
 
 ;;; Commentary:
 ;;;
@@ -105,21 +103,6 @@ denoting a file name."
    (color-highlight '((fg . yellow) (bg . black)))
    (color-normal    '((fg . light-gray) (bg . black))))) ;XXX: #x303030
 
-(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)))
-
 (define-record-type* <menu-entry>
   menu-entry make-menu-entry
   menu-entry?
@@ -162,7 +145,8 @@ WIDTH/HEIGHT, or #f if none was found."
   (let* ((ratio (/ width height))
          (image (find (lambda (image)
                         (= (grub-image-aspect-ratio image) ratio))
-                      (grub-theme-images (grub-configuration-theme config)))))
+                      (grub-theme-images (bootloader-theme
+                                          (bootloader-configuration-bootloader config))))))
     (if image
         (svg->png (grub-image-file image)
                   #:width width #:height height)
@@ -205,7 +189,8 @@ system string---e.g., \"x86_64-linux\"."
         ""))
 
   (define (theme-colors type)
-    (let* ((theme  (grub-configuration-theme config))
+    (let* ((theme  (bootloader-theme
+                    (bootloader-configuration-bootloader config)))
            (colors (type theme)))
       (string-append (symbol->string (assoc-ref colors 'fg)) "/"
                      (symbol->string (assoc-ref colors 'bg)))))
@@ -282,12 +267,12 @@ code."
                                   (system (%current-system))
                                   (old-entries '()))
   "Return the GRUB configuration file corresponding to CONFIG, a
-<grub-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."
+<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."
   (define all-entries
     (append (map boot-parameters->menu-entry entries)
-            (grub-configuration-menu-entries config)))
+            (bootloader-configuration-menu-entries config)))
 
   (define entry->gexp
     (match-lambda
@@ -326,8 +311,8 @@ corresponding to old generations of the system."
             (format port "
 set default=~a
 set timeout=~a~%"
-                    #$(grub-configuration-default-entry config)
-                    #$(grub-configuration-timeout config))
+                    #$(bootloader-configuration-default-entry config)
+                    #$(bootloader-configuration-timeout config))
             #$@(map entry->gexp all-entries)
 
             #$@(if (pair? old-entries)
@@ -339,4 +324,60 @@ submenu \"GNU system, old configurations...\" {~%")
 
     (gexp->derivation "grub.cfg" builder)))
 
+\f
+
+;;;
+;;; 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")
+
+        (unless (zero? (system* grub "--no-floppy"
+                                "--boot-directory" install-dir
+                                device))
+          (error "failed to install GRUB")))))
+
+\f
+
+;;;
+;;; Bootloader definitions.
+;;;
+
+(define grub-bootloader
+  (bootloader
+   (name 'grub)
+   (package grub)
+   (theme %default-theme)
+   (installer install-grub)
+   (configuration-file "/boot/grub/grub.cfg")
+   (configuration-file-generator grub-configuration-file)))
+
+(define* grub-efi-bootloader
+  (bootloader
+   (inherit grub-bootloader)
+   (name 'grub-efi)
+   (package grub-efi)))
+
+\f
+;;;
+;;; Compatibility macros.
+;;;
+
+(define-syntax-rule (grub-configuration fields ...)
+  (bootloader-configuration
+   (bootloader grub-bootloader)
+   fields ...))
+
+(define-syntax-rule (grub-efi-configuration fields ...)
+  (bootloader-configuration
+   (bootloader grub-efi-bootloader)
+   fields ...))
+
 ;;; grub.scm ends here
diff --git a/gnu/local.mk b/gnu/local.mk
index 28a283ab7..73650c673 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -36,6 +36,9 @@
 GNU_SYSTEM_MODULES =				\
   gnu.scm					\
   %D%/artwork.scm				\
+  %D%/bootloader.scm				\
+  %D%/bootloader/grub.scm                       \
+  %D%/bootloader/extlinux.scm                   \
   %D%/packages.scm				\
   %D%/packages/abduco.scm			\
   %D%/packages/abiword.scm			\
@@ -441,7 +444,6 @@ GNU_SYSTEM_MODULES =				\
 						\
   %D%/system.scm				\
   %D%/system/file-systems.scm			\
-  %D%/system/grub.scm				\
   %D%/system/install.scm			\
   %D%/system/linux-container.scm		\
   %D%/system/linux-initrd.scm			\
diff --git a/gnu/system.scm b/gnu/system.scm
index 9fc6cc5e7..8040e2b15 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -48,6 +48,7 @@
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services base)
+  #:use-module (gnu bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system nss)
   #:use-module (gnu system locale)
@@ -138,7 +139,7 @@ booted from ROOT-DEVICE"
           (default linux-libre))
   (kernel-arguments operating-system-user-kernel-arguments
                     (default '()))                ; list of gexps/strings
-  (bootloader operating-system-bootloader)        ; <grub-configuration>
+  (bootloader operating-system-bootloader)        ; <bootloader-configuration>
 
   (initrd operating-system-initrd                 ; (list fs) -> M derivation
           (default base-initrd))
@@ -846,12 +847,11 @@ populate the \"old entries\" menu."
        (root-device -> (if (eq? 'uuid (file-system-title root-fs))
                            (uuid->string (file-system-device root-fs))
                            (file-system-device root-fs)))
-       (entry (operating-system-boot-parameters os system root-device)))
-    ((module-ref (resolve-interface '(gnu system grub))
-                 'grub-configuration-file)
-     (operating-system-bootloader os)
-     (list entry)
-     #:old-entries old-entries)))
+       (entry (operating-system-boot-parameters os system root-device))
+       (bootloader-conf -> (operating-system-bootloader os)))
+    ((bootloader-configuration-file-generator
+      (bootloader-configuration-bootloader bootloader-conf))
+     bootloader-conf (list entry) #:old-entries old-entries)))
 
 (define (fs->boot-device fs)
   "Given FS, a <file-system> object, return a value suitable for use as the
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 2c8b954c8..080014cde 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -49,7 +49,7 @@
   #:use-module (gnu system shadow)
   #:use-module (gnu system pam)
   #:use-module (gnu system linux-initrd)
-  #:use-module (gnu system grub)
+  #:use-module (gnu bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system)
   #:use-module (gnu services)
diff --git a/gnu/tests.scm b/gnu/tests.scm
index 810711ab9..2886a982f 100644
--- a/gnu/tests.scm
+++ b/gnu/tests.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,8 +21,8 @@
   #:use-module (guix gexp)
   #:use-module (guix utils)
   #:use-module (guix records)
+  #:use-module (gnu bootloader grub)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu services)
diff --git a/gnu/tests/nfs.scm b/gnu/tests/nfs.scm
index 1f28f5a5b..9e1ac1d55 100644
--- a/gnu/tests/nfs.scm
+++ b/gnu/tests/nfs.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 John Darrington <jmd@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,8 +20,8 @@
 
 (define-module (gnu tests nfs)
   #:use-module (gnu tests)
+  #:use-module (gnu bootloader grub)
   #:use-module (gnu system)
-  #:use-module (gnu system grub)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system shadow)
   #:use-module (gnu system vm)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 9c0976750..5fd0d7600 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -38,10 +38,10 @@
   #:use-module (guix build utils)
   #:use-module (gnu build install)
   #:use-module (gnu system)
+  #:use-module (gnu bootloader)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system linux-container)
   #:use-module (gnu system vm)
-  #:use-module (gnu system grub)
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services herd)
@@ -598,8 +598,12 @@ output when building a system derivation, such as a disk image."
                                                 #:image-size image-size
                                                 #:full-boot? full-boot?
                                                 #:mappings mappings))
-       (grub      (package->derivation (grub-configuration-grub
-                                        (operating-system-bootloader os))))
+       (bootloader (let ((bootloader (bootloader-package
+                                      (bootloader-configuration-bootloader
+                                       (operating-system-bootloader os)))))
+                     (if bootloader
+                         (package->derivation bootloader)
+                         (return #f))))
        (grub.cfg  (if (eq? 'container action)
                       (return #f)
                       (operating-system-bootcfg os
@@ -611,8 +615,8 @@ output when building a system derivation, such as a disk image."
        ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
        ;; root.  See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if bootloader?
-                          (list sys grub.cfg grub)
+                      (if (and bootloader? bootloader)
+                          (list sys grub.cfg bootloader)
                           (list sys grub.cfg))
                       (list sys)))
        (%         (if derivations-only?
@@ -628,8 +632,8 @@ output when building a system derivation, such as a disk image."
                     drvs)
 
           ;; Make sure GRUB is accessible.
-          (when bootloader?
-            (let ((prefix (derivation->output-path grub)))
+          (when (and bootloader? bootloader)
+            (let ((prefix (derivation->output-path bootloader)))
               (setenv "PATH"
                       (string-append  prefix "/bin:" prefix "/sbin:"
                                       (getenv "PATH")))))
@@ -832,7 +836,7 @@ resulting from command-line parsing."
                         ((first second) second)
                         (_ #f)))
          (device      (and bootloader?
-                           (grub-configuration-device
+                           (bootloader-configuration-device
                             (operating-system-bootloader os)))))
 
     (with-store store
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API.
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
  2017-05-14  7:47   ` bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support Mathieu Othacehe
@ 2017-05-14  7:47   ` Mathieu Othacehe
  2017-05-14  8:47     ` Danny Milosavljevic
  2017-05-14 13:28     ` Ludovic Courtès
  2017-05-14  7:47   ` bug#26339: [PATCH v4 3/7] bootloader: Add bootloader name to boot-parameters record Mathieu Othacehe
                     ` (4 subsequent siblings)
  6 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:47 UTC (permalink / raw)
  To: 26339

* gnu/build/install.scm (install-boot-config): New procedure.
  (install-grub): Move to (gnu bootloader grub).
* gnu/build/vm.scm (register-bootcfg-root): Rename register-grub.cfg-root and
  adjust accordingly.
  (initialize-hard-disk): Takes a bootloader-package, bootcfg, bootcfg-location and
  bootloader-installer procedure. Adjust accordingly.
* gnu/system/vm.scm (qemu-image): Adjust to initialize-hard-disk.
  (system-disk-image, system-qemu-image, system-qemu-image/shared-store):
  Adjust to qemu-image.
---
 gnu/build/install.scm | 36 ++++++++----------------------------
 gnu/build/vm.scm      | 17 +++++++++++------
 gnu/system/vm.scm     | 36 +++++++++++++++++++++++++-----------
 3 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index 5cb6055a0..9e30c0d23 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -22,8 +22,7 @@
   #:use-module (guix build store-copy)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
-  #:export (install-grub
-            install-grub-config
+  #:export (install-boot-config
             evaluate-populate-directive
             populate-root-file-system
             reset-timestamps
@@ -39,36 +38,17 @@
 ;;;
 ;;; Code:
 
-(define (install-grub grub.cfg device mount-point)
-  "Install GRUB with GRUB.CFG on DEVICE, which is assumed to be mounted on
-MOUNT-POINT.
-
-Note that the caller must make sure that GRUB.CFG is registered as a GC root
-so that the fonts, background images, etc. referred to by GRUB.CFG are not
-GC'd."
-  (install-grub-config grub.cfg mount-point)
-
-  ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or root
-  ;; partition.
-  (setenv "GRUB_ENABLE_CRYPTODISK" "y")
-
-  (unless (zero? (system* "grub-install" "--no-floppy"
-                          "--boot-directory"
-                          (string-append mount-point "/boot")
-                          device))
-    (error "failed to install GRUB")))
-
-(define (install-grub-config grub.cfg mount-point)
-  "Atomically copy GRUB.CFG into boot/grub/grub.cfg on the MOUNT-POINT.  Note
-that the caller must make sure that GRUB.CFG is registered as a GC root so
-that the fonts, background images, etc. referred to by GRUB.CFG are not GC'd."
-  (let* ((target (string-append mount-point "/boot/grub/grub.cfg"))
+(define (install-boot-config bootcfg bootcfg-location mount-point)
+  "Atomically copy BOOTCFG into BOOTCFG-LOCATION on the MOUNT-POINT.  Note
+that the caller must make sure that BOOTCFG is registered as a GC root so
+that the fonts, background images, etc. referred to by BOOTCFG are not GC'd."
+  (let* ((target (string-append mount-point bootcfg-location))
          (pivot  (string-append target ".new")))
     (mkdir-p (dirname target))
 
-    ;; Copy GRUB.CFG instead of just symlinking it, because symlinks won't
+    ;; Copy BOOTCFG instead of just symlinking it, because symlinks won't
     ;; work when /boot is on a separate partition.  Do that atomically.
-    (copy-file grub.cfg pivot)
+    (copy-file bootcfg pivot)
     (rename-file pivot target)))
 
 (define (evaluate-populate-directive directive target)
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 1eb9a4c45..9a77bee72 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -285,15 +285,18 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
     (unless register-closures?
       (reset-timestamps target))))
 
-(define (register-grub.cfg-root target bootcfg)
+(define (register-bootcfg-root target bootcfg)
   "On file system TARGET, register BOOTCFG as a GC root."
   (let ((directory (string-append target "/var/guix/gcroots")))
     (mkdir-p directory)
-    (symlink bootcfg (string-append directory "/grub.cfg"))))
+    (symlink bootcfg (string-append directory "/bootcfg"))))
 
 (define* (initialize-hard-disk device
                                #:key
-                               grub.cfg
+                               bootloader-package
+                               bootcfg
+                               bootcfg-location
+                               bootloader-installer
                                (partitions '()))
   "Initialize DEVICE as a disk containing all the <partition> objects listed
 in PARTITIONS, and using BOOTCFG as its bootloader configuration file.
@@ -311,10 +314,12 @@ passing it a directory name where it is mounted."
     (display "mounting root partition...\n")
     (mkdir-p target)
     (mount (partition-device root) target (partition-file-system root))
-    (install-grub grub.cfg device target)
+    (install-boot-config bootcfg bootcfg-location target)
+    (when bootloader-installer
+      (bootloader-installer bootloader-package device target))
 
-    ;; Register GRUB.CFG as a GC root.
-    (register-grub.cfg-root target grub.cfg)
+    ;; Register BOOTCFG as a GC root.
+    (register-bootcfg-root target bootcfg)
 
     (umount target)))
 
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 080014cde..fcdb5360d 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -46,6 +46,7 @@
                 #:select (%guile-static-stripped))
   #:use-module (gnu packages admin)
 
+  #:use-module (gnu bootloader)
   #:use-module (gnu system shadow)
   #:use-module (gnu system pam)
   #:use-module (gnu system linux-initrd)
@@ -176,8 +177,9 @@ made available under the /xchg CIFS share."
                      (disk-image-format "qcow2")
                      (file-system-type "ext4")
                      file-system-label
-                     os-derivation
-                     grub-configuration
+                     os.drv
+                     bootcfg.drv
+                     bootloader
                      (register-closures? #t)
                      (inputs '())
                      copy-inputs?)
@@ -201,7 +203,7 @@ the image."
                       (guix build utils))
 
          (let ((inputs
-                '#$(append (list qemu parted grub e2fsprogs)
+                '#$(append (list qemu parted e2fsprogs)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -223,7 +225,7 @@ the image."
                                #:closures graphs
                                #:copy-closures? #$copy-inputs?
                                #:register-closures? #$register-closures?
-                               #:system-directory #$os-derivation))
+                               #:system-directory #$os.drv))
                   (partitions (list (partition
                                      (size #$(- disk-image-size
                                                 (* 10 (expt 2 20))))
@@ -233,7 +235,13 @@ the image."
                                      (initializer initialize)))))
              (initialize-hard-disk "/dev/vda"
                                    #:partitions partitions
-                                   #:grub.cfg #$grub-configuration)
+                                   #:bootloader-package
+                                   #$(bootloader-package bootloader)
+                                   #:bootcfg #$bootcfg.drv
+                                   #:bootcfg-location
+                                   #$(bootloader-configuration-file bootloader)
+                                   #:bootloader-installer
+                                   #$(bootloader-installer bootloader))
              (reboot)))))
    #:system system
    #:make-disk-image? #t
@@ -287,8 +295,10 @@ to USB sticks meant to be read-only."
     (mlet* %store-monad ((os-drv   (operating-system-derivation os))
                          (bootcfg  (operating-system-bootcfg os)))
       (qemu-image #:name name
-                  #:os-derivation os-drv
-                  #:grub-configuration bootcfg
+                  #:os.drv os-drv
+                  #:bootcfg.drv bootcfg
+                  #:bootloader (bootloader-configuration-bootloader
+                                (operating-system-bootloader os))
                   #:disk-image-size disk-image-size
                   #:disk-image-format "raw"
                   #:file-system-type file-system-type
@@ -330,8 +340,10 @@ of the GNU system as described by OS."
     (mlet* %store-monad
         ((os-drv      (operating-system-derivation os))
          (bootcfg     (operating-system-bootcfg os)))
-      (qemu-image  #:os-derivation os-drv
-                   #:grub-configuration bootcfg
+      (qemu-image  #:os.drv os-drv
+                   #:bootcfg.drv bootcfg
+                   #:bootloader (bootloader-configuration-bootloader
+                                 (operating-system-bootloader os))
                    #:disk-image-size disk-image-size
                    #:file-system-type file-system-type
                    #:inputs `(("system" ,os-drv)
@@ -429,8 +441,10 @@ bootloader refers to: OS kernel, initrd, bootloader data, etc."
     ;; BOOTCFG and all its dependencies, including the output of OS-DRV.
     ;; This is more than needed (we only need the kernel, initrd, GRUB for its
     ;; font, and the background image), but it's hard to filter that.
-    (qemu-image #:os-derivation os-drv
-                #:grub-configuration bootcfg
+    (qemu-image #:os.drv os-drv
+                #:bootcfg.drv bootcfg
+                #:bootloader (bootloader-configuration-bootloader
+                              (operating-system-bootloader os))
                 #:disk-image-size disk-image-size
                 #:inputs (if full-boot?
                              `(("bootcfg" ,bootcfg))
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 3/7] bootloader: Add bootloader name to boot-parameters record.
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
  2017-05-14  7:47   ` bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support Mathieu Othacehe
  2017-05-14  7:47   ` bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API Mathieu Othacehe
@ 2017-05-14  7:47   ` Mathieu Othacehe
  2017-05-14  8:47     ` Danny Milosavljevic
  2017-05-14  7:48   ` bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
                     ` (3 subsequent siblings)
  6 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:47 UTC (permalink / raw)
  To: 26339

* gnu/system.scm (<boot-parameters>)[name]: New field.
(boot-parameters-boot-name): Ditto.
(operating-system-boot-parameters-file): Add new field.
(operating-system-boot-parameters): Ditto.
(read-boot-parameters): Ditto.
---
 gnu/system.scm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gnu/system.scm b/gnu/system.scm
index 8040e2b15..4631cc56f 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -104,6 +104,7 @@
             boot-parameters?
             boot-parameters-label
             boot-parameters-root-device
+            boot-parameters-boot-name
             boot-parameters-store-device
             boot-parameters-store-mount-point
             boot-parameters-kernel
@@ -213,6 +214,7 @@ directly by the user."
   ;; exactly to the device field of the <file-system> object representing the
   ;; OS's root file system, so it might be a device path like "/dev/sda3".
   (root-device      boot-parameters-root-device)
+  (boot-name        boot-parameters-boot-name)
   (store-device     boot-parameters-store-device)
   (store-mount-point boot-parameters-store-mount-point)
   (kernel           boot-parameters-kernel)
@@ -231,6 +233,11 @@ directly by the user."
       (label label)
       (root-device root)
 
+      (boot-name
+       (match (assq 'boot-name rest)
+         ((_ args) args)
+         (#f       'grub))) ; for compatibility reasons.
+
       ;; In the past, we would store the directory name of the kernel instead
       ;; of the absolute file name of its image.  Detect that and correct it.
       (kernel (if (string=? linux (direct-store-path linux))
@@ -868,6 +875,9 @@ kernel arguments for that derivation to <boot-parameters>."
   (mlet* %store-monad
       ((initrd (operating-system-initrd-file os))
        (store -> (operating-system-store-file-system os))
+       (bootloader  -> (bootloader-configuration-bootloader
+                        (operating-system-bootloader os)))
+       (boot-name   -> (bootloader-name bootloader))
        (label -> (kernel->boot-label (operating-system-kernel os))))
     (return (boot-parameters
              (label label)
@@ -878,6 +888,7 @@ kernel arguments for that derivation to <boot-parameters>."
                 (operating-system-kernel-arguments os system.drv root-device)
                 (operating-system-user-kernel-arguments os)))
              (initrd initrd)
+             (boot-name boot-name)
              (store-device (fs->boot-device store))
              (store-mount-point (file-system-mount-point store))))))
 
@@ -903,6 +914,7 @@ being stored into the \"parameters\" file)."
                     (kernel-arguments
                      #$(boot-parameters-kernel-arguments params))
                     (initrd #$(boot-parameters-initrd params))
+                    (boot-name #$(boot-parameters-boot-name params))
                     (store
                      (device #$(boot-parameters-store-device params))
                      (mount-point #$(boot-parameters-store-mount-point params))))
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
                     ` (2 preceding siblings ...)
  2017-05-14  7:47   ` bug#26339: [PATCH v4 3/7] bootloader: Add bootloader name to boot-parameters record Mathieu Othacehe
@ 2017-05-14  7:48   ` Mathieu Othacehe
  2017-05-14  8:50     ` Danny Milosavljevic
  2017-05-14 13:31     ` Ludovic Courtès
  2017-05-14  7:48   ` bug#26339: [PATCH v4 5/7] scripts: system: Adapt "init" " Mathieu Othacehe
                     ` (2 subsequent siblings)
  6 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:48 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install-grub*): Rename to install-bootloader. Use
  keys to pass arguments. Pass a new argument, "installer.drv" which is
  a script in store dealing with bootloader-specific install actions.
  Also call "install-boot-config" to install the bootloader config file.
(install-bootloader-derivation): New procedure. It returns a derivation that
builds a file containing "install-procedure" gexp.
(perform-action): Build install-proc derivation and call install-bootloader
with the resulting file. Stop adding GRUB to PATH as bootloaders are called in
install-proc with direct store paths.
---
 guix/scripts/system.scm | 129 +++++++++++++++++++++++++++++-------------------
 1 file changed, 77 insertions(+), 52 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 5fd0d7600..b194b59a7 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -147,27 +147,34 @@ TARGET, and register them."
               (map (cut copy-item <> target #:log-port log-port)
                    to-copy))))
 
-(define (install-grub* grub.cfg device target)
-  "This is a variant of 'install-grub' with error handling, lifted in
-%STORE-MONAD"
-  (let* ((gc-root      (string-append target %gc-roots-directory
-                                      "/grub.cfg"))
-         (temp-gc-root (string-append gc-root ".new"))
-         (delete-file  (lift1 delete-file %store-monad))
-         (make-symlink (lift2 switch-symlinks %store-monad))
-         (rename       (lift2 rename-file %store-monad)))
-    (mbegin %store-monad
-      ;; Prepare the symlink to GRUB.CFG to make sure that it's a GC root when
-      ;; 'install-grub' completes (being a bit paranoid.)
-      (make-symlink temp-gc-root grub.cfg)
-
-      (munless (false-if-exception (install-grub grub.cfg device target))
+(define* (install-bootloader installer.drv
+                             #:key
+                             bootcfg bootcfg-file
+                             device target)
+  "Call INSTALLER.DRV with error handling, in %STORE-MONAD."
+  (with-monad %store-monad
+    (let* ((gc-root      (string-append target %gc-roots-directory
+                                        "/bootcfg"))
+           (temp-gc-root (string-append gc-root ".new"))
+           (install (and installer.drv
+                         (derivation->output-path installer.drv)))
+           (bootcfg (derivation->output-path bootcfg)))
+      ;; Prepare the symlink to bootloader config file to make sure that it's
+      ;; a GC root when 'installer.drv' completes (being a bit paranoid.)
+      (switch-symlinks temp-gc-root bootcfg)
+
+      (unless (false-if-exception
+               (begin
+                 (install-boot-config bootcfg bootcfg-file target)
+                 (when install
+                   (save-load-path-excursion (primitive-load install)))))
         (delete-file temp-gc-root)
-        (leave (G_ "failed to install GRUB on device '~a'~%") device))
+        (leave (G_ "failed to install bootloader on device ~a '~a'~%") install device))
 
-      ;; Register GRUB.CFG as a GC root so that its dependencies (background
-      ;; image, font, etc.) are not reclaimed.
-      (rename temp-gc-root gc-root))))
+      ;; Register bootloader config file as a GC root so that its dependencies
+      ;; (background image, font, etc.) are not reclaimed.
+      (rename-file temp-gc-root gc-root)
+      (return #t))))
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
@@ -570,17 +577,28 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
     (warning (G_ "Consider running 'guix pull' before 'reconfigure'.~%"))
     (warning (G_ "Failing to do that may downgrade your system!~%"))))
 
+(define (bootloader-installer-derivation installer
+                                         bootloader device target)
+  "Return a file calling INSTALLER gexp with given BOOTLOADER, DEVICE
+and TARGET arguments."
+  (with-monad %store-monad
+    (gexp->file "bootloader-installer"
+                (with-imported-modules '((guix build utils))
+                  #~(begin
+                      (use-modules (guix build utils))
+                      (#$installer #$bootloader #$device #$target))))))
+
 (define* (perform-action action os
                          #:key bootloader? dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '())
                          (gc-root #f))
-  "Perform ACTION for OS.  GRUB? specifies whether to install GRUB; DEVICE is
-the target devices for GRUB; TARGET is the target root directory; IMAGE-SIZE
-is the size of the image to be built, for the 'vm-image' and 'disk-image'
-actions.  FULL-BOOT? is used for the 'vm' action; it determines whether to
-boot directly to the kernel or to the bootloader.
+  "Perform ACTION for OS.  BOOTLOADER? specifies whether to install
+bootloader; DEVICE is the target devices for bootloader; TARGET is the target
+root directory; IMAGE-SIZE is the size of the image to be built, for the
+'vm-image' and 'disk-image' actions.  FULL-BOOT? is used for the 'vm' action;
+it determines whether to boot directly to the kernel or to the bootloader.
 
 When DERIVATIONS-ONLY? is true, print the derivation file name(s) without
 building anything.
@@ -598,26 +616,37 @@ output when building a system derivation, such as a disk image."
                                                 #:image-size image-size
                                                 #:full-boot? full-boot?
                                                 #:mappings mappings))
-       (bootloader (let ((bootloader (bootloader-package
-                                      (bootloader-configuration-bootloader
-                                       (operating-system-bootloader os)))))
-                     (if bootloader
-                         (package->derivation bootloader)
-                         (return #f))))
-       (grub.cfg  (if (eq? 'container action)
-                      (return #f)
-                      (operating-system-bootcfg os
-                                                (if (eq? 'init action)
-                                                    '()
-                                                    (profile-boot-parameters)))))
-
-       ;; For 'init' and 'reconfigure', always build GRUB.CFG, even if
-       ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
-       ;; root.  See <http://bugs.gnu.org/21068>.
+       (bootloader -> (bootloader-configuration-bootloader
+                       (operating-system-bootloader os)))
+       (bootloader-package
+        (let ((package (bootloader-package bootloader)))
+          (if package
+              (package->derivation package)
+              (return #f))))
+       (bootcfg  (if (eq? 'container action)
+                     (return #f)
+                     (operating-system-bootcfg
+                      os
+                      (if (eq? 'init action)
+                          '()
+                          (profile-boot-parameters)))))
+       (bootcfg-file -> (bootloader-configuration-file bootloader))
+       (bootloader-installer
+        (let ((installer (bootloader-installer bootloader))
+              (target    (or target "/")))
+          (bootloader-installer-derivation installer
+                                           bootloader-package
+                                           device target)))
+
+       ;; For 'init' and 'reconfigure', always build BOOTCFG, even if
+       ;; --no-bootloader is passed, because we then use it as a GC root.
+       ;; See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if (and bootloader? bootloader)
-                          (list sys grub.cfg bootloader)
-                          (list sys grub.cfg))
+                      (if (and bootloader? bootloader-package)
+                          (list sys bootcfg
+                                bootloader-package
+                                bootloader-installer)
+                          (list sys bootcfg))
                       (list sys)))
        (%         (if derivations-only?
                       (return (for-each (compose println derivation-file-name)
@@ -631,20 +660,16 @@ output when building a system derivation, such as a disk image."
           (for-each (compose println derivation->output-path)
                     drvs)
 
-          ;; Make sure GRUB is accessible.
-          (when (and bootloader? bootloader)
-            (let ((prefix (derivation->output-path bootloader)))
-              (setenv "PATH"
-                      (string-append  prefix "/bin:" prefix "/sbin:"
-                                      (getenv "PATH")))))
-
           (case action
             ((reconfigure)
              (mbegin %store-monad
                (switch-to-system os)
                (mwhen bootloader?
-                 (install-grub* (derivation->output-path grub.cfg)
-                                device "/"))))
+                 (install-bootloader bootloader-installer
+                                     #:bootcfg bootcfg
+                                     #:bootcfg-file bootcfg-file
+                                     #:device device
+                                     #:target "/"))))
             ((init)
              (newline)
              (format #t (G_ "initializing operating system under '~a'...~%")
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 5/7] scripts: system: Adapt "init" to new bootloader API.
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
                     ` (3 preceding siblings ...)
  2017-05-14  7:48   ` bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
@ 2017-05-14  7:48   ` Mathieu Othacehe
  2017-05-14  8:51     ` Danny Milosavljevic
  2017-05-14  7:48   ` bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
  2017-05-14  7:48   ` bug#26339: [PATCH v4 7/7] scripts: system: Display bootloader name in "list-generations" Mathieu Othacehe
  6 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:48 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (install): Pass installer a new
argument. Rename other arguments.
Call install-bootloader instead of install-grub*.
(perform-action): Adapt.
---
 guix/scripts/system.scm | 44 +++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index b194b59a7..a40d026ec 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -178,12 +178,14 @@ TARGET, and register them."
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
-                  grub? grub.cfg device)
-  "Copy the closure of GRUB.CFG, which includes the output of OS-DRV, to
+                  bootloader-installer install-bootloader?
+                  bootcfg bootcfg-file
+                  device)
+  "Copy the closure of BOOTCFG, which includes the output of OS-DRV, to
 directory TARGET.  TARGET must be an absolute directory name since that's what
 'guix-register' expects.
 
-When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG."
+When INSTALL-BOOTLOADER? is true, install bootloader on DEVICE, using BOOTCFG."
   (define (maybe-copy to-copy)
     (with-monad %store-monad
       (if (string=? target "/")
@@ -212,16 +214,21 @@ the ownership of '~a' may be incorrect!~%")
         (populate (lift2 populate-root-file-system %store-monad)))
 
     (mbegin %store-monad
-      ;; Copy the closure of GRUB.CFG, which includes OS-DIR, GRUB's
-      ;; background image and so on.
-      (maybe-copy grub.cfg)
+      ;; Copy the closure of BOOTCFG, which includes OS-DIR,
+      ;; eventual background image and so on.
+      (maybe-copy
+       (derivation->output-path bootcfg))
 
       ;; Create a bunch of additional files.
       (format log-port "populating '~a'...~%" target)
       (populate os-dir target)
 
-      (mwhen grub?
-        (install-grub* grub.cfg device target)))))
+      (mwhen install-bootloader?
+        (install-bootloader bootloader-installer
+                            #:bootcfg bootcfg
+                            #:bootcfg-file bootcfg-file
+                            #:device device
+                            #:target target)))))
 
 \f
 ;;;
@@ -589,12 +596,13 @@ and TARGET arguments."
                       (#$installer #$bootloader #$device #$target))))))
 
 (define* (perform-action action os
-                         #:key bootloader? dry-run? derivations-only?
+                         #:key install-bootloader?
+                         dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '())
                          (gc-root #f))
-  "Perform ACTION for OS.  BOOTLOADER? specifies whether to install
+  "Perform ACTION for OS.  INSTALL-BOOTLOADER? specifies whether to install
 bootloader; DEVICE is the target devices for bootloader; TARGET is the target
 root directory; IMAGE-SIZE is the size of the image to be built, for the
 'vm-image' and 'disk-image' actions.  FULL-BOOT? is used for the 'vm' action;
@@ -642,10 +650,10 @@ output when building a system derivation, such as a disk image."
        ;; --no-bootloader is passed, because we then use it as a GC root.
        ;; See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if (and bootloader? bootloader-package)
+                      (if (and install-bootloader? bootloader-package)
                           (list sys bootcfg
-                                bootloader-package
-                                bootloader-installer)
+				bootloader-package
+				bootloader-installer)
                           (list sys bootcfg))
                       (list sys)))
        (%         (if derivations-only?
@@ -664,7 +672,7 @@ output when building a system derivation, such as a disk image."
             ((reconfigure)
              (mbegin %store-monad
                (switch-to-system os)
-               (mwhen bootloader?
+               (mwhen install-bootloader?
                  (install-bootloader bootloader-installer
                                      #:bootcfg bootcfg
                                      #:bootcfg-file bootcfg-file
@@ -675,8 +683,10 @@ output when building a system derivation, such as a disk image."
              (format #t (G_ "initializing operating system under '~a'...~%")
                      target)
              (install sys (canonicalize-path target)
-                      #:grub? bootloader?
-                      #:grub.cfg (derivation->output-path grub.cfg)
+                      #:install-bootloader? install-bootloader?
+                      #:bootcfg bootcfg
+                      #:bootcfg-file bootcfg-file
+                      #:bootloader-installer bootloader-installer
                       #:device device))
             (else
              ;; All we had to do was to build SYS and maybe register an
@@ -890,7 +900,7 @@ resulting from command-line parsing."
                                                        m)
                                                       (_ #f))
                                                     opts)
-                             #:bootloader? bootloader?
+                             #:install-bootloader? bootloader?
                              #:target target #:device device
                              #:gc-root (assoc-ref opts 'gc-root)))))
         #:system system))))
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
                     ` (4 preceding siblings ...)
  2017-05-14  7:48   ` bug#26339: [PATCH v4 5/7] scripts: system: Adapt "init" " Mathieu Othacehe
@ 2017-05-14  7:48   ` Mathieu Othacehe
  2017-05-14  8:52     ` Danny Milosavljevic
  2017-05-14  8:54     ` Danny Milosavljevic
  2017-05-14  7:48   ` bug#26339: [PATCH v4 7/7] scripts: system: Display bootloader name in "list-generations" Mathieu Othacehe
  6 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:48 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (reinstall-grub): Rename to
  reinstall-bootloader. Read boot-device and boot-type from parameters file to
  be able to restore the correct bootloader on specified device.
  Factorize bootloader installation code by calling install-bootloader.
 (system-bootloader-name): New procedure.
 (switch-to-system-generation): Adapt.
---
 guix/scripts/system.scm | 61 +++++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 27 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index a40d026ec..01070ce6e 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -412,49 +412,56 @@ connection to the store."
 ;;;
 (define (switch-to-system-generation store spec)
   "Switch the system profile to the generation specified by SPEC, and
-re-install grub with a grub configuration file that uses the specified system
+re-install bootloader with a configuration file that uses the specified system
 generation as its default entry.  STORE is an open connection to the store."
   (let ((number (relative-generation-spec->number %system-profile spec)))
     (if number
         (begin
-          (reinstall-grub store number)
+          (reinstall-bootloader store number)
           (switch-to-generation* %system-profile number))
         (leave (G_ "cannot switch to system generation '~a'~%") spec))))
 
-(define (reinstall-grub store number)
-  "Re-install grub for existing system profile generation NUMBER.  STORE is an
-open connection to the store."
+(define* (system-bootloader-name #:optional (system %system-profile))
+  "Return the bootloader name stored in SYSTEM's \"parameters\" file."
+  (let ((params (unless-file-not-found
+                 (read-boot-parameters-file system))))
+    (boot-parameters-boot-name params)))
+
+(define (reinstall-bootloader store number)
+  "Re-install bootloader for existing system profile generation NUMBER.
+STORE is an open connection to the store."
   (let* ((generation (generation-file-name %system-profile number))
          (params (unless-file-not-found
                   (read-boot-parameters-file generation)))
-         (root-device (boot-parameters-root-device params))
          ;; We don't currently keep track of past menu entries' details.  The
          ;; default values will allow the system to boot, even if they differ
          ;; from the actual past values for this generation's entry.
-         (grub-config (grub-configuration (device root-device)))
+         (bootloader (lookup-bootloader-by-name (system-bootloader-name)))
+         (bootloader-config (bootloader-configuration
+                             (bootloader bootloader)))
          ;; Make the specified system generation the default entry.
          (entries (profile-boot-parameters %system-profile (list number)))
          (old-generations (delv number (generation-numbers %system-profile)))
-         (old-entries (profile-boot-parameters %system-profile old-generations))
-         (grub.cfg (run-with-store store
-                     (grub-configuration-file grub-config
-                                              entries
-                                              #:old-entries old-entries))))
-    (show-what-to-build store (list grub.cfg))
-    (build-derivations store (list grub.cfg))
-    ;; This is basically the same as install-grub*, but for now we avoid
-    ;; re-installing the GRUB boot loader itself onto a device, mainly because
-    ;; we don't in general have access to the same version of the GRUB package
-    ;; which was used when installing this other system generation.
-    (let* ((grub.cfg-path (derivation->output-path grub.cfg))
-           (gc-root (string-append %gc-roots-directory "/grub.cfg"))
-           (temp-gc-root (string-append gc-root ".new")))
-      (switch-symlinks temp-gc-root grub.cfg-path)
-      (unless (false-if-exception (install-grub-config grub.cfg-path "/"))
-        (delete-file temp-gc-root)
-        (leave (G_ "failed to re-install GRUB configuration file: '~a'~%")
-               grub.cfg-path))
-      (rename-file temp-gc-root gc-root))))
+         (old-entries (profile-boot-parameters
+                       %system-profile old-generations)))
+    (run-with-store store
+      (mlet* %store-monad
+          ((bootcfg ((bootloader-configuration-file-generator bootloader)
+                     bootloader-config entries
+                     #:old-entries old-entries))
+           (bootcfg-file -> (bootloader-configuration-file bootloader))
+           (target -> "/")
+           (drvs -> (list bootcfg)))
+        (mbegin %store-monad
+          (show-what-to-build* drvs)
+          (built-derivations drvs)
+          ;; PARAMS file may not contain a suitable BOOT-DEVICE. If BOOT-DEVICE
+          ;; is #f do not run BOOTLOADER-INSTALLER during bootloader installation.
+          (install-bootloader #f
+                              #:bootcfg bootcfg
+                              #:bootcfg-file bootcfg-file
+                              #:device #f
+                              #:target target))))))
 
 \f
 ;;;
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 7/7] scripts: system: Display bootloader name in "list-generations".
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
                     ` (5 preceding siblings ...)
  2017-05-14  7:48   ` bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
@ 2017-05-14  7:48   ` Mathieu Othacehe
  2017-05-14 13:33     ` Ludovic Courtès
  6 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:48 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.scm (display-system-generation): Display
  bootloader name.
---
 guix/scripts/system.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 01070ce6e..05ac13e7a 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -519,6 +519,7 @@ list of services."
     (let* ((generation  (generation-file-name profile number))
            (params      (read-boot-parameters-file generation))
            (label       (boot-parameters-label params))
+           (boot-name   (boot-parameters-boot-name params))
            (root        (boot-parameters-root-device params))
            (root-device (if (bytevector? root)
                             (uuid->string root)
@@ -529,6 +530,7 @@ list of services."
       (format #t (G_ "  canonical file name: ~a~%") (readlink* generation))
       ;; TRANSLATORS: Please preserve the two-space indentation.
       (format #t (G_ "  label: ~a~%") label)
+      (format #t (G_ "  bootloader name: ~a~%") boot-name)
       (format #t (G_ "  root device: ~a~%") root-device)
       (format #t (G_ "  kernel: ~a~%") kernel))))
 
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH 02/18] system: Add extlinux support.
  2017-05-13  9:53                         ` Danny Milosavljevic
@ 2017-05-14  7:49                           ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-14  7:49 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi Danny,

> If you mean that for "switch-generation" you use the current generation's bootloader but for "reconfigure" you use the newly-specified bootloader, I agree :)
>

Yes I meant for switch-generation, sorry for the imprecision. I just
sent v4 if you want to have a look :)

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-14  7:47   ` bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support Mathieu Othacehe
@ 2017-05-14  8:43     ` Danny Milosavljevic
  2017-05-16 12:46       ` Mathieu Othacehe
  2017-05-14 13:25     ` Ludovic Courtès
  2017-05-14 13:35     ` Ludovic Courtès
  2 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14  8:43 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

>+++ b/gnu/bootloader.scm
[...]
>+(define-record-type* <bootloader-configuration>
> +  (menu-entries                    bootloader-configuration-menu-entries   ; list of <boot-parameters>
> +                                   (default '()))

At first I thought this could be confused with grub menu-entries - but on second thought they are similar enough.

> +  (timeout                         bootloader-configuration-timeout        ; integer
> +                                   (default 5))

Can you add a comment about the unit?

> +(define (lookup-bootloader-by-name name)
> +  "Return the bootloader called NAME."
> +  (or (find (lambda (bootloader)
> +              (format #t "~a\n" (eq? name (bootloader-name bootloader)))

Left-over debugging message?

>      (append (map boot-parameters->menu-entry entries)
> -            (grub-configuration-menu-entries config)))
> +            (bootloader-configuration-menu-entries config)))

So bootloader-configuration-menu-entries are grub menu-entries, right?  Earlier the code said they were boot-parameters (see quoted text above).

>+++ b/gnu/bootloader/grub.scm
> +(define-syntax-rule (grub-configuration fields ...)
> +  (bootloader-configuration
> +   (bootloader grub-bootloader)
> +   fields ...))

Will these be able to resolve the symbols used?  Because there are new modules now etc - do old configuration files which don't import those modules still work?

> -       (entry (operating-system-boot-parameters os system root-device)))
> -    ((module-ref (resolve-interface '(gnu system grub))
> -                 'grub-configuration-file)
> -     (operating-system-bootloader os)
> -     (list entry)
> -     #:old-entries old-entries)))
> +       (entry (operating-system-boot-parameters os system root-device))
> +       (bootloader-conf -> (operating-system-bootloader os)))
> +    ((bootloader-configuration-file-generator
> +      (bootloader-configuration-bootloader bootloader-conf))
> +     bootloader-conf (list entry) #:old-entries old-entries)))

Yay my band-aid is gone :)

Remainder of this patch LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API.
  2017-05-14  7:47   ` bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API Mathieu Othacehe
@ 2017-05-14  8:47     ` Danny Milosavljevic
  2017-05-14 13:28     ` Ludovic Courtès
  1 sibling, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14  8:47 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 3/7] bootloader: Add bootloader name to boot-parameters record.
  2017-05-14  7:47   ` bug#26339: [PATCH v4 3/7] bootloader: Add bootloader name to boot-parameters record Mathieu Othacehe
@ 2017-05-14  8:47     ` Danny Milosavljevic
  2017-05-14 13:29       ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14  8:47 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-14  7:48   ` bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
@ 2017-05-14  8:50     ` Danny Milosavljevic
  2017-05-14 13:31     ` Ludovic Courtès
  1 sibling, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14  8:50 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 5/7] scripts: system: Adapt "init" to new bootloader API.
  2017-05-14  7:48   ` bug#26339: [PATCH v4 5/7] scripts: system: Adapt "init" " Mathieu Othacehe
@ 2017-05-14  8:51     ` Danny Milosavljevic
  2017-05-14 13:31       ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14  8:51 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-14  7:48   ` bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
@ 2017-05-14  8:52     ` Danny Milosavljevic
  2017-05-14 13:32       ` Ludovic Courtès
  2017-05-14  8:54     ` Danny Milosavljevic
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14  8:52 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-14  7:48   ` bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
  2017-05-14  8:52     ` Danny Milosavljevic
@ 2017-05-14  8:54     ` Danny Milosavljevic
  2017-05-16 12:46       ` Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14  8:54 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

> +          ;; PARAMS file may not contain a suitable BOOT-DEVICE. If BOOT-DEVICE
> +          ;; is #f do not run BOOTLOADER-INSTALLER during bootloader installation.

Comment outdated?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-14  7:47   ` bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support Mathieu Othacehe
  2017-05-14  8:43     ` Danny Milosavljevic
@ 2017-05-14 13:25     ` Ludovic Courtès
  2017-05-16 12:51       ` Mathieu Othacehe
  2017-05-14 13:35     ` Ludovic Courtès
  2 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:25 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hello Mathieu,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/bootloader.scm: New file.
> * gnu/bootloader/extlinux.scm: New file.
> * gnu/bootloader/grub.scm: New file.
> * gnu/local.mk: Build new files.
> * gnu/system.scm: Adapt to new bootloader api.
> * gnu/scripts/system.scm: Adapt to new bootloader api.
> * gnu.scm: Remove (gnu system grub) and replace by (gnu bootloader) and (gnu
> bootloader grub) modules.
> * gnu/system/grub.scm: Moved content to gnu/bootloader/grub.scm.
> * gnu/system/vm: Replace (gnu system grub) module by (gnu bootloader).
> * gnu/tests.scm: Ditto.
> * gnu/tests/nfs.scm: Ditto.

Nice!  Some very minor comments before you push:

> +;;; The <bootloader> record contains fields expressing how the bootloader
> +;;; should be installed. Every bootloader in gnu/bootloader/ directory
> +;;; has to be described by this record.
   ^
Only two semicolons here.  :-)

> +  (theme                           bootloader-theme
> +                                   (default #f))

I would expect the theme to be part of <bootloader-configuration> rather
than <bootloader> no?  For example GRUB does not impose a particular
theme.

> +(define dd
> +  #~(lambda (bs count if of)
> +      (zero? (system* "dd"
> +                      (string-append "bs=" (number->string bs))
> +                      (string-append "count=" (number->string count))
> +                      (string-append "if=" if)
> +                      (string-append "of=" of)))))

Dunno but in the future it may be better to use ‘dump-port’ from (guix
build utils) than to invoke ‘dd’.

> +(define install-syslinux
> +  #~(lambda (bootloader device mount-point)
> +      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
> +            (install-dir (string-append mount-point "/boot/extlinux"))
> +            (syslinux-dir (string-append bootloader "/share/syslinux")))
> +        (mkdir-p install-dir)
> +        (for-each (lambda (file)
> +                    (copy-file file
> +                               (string-append install-dir "/" (basename file))))

Rather: (install-file file install-dir).

> +;;;
> +;;; Bootloader definitions.
> +;;;
> +
> +(define extlinux-bootloader
> +  (bootloader
> +   (name 'extlinux)
> +   (package #f)
> +   (installer #f)

Why #f here?  Looks fishy.

> +;;;
> +;;; Compatibility macros.
> +;;;
> +
> +(define-syntax-rule (extlinux-configuration fields ...)
> +  (bootloader-configuration
> +   (bootloader extlinux-bootloader)
> +   fields ...))
> +
> +(define-syntax-rule (syslinux-configuration fields ...)
> +  (bootloader-configuration
> +   (bootloader syslinux-bootloader)
> +   fields ...))

We can omit these two macros since they have never existed before this
patch.  New users will write:

  (bootloader-configuration
    (bootloader syslinux-bootloader)
    …)

Speaking of which, could you update guix.texi, maybe in a subsequent
patch to avoid blocking this one?  I suppose “GRUB Configuration” would
have to be renamed to “Bootloader Configuration”.

> +;;;
> +;;; Compatibility macros.
> +;;;
> +
> +(define-syntax-rule (grub-configuration fields ...)
> +  (bootloader-configuration
> +   (bootloader grub-bootloader)
> +   fields ...))
> +
> +(define-syntax-rule (grub-efi-configuration fields ...)
> +  (bootloader-configuration
> +   (bootloader grub-efi-bootloader)
> +   fields ...))

The second macro can be removed (it did not exist before).

However the first one might need to be improved to be really compatible
with what exists now.  For instance, my laptop’s config has this:

  (grub-configuration
    (grub grub-efi)
    (device "/dev/sda"))

So we probably need something like this (untested):

  (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 ...))))

This will only address the simple case where the ‘grub’ field comes
first, but that should be OK (esp. since UEFI support was not documented
until now…).

Otherwise LGTM, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API.
  2017-05-14  7:47   ` bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API Mathieu Othacehe
  2017-05-14  8:47     ` Danny Milosavljevic
@ 2017-05-14 13:28     ` Ludovic Courtès
  2017-05-14 14:59       ` Danny Milosavljevic
  1 sibling, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:28 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/build/install.scm (install-boot-config): New procedure.
>   (install-grub): Move to (gnu bootloader grub).
> * gnu/build/vm.scm (register-bootcfg-root): Rename register-grub.cfg-root and
>   adjust accordingly.
>   (initialize-hard-disk): Takes a bootloader-package, bootcfg, bootcfg-location and
>   bootloader-installer procedure. Adjust accordingly.
> * gnu/system/vm.scm (qemu-image): Adjust to initialize-hard-disk.
>   (system-disk-image, system-qemu-image, system-qemu-image/shared-store):
>   Adjust to qemu-image.

[...]

> --- a/gnu/system/vm.scm
> +++ b/gnu/system/vm.scm
> @@ -46,6 +46,7 @@
>                  #:select (%guile-static-stripped))
>    #:use-module (gnu packages admin)
>  
> +  #:use-module (gnu bootloader)
>    #:use-module (gnu system shadow)
>    #:use-module (gnu system pam)
>    #:use-module (gnu system linux-initrd)
> @@ -176,8 +177,9 @@ made available under the /xchg CIFS share."
>                       (disk-image-format "qcow2")
>                       (file-system-type "ext4")
>                       file-system-label
> -                     os-derivation
> -                     grub-configuration
> +                     os.drv
> +                     bootcfg.drv
> +                     bootloader

I suggest avoiding dots in identifiers (RnRS Scheme does not allow it
because it can conflict with the dot notation for pairs.)  Use a hyphen
instead.

Apart from that, if the system tests are happy after this change, fine
with me too!

Thank you,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 3/7] bootloader: Add bootloader name to boot-parameters record.
  2017-05-14  8:47     ` Danny Milosavljevic
@ 2017-05-14 13:29       ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:29 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> LGTM!

+1

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API.
  2017-05-14  7:48   ` bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
  2017-05-14  8:50     ` Danny Milosavljevic
@ 2017-05-14 13:31     ` Ludovic Courtès
  1 sibling, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:31 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * guix/scripts/system.scm (install-grub*): Rename to install-bootloader. Use
>   keys to pass arguments. Pass a new argument, "installer.drv" which is
>   a script in store dealing with bootloader-specific install actions.
>   Also call "install-boot-config" to install the bootloader config file.
 ^^
Extra space.

> (install-bootloader-derivation): New procedure. It returns a derivation that
> builds a file containing "install-procedure" gexp.
> (perform-action): Build install-proc derivation and call install-bootloader
> with the resulting file. Stop adding GRUB to PATH as bootloaders are called in
> install-proc with direct store paths.

[...]

> +(define* (install-bootloader installer.drv

Please avoid dots in identifiers.

Otherwise LGTM!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 5/7] scripts: system: Adapt "init" to new bootloader API.
  2017-05-14  8:51     ` Danny Milosavljevic
@ 2017-05-14 13:31       ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:31 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> LGTM!

Ditto!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-14  8:52     ` Danny Milosavljevic
@ 2017-05-14 13:32       ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:32 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> LGTM!

+1!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 7/7] scripts: system: Display bootloader name in "list-generations".
  2017-05-14  7:48   ` bug#26339: [PATCH v4 7/7] scripts: system: Display bootloader name in "list-generations" Mathieu Othacehe
@ 2017-05-14 13:33     ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:33 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * guix/scripts/system.scm (display-system-generation): Display
>   bootloader name.

[...]

> +      (format #t (G_ "  bootloader name: ~a~%") boot-name)

Simply “bootloader:”.

Otherwise OK, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-14  7:47   ` bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support Mathieu Othacehe
  2017-05-14  8:43     ` Danny Milosavljevic
  2017-05-14 13:25     ` Ludovic Courtès
@ 2017-05-14 13:35     ` Ludovic Courtès
  2017-05-16 12:55       ` Mathieu Othacehe
  2 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 13:35 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

BTW, it would be nice if, in a subsequent patch, you could add an
extlinux/syslinux test.  It’s probably going to be less used than GRUB
so having a test would help avoid bitrot.

Anyway, thanks for your patience and hard work on this series, thanks to
David for starting it and to Danny for tirelessly reviewing it!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API.
  2017-05-14 13:28     ` Ludovic Courtès
@ 2017-05-14 14:59       ` Danny Milosavljevic
  2017-05-14 19:53         ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-14 14:59 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

On Sun, 14 May 2017 15:28:47 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> I suggest avoiding dots in identifiers (RnRS Scheme does not allow it
> because it can conflict with the dot notation for pairs.)  Use a hyphen
> instead.

... oops.  My fault for suggesting it.  I didn't have practical problems with dots before and some parts in Guix already use the dot
(latest-kernel.org-release, package definitions and the previous bootloader that's in master for a long time).

But good to know.  I shall use no dots in identifiers in the future.  Any preference of how to name derivations?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API.
  2017-05-14 14:59       ` Danny Milosavljevic
@ 2017-05-14 19:53         ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-05-14 19:53 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> On Sun, 14 May 2017 15:28:47 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> I suggest avoiding dots in identifiers (RnRS Scheme does not allow it
>> because it can conflict with the dot notation for pairs.)  Use a hyphen
>> instead.
>
> ... oops.  My fault for suggesting it.  I didn't have practical problems with dots before and some parts in Guix already use the dot
> (latest-kernel.org-release, package definitions and the previous bootloader that's in master for a long time).

Right, dots in identifiers are valid in Guile, I even use them for
packages, but somehow I mentally have double-standards between (gnu
packages …) modules and the rest.  :-)

> But good to know.  I shall use no dots in identifiers in the future.  Any preference of how to name derivations?

Often it’s enough to name them by what the correspond to (say “profile”,
“config-file”, etc.).  In other cases, I usually use things like
“os-drv” or “drv”.

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-14  8:43     ` Danny Milosavljevic
@ 2017-05-16 12:46       ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-16 12:46 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi Danny,

> Can you add a comment about the unit?

Done.

> Left-over debugging message?

Ooop ;)

> So bootloader-configuration-menu-entries are grub menu-entries, right?  Earlier the code said they were boot-parameters (see quoted text above).

Yes you're right there were a confusion here. I fixed it before applying.
>
>>+++ b/gnu/bootloader/grub.scm
>> +(define-syntax-rule (grub-configuration fields ...)
>> +  (bootloader-configuration
>> +   (bootloader grub-bootloader)
>> +   fields ...))
>
> Will these be able to resolve the symbols used?  Because there are new modules now etc - do old configuration files which don't import those modules still work?

Yes the will because most modules included (gnu) which no includes (gnu
bootloader grub). For modules directly including (gnu system grub), this
patch was already ok. See (gnu tests) for instance.

>
>> -       (entry (operating-system-boot-parameters os system root-device)))
>> -    ((module-ref (resolve-interface '(gnu system grub))
>> -                 'grub-configuration-file)
>> -     (operating-system-bootloader os)
>> -     (list entry)
>> -     #:old-entries old-entries)))
>> +       (entry (operating-system-boot-parameters os system root-device))
>> +       (bootloader-conf -> (operating-system-bootloader os)))
>> +    ((bootloader-configuration-file-generator
>> +      (bootloader-configuration-bootloader bootloader-conf))
>> +     bootloader-conf (list entry) #:old-entries old-entries)))
>
> Yay my band-aid is gone :)

Yop !

>
> Remainder of this patch LGTM!

Thanks for your review !

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" to new bootloader API.
  2017-05-14  8:54     ` Danny Milosavljevic
@ 2017-05-16 12:46       ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-16 12:46 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


>> +          ;; PARAMS file may not contain a suitable BOOT-DEVICE. If BOOT-DEVICE
>> +          ;; is #f do not run BOOTLOADER-INSTALLER during bootloader installation.
>
> Comment outdated?

You're right I changed it before applying.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-14 13:25     ` Ludovic Courtès
@ 2017-05-16 12:51       ` Mathieu Othacehe
  2017-05-16 14:38         ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-16 12:51 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


Hi Ludo,

> Nice!  Some very minor comments before you push:

Thank you :)

> Only two semicolons here.  :-)

Ok.

>
>> +  (theme                           bootloader-theme
>> +                                   (default #f))
>
> I would expect the theme to be part of <bootloader-configuration> rather
> than <bootloader> no?  For example GRUB does not impose a particular
> theme.

Ok I moved it to <bootloader-configuration>.

>
>> +(define dd
>> +  #~(lambda (bs count if of)
>> +      (zero? (system* "dd"
>> +                      (string-append "bs=" (number->string bs))
>> +                      (string-append "count=" (number->string count))
>> +                      (string-append "if=" if)
>> +                      (string-append "of=" of)))))
>
> Dunno but in the future it may be better to use ‘dump-port’ from (guix
> build utils) than to invoke ‘dd’.

Ok, I'll consider it in a follow-up serie.

>
>> +(define install-syslinux
>> +  #~(lambda (bootloader device mount-point)
>> +      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
>> +            (install-dir (string-append mount-point "/boot/extlinux"))
>> +            (syslinux-dir (string-append bootloader "/share/syslinux")))
>> +        (mkdir-p install-dir)
>> +        (for-each (lambda (file)
>> +                    (copy-file file
>> +                               (string-append install-dir "/" (basename file))))
>
> Rather: (install-file file install-dir).

Ok.

>
>> +;;;
>> +;;; Bootloader definitions.
>> +;;;
>> +
>> +(define extlinux-bootloader
>> +  (bootloader
>> +   (name 'extlinux)
>> +   (package #f)
>> +   (installer #f)
>
> Why #f here?  Looks fishy.

It turns out that the distinction between extlinux and syslinux was
weird in David serie. "extlinux" bootloader was no installing anything.

My understanding is that extlinux is one of the bootloaders provided by
the syslinux package. So, I removed the notion of "syslinux-bootloader"
and only kepy an "extlinux-bootloader" before applying.

>
>> +;;;
>> +;;; Compatibility macros.
>> +;;;
>> +
>> +(define-syntax-rule (extlinux-configuration fields ...)
>> +  (bootloader-configuration
>> +   (bootloader extlinux-bootloader)
>> +   fields ...))
>> +
>> +(define-syntax-rule (syslinux-configuration fields ...)
>> +  (bootloader-configuration
>> +   (bootloader syslinux-bootloader)
>> +   fields ...))
>
> We can omit these two macros since they have never existed before this
> patch.  New users will write:
>
>   (bootloader-configuration
>     (bootloader syslinux-bootloader)
>     …)

Ok.

>
> Speaking of which, could you update guix.texi, maybe in a subsequent
> patch to avoid blocking this one?  I suppose “GRUB Configuration” would
> have to be renamed to “Bootloader Configuration”.
>
>> +;;;
>> +;;; Compatibility macros.
>> +;;;
>> +
>> +(define-syntax-rule (grub-configuration fields ...)
>> +  (bootloader-configuration
>> +   (bootloader grub-bootloader)
>> +   fields ...))
>> +
>> +(define-syntax-rule (grub-efi-configuration fields ...)
>> +  (bootloader-configuration
>> +   (bootloader grub-efi-bootloader)
>> +   fields ...))
>
> The second macro can be removed (it did not exist before).
>
> However the first one might need to be improved to be really compatible
> with what exists now.  For instance, my laptop’s config has this:
>
>   (grub-configuration
>     (grub grub-efi)
>     (device "/dev/sda"))
>
> So we probably need something like this (untested):
>
>   (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 ...))))
>
> This will only address the simple case where the ‘grub’ field comes
> first, but that should be OK (esp. since UEFI support was not documented
> until now…).

It seems to work ok, I took it :)

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-14 13:35     ` Ludovic Courtès
@ 2017-05-16 12:55       ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-16 12:55 UTC (permalink / raw)
  To: Ludovic Courtès, Danny Milosavljevic; +Cc: 26339


> Anyway, thanks for your patience and hard work on this series, thanks to
> David for starting it and to Danny for tirelessly reviewing it!

I pushed the whole serie. Thanks a lot to both of you for reviewing it !

I'll submit the doc patch soon.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] doc: Adapt to multiple bootloader support.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
                   ` (3 preceding siblings ...)
  2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
@ 2017-05-16 13:03 ` Mathieu Othacehe
  2017-05-20 20:49   ` Danny Milosavljevic
  2017-05-20 21:12   ` Tomáš Čech
  2017-05-18 10:13 ` bug#26339: [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt Mathieu Othacehe
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-16 13:03 UTC (permalink / raw)
  To: 26339

* doc/guix.texi (GRUB configuration): Rename to "Bootloader
  configuration".
  [menu-entry]: Switch to "boot-parameters" and adapt fields.
  Adapt occurences of "GRUB" in other sections.
---

Hi,

Here's the doc patch. While writting it, I noticed that using
<boot-parameters> for <bootloader-configuration>'s menu-entry fields
was maybe not a good idea.

<boot-parameters> has no default values and it might be hard to understand
by final users. WDYT ?

Thanks,

Mathieu

 doc/guix.texi | 208 +++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 118 insertions(+), 90 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7baf6ee38..455dbbc84 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -198,7 +198,7 @@ System Configuration
 * X.509 Certificates::          Authenticating HTTPS servers.
 * Name Service Switch::         Configuring libc's name service switch.
 * Initial RAM Disk::            Linux-Libre bootstrapping.
-* GRUB Configuration::          Configuring the boot loader.
+* Bootloader Configuration::    Configuring the boot loader.
 * Invoking guix system::        Instantiating a system configuration.
 * Running GuixSD in a VM::      How to run GuixSD in a virtual machine.
 * Defining Services::           Adding new service definitions.
@@ -7731,7 +7731,7 @@ instance to support new system services.
 * X.509 Certificates::          Authenticating HTTPS servers.
 * Name Service Switch::         Configuring libc's name service switch.
 * Initial RAM Disk::            Linux-Libre bootstrapping.
-* GRUB Configuration::          Configuring the boot loader.
+* Bootloader Configuration::    Configuring the boot loader.
 * Invoking guix system::        Instantiating a system configuration.
 * Running GuixSD in a VM::      How to run GuixSD in a virtual machine.
 * Defining Services::           Adding new service definitions.
@@ -7914,7 +7914,7 @@ system, should you ever need to.
 Speaking of roll-back, each time you run @command{guix system
 reconfigure}, a new @dfn{generation} of the system is created---without
 modifying or deleting previous generations.  Old system generations get
-an entry in the GRUB boot menu, allowing you to boot them in case
+an entry in the bootloader boot menu, allowing you to boot them in case
 something went wrong with the latest generation.  Reassuring, no?  The
 @command{guix system list-generations} command lists the system
 generations available on disk.  It is also possible to roll back the
@@ -7970,7 +7970,7 @@ List of strings or gexps representing additional arguments to pass on
 the command-line of the kernel---e.g., @code{("console=ttyS0")}.
 
 @item @code{bootloader}
-The system bootloader configuration object.  @xref{GRUB Configuration}.
+The system bootloader configuration object.  @xref{Bootloader Configuration}.
 
 @item @code{initrd} (default: @code{base-initrd})
 @cindex initrd
@@ -15229,32 +15229,41 @@ upon booting.  All the derivations referenced by @var{exp} are
 automatically copied to the initrd.
 @end deffn
 
-@node GRUB Configuration
-@subsection GRUB Configuration
+@node Bootloader Configuration
+@subsection Bootloader Configuration
 
-@cindex GRUB
+@cindex Bootloader
 @cindex boot loader
 
-The operating system uses GNU@tie{}GRUB as its boot loader
-(@pxref{Overview, overview of GRUB,, grub, GNU GRUB Manual}).  It is
-configured using a @code{grub-configuration} declaration.  This data type
-is exported by the @code{(gnu system grub)} module and described below.
+The operating system supports multiple bootloaders. The bootloader is
+configured using @code{bootloader-configuration} declaration. All the
+fields of this structure are bootloader agnostic except for one field,
+@code{bootloader} that indicates the bootloader to be configured and
+installed.
 
-@deftp {Data Type} grub-configuration
-The type of a GRUB configuration declaration.
+Note that all fields of @code{bootloader-configuration} are not
+necessarily handled by all GuixSD supported bootloaders.
+
+@deftp {Data Type} bootloader-configuration
+The type of a bootloader configuration declaration.
 
 @table @asis
 
+@item @code{bootloader}
+The bootloader to use, as a @code{bootloader} object. For now
+@code{grub}, @code{grub-efi} and @code{syslinux} are supported.
+
 @item @code{device}
 This is a string denoting the boot device.  It must be a device name
-understood by the @command{grub-install} command, such as
-@code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
+understood by the bootloader @command{installer} command, such as
+@code{/dev/sda} or @code{(hd0)} (for GRUB, @pxref{Invoking grub-install,,, grub,
 GNU GRUB Manual}).
 
 @item @code{menu-entries} (default: @code{()})
-A possibly empty list of @code{menu-entry} objects (see below), denoting
-entries to appear in the GRUB boot menu, in addition to the current
-system entry and the entry pointing to previous system generations.
+A possibly empty list of @code{boot-parameters} objects (see below),
+denoting entries to appear in the bootloader menu, in addition to the
+current system entry and the entry pointing to previous system
+generations.
 
 @item @code{default-entry} (default: @code{0})
 The index of the default boot menu entry.  Index 0 is for the entry of the
@@ -15264,37 +15273,37 @@ current system.
 The number of seconds to wait for keyboard input before booting.  Set to
 0 to boot immediately, and to -1 to wait indefinitely.
 
-@item @code{theme} (default: @var{%default-theme})
-The @code{grub-theme} object describing the theme to use.
-
-@item @code{grub} (default: @code{grub})
-The GRUB package to use.
+@item @code{theme} (default: @var{#f})
+The bootloader theme object describing the theme to use. If no theme
+is provided, some bootloaders might use a default theme, that's true
+for GRUB.
 
 @item @code{terminal-outputs} (default: @code{'gfxterm})
-The output terminals used for the GRUB boot menu, as a list of symbols.
-These values are accepted: @code{console}, @code{serial},
-@code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text}, @code{mda_text},
-@code{morse}, and @code{pkmodem}.  This field corresponds to the GRUB
-variable GRUB_TERMINAL_OUTPUT (@pxref{Simple configuration,,, grub,GNU
-GRUB manual}).
+The output terminals used for the bootloader boot menu, as a list of
+symbols.  GRUB accepts the values: @code{console}, @code{serial},
+@code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
+@code{mda_text}, @code{morse}, and @code{pkmodem}.  This field
+corresponds to the GRUB variable GRUB_TERMINAL_OUTPUT (@pxref{Simple
+configuration,,, grub,GNU GRUB manual}).
 
 @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.  These values are accepted: @code{console}, @code{serial},
-@code{serial_@{0-3@}}, @code{at_keyboard}, and @code{usb_keyboard}.
-This field corresponds to the GRUB variable GRUB_TERMINAL_INPUT
-(@pxref{Simple configuration,,, grub,GNU GRUB manual}).
+The input terminals used for the bootloader boot menu, as a list of
+symbols.  For GRUB, the default is the native platform terminal as
+determined at run-time.  GRUB accepts the values: @code{console},
+@code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
+@code{usb_keyboard}.  This field corresponds to the GRUB variable
+GRUB_TERMINAL_INPUT (@pxref{Simple configuration,,, grub,GNU GRUB
+manual}).
 
 @item @code{serial-unit} (default: @code{#f})
-The serial unit used by GRUB, as an integer from 0 to 3.  The default
-value is chosen by GRUB at run-time; currently GRUB chooses 0, which
+The serial unit used by the bootloader, as an integer from 0 to 3.
+For GRUB it is choosen at run-time; currently GRUB chooses 0, which
 corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
 
 @item @code{serial-speed} (default: @code{#f})
-The speed of the serial interface, as an integer.  The default value is
-chosen by GRUB at run-time; currently GRUB chooses 9600@tie{}bps
-(@pxref{Serial terminal,,, grub,GNU GRUB manual}).
+The speed of the serial interface, as an integer.  For GRUB, the
+default value is chosen at run-time; currently GRUB chooses
+9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
 @end table
 
 @end deftp
@@ -15303,38 +15312,68 @@ chosen by GRUB at run-time; currently GRUB chooses 9600@tie{}bps
 @cindex boot menu
 Should you want to list additional boot menu entries @i{via} the
 @code{menu-entries} field above, you will need to create them with the
-@code{menu-entry} form.  For example, imagine you want to be able to
+@code{boot-parameters} form.  For example, imagine you want to be able to
 boot another distro (hard to imagine!), you can define a menu entry
 along these lines:
 
 @example
-(menu-entry
+(boot-parameters
   (label "The Other Distro")
-  (linux "/boot/old/vmlinux-2.6.32")
-  (linux-arguments '("root=/dev/sda2"))
+  (root-device "my-root")
+  (boot-name 'grub)
+  (store-device "my-root")
+  (store-mount-point "/")
+  (kernel "/boot/old/vmlinux-2.6.32")
+  (kernel-arguments '("root=/dev/sda2"))
   (initrd "/boot/old/initrd"))
 @end example
 
 Details below.
 
-@deftp {Data Type} menu-entry
-The type of an entry in the GRUB boot menu.
+@deftp {Data Type} boot-parameters
+The type of an entry in the bootloader boot menu.
 
 @table @asis
 
 @item @code{label}
 The label to show in the menu---e.g., @code{"GNU"}.
 
-@item @code{linux}
-The Linux kernel image to boot, for example:
+@item @code{root-device}
+The root device identifier. It has to correspond exactly to the device
+field of the <file-system> object representing the OS's root file
+system, so it might be a device path like @code{"/dev/sda3"}.
+
+@item @code{boot-device}
+The name of the bootloader used to boot this entry (@code{'grub} or
+@code{'syslinux} for instance).
+
+@item @code{store-device}
+The device where the kernel and initrd are to be found---i.e., for GRUB
+@dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
+
+Depending on the bootloader, this may be a file system label (a
+string), a file system UUID (a bytevector, @pxref{File Systems}), or
+@code{#f}. If set to @code{#f}, GRUB will search the device containing
+the file specified by the @code{linux} field (@pxref{search,,, grub,
+GNU GRUB manual}).  It must @emph{not} be an OS device name such as
+@file{/dev/sda1}.
+
+@item @code{store-mount-point}
+The mount point of the above device on the system.  You probably want
+to set it to @code{"/"}.  GuixSD uses it to strip the prefix of store
+file names for systems where @file{/gnu} or @file{/gnu/store} is on a
+separate partition.
+
+@item @code{kernel}
+The kernel image to boot, for example:
 
 @example
 (file-append linux-libre "/bzImage")
 @end example
 
-It is also possible to specify a device explicitly in the file path
-using GRUB's device naming convention (@pxref{Naming convention,,, grub,
-GNU GRUB manual}), for example:
+For GRUB, It is also possible to specify a device explicitly in the
+file path using GRUB's device naming convention (@pxref{Naming
+convention,,, grub, GNU GRUB manual}), for example:
 
 @example
 "(hd0,msdos1)/boot/vmlinuz"
@@ -15343,40 +15382,27 @@ GNU GRUB manual}), for example:
 If the device is specified explicitly as above, then the @code{device}
 field is ignored entirely.
 
-@item @code{linux-arguments} (default: @code{()})
-The list of extra Linux kernel command-line arguments---e.g.,
+@item @code{kernel-arguments}
+The list of extra kernel command-line arguments---e.g.,
 @code{("console=ttyS0")}.
 
 @item @code{initrd}
 A G-Expression or string denoting the file name of the initial RAM disk
 to use (@pxref{G-Expressions}).
-
-@item @code{device} (default: @code{#f})
-The device where the kernel and initrd are to be found---i.e., the GRUB
-@dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
-
-This may be a file system label (a string), a file system UUID (a
-bytevector, @pxref{File Systems}), or @code{#f}, in which case GRUB will
-search the device containing the file specified by the @code{linux}
-field (@pxref{search,,, grub, GNU GRUB manual}).  It must @emph{not} be
-an OS device name such as @file{/dev/sda1}.
-
-@item @code{device-mount-point} (default: @code{"/"})
-The mount point of the above device on the system.  You probably do not
-need to change the default value.  GuixSD uses it to strip the prefix of
-store file names for systems where @file{/gnu} or @file{/gnu/store} is
-on a separate partition.
-
 @end table
 @end deftp
 
 @c FIXME: Write documentation once it's stable.
-Themes are created using the @code{grub-theme} form, which is not
-documented yet.
+Fow now only GRUB has theme support. GRUB Themes are created using
+the @code{grub-theme} form, which is not documented yet.
 
 @defvr {Scheme Variable} %default-theme
-This is the default GRUB theme used by the operating system, with a
-fancy background image displaying the GNU and Guix logos.
+This is the default GRUB theme used by the operating system if no
+@code{theme} field is specified in @code{bootloader-configuration}
+record.
+
+It comes with a fancy background image displaying the GNU and Guix
+logos.
 @end defvr
 
 
@@ -15416,9 +15442,9 @@ list-generations}).  If that generation already exists, it will be
 overwritten.  This behavior mirrors that of @command{guix package}
 (@pxref{Invoking guix package}).
 
-It also adds a GRUB menu entry for the new OS configuration, and moves
-entries for older configurations to a submenu---unless
-@option{--no-bootloader} is passed.
+It also adds a bootloader menu entry for the new OS configuration,
+---unless @option{--no-bootloader} is passed.  For GRUB, it moves
+entries for older configurations to a submenu.
 
 @quotation Note
 @c The paragraph below refers to the problem discussed at
@@ -15432,11 +15458,12 @@ once @command{reconfigure} has completed.
 @item switch-generation
 @cindex generations
 Switch to an existing system generation.  This action atomically
-switches the system profile to the specified system generation.  It also
-rearranges the system's existing GRUB menu entries.  It makes the menu
-entry for the specified system generation the default, and it moves the
-entries for the other generations to a submenu.  The next time the
-system boots, it will use the specified system generation.
+switches the system profile to the specified system generation.  It
+also rearranges the system's existing bootloader menu entries.  It
+makes the menu entry for the specified system generation the default,
+and it moves the entries for the other generations to a submenu.  The
+next time the system boots, it will use the specified system
+generation.
 
 The target generation can be specified explicitly by its generation
 number.  For example, the following invocation would switch to system
@@ -15458,11 +15485,11 @@ guix system switch-generation -- -1
 @end example
 
 Currently, the effect of invoking this action is @emph{only} to switch
-the system profile to an existing generation and rearrange the GRUB menu
-entries.  To actually start using the target system generation, you must
-reboot after running this action.  In the future, it will be updated to
-do the same things as @command{reconfigure}, like activating and
-deactivating services.
+the system profile to an existing generation and rearrange the
+bootloader menu entries.  To actually start using the target system
+generation, you must reboot after running this action.  In the future,
+it will be updated to do the same things as @command{reconfigure},
+like activating and deactivating services.
 
 This action will fail if the specified generation does not exist.
 
@@ -15497,8 +15524,9 @@ files, packages, and so on.  It also creates other essential files
 needed for the system to operate correctly---e.g., the @file{/etc},
 @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
 
-This command also installs GRUB on the device specified in
-@file{my-os-config}, unless the @option{--no-bootloader} option was passed.
+This command also installs bootloader on the device specified in
+@file{my-os-config}, unless the @option{--no-bootloader} option was
+passed.
 
 @item vm
 @cindex virtual machine
@@ -15638,7 +15666,7 @@ build users of the daemon (@pxref{Build Environment Setup}).
 Once you have built, configured, re-configured, and re-re-configured
 your GuixSD installation, you may find it useful to list the operating
 system generations available on disk---and that you can choose from the
-GRUB boot menu:
+bootloader boot menu:
 
 @table @code
 
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-16 12:51       ` Mathieu Othacehe
@ 2017-05-16 14:38         ` Danny Milosavljevic
  2017-05-16 14:50           ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-16 14:38 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

U-Boot uses extlinux config.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-16 14:38         ` Danny Milosavljevic
@ 2017-05-16 14:50           ` Mathieu Othacehe
  2017-05-16 15:00             ` Danny Milosavljevic
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-16 14:50 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> U-Boot uses extlinux config.

What do you mean by extlinux config ? An extlinux configuration file,
without extlinux installed in MBR ?

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-16 14:50           ` Mathieu Othacehe
@ 2017-05-16 15:00             ` Danny Milosavljevic
  2017-05-16 15:03               ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-16 15:00 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

On Tue, 16 May 2017 16:50:41 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

> > U-Boot uses extlinux config.  
> 
> What do you mean by extlinux config ? An extlinux configuration file,
> without extlinux installed in MBR ?

Yes.  If an extlinux config file is there, u-boot prefers it even to u-boot's native config file (the latter is more like a list of commands than a configuration).

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support.
  2017-05-16 15:00             ` Danny Milosavljevic
@ 2017-05-16 15:03               ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-16 15:03 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


> Yes.  If an extlinux config file is there, u-boot prefers it even to u-boot's native config file (the latter is more like a list of commands than a configuration).

Ok then, would the following bootloader be ok ?

--8<---------------cut here---------------start------------->8---
(define extlinux-bootloader-no-installer
  (bootloader
   (inherit extlinux-bootloader)
   (installer #f)))
--8<---------------cut here---------------end--------------->8---

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
                   ` (4 preceding siblings ...)
  2017-05-16 13:03 ` bug#26339: [PATCH] doc: Adapt to multiple bootloader support Mathieu Othacehe
@ 2017-05-18 10:13 ` Mathieu Othacehe
  2017-06-12 20:23   ` [bug#26339] " Ludovic Courtès
  2017-06-13 14:34   ` Danny Milosavljevic
  2017-05-18 10:26 ` bug#26339: [PATCH] tests: Add syslinux gpt test Mathieu Othacehe
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-18 10:13 UTC (permalink / raw)
  To: 26339

* gnu/bootloader/extlinux.scm (extlinux-bootloader-gpt): New exported
  variable.
 (install-extlinux)[mbr]: New argument.
 (install-extlinux-mbr, install-extlinux-gpt): New variables.
 (extlinux-bootloader)[installer]: Use install-extlinux-mbr.
---

Hi,

Here's a patch to add gpt support to extlinux. I will be used
later on system tests based on gpt.

Thanks,

Mathieu

 gnu/bootloader/extlinux.scm | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm
index 12fa447c3..8f928ff22 100644
--- a/gnu/bootloader/extlinux.scm
+++ b/gnu/bootloader/extlinux.scm
@@ -26,7 +26,7 @@
   #:use-module (guix records)
   #:use-module (guix utils)
   #:export (extlinux-bootloader
-            syslinux-bootloader))
+            extlinux-bootloader-gpt))
 
 (define* (extlinux-configuration-file config entries
                                       #:key
@@ -92,7 +92,7 @@ TIMEOUT ~a~%"
                       (string-append "if=" if)
                       (string-append "of=" of)))))
 
-(define install-extlinux
+(define (install-extlinux mbr)
   #~(lambda (bootloader device mount-point)
       (let ((extlinux (string-append bootloader "/sbin/extlinux"))
             (install-dir (string-append mount-point "/boot/extlinux"))
@@ -102,9 +102,15 @@ TIMEOUT ~a~%"
                   (find-files syslinux-dir "\\.c32$"))
 
         (unless (and (zero? (system* extlinux "--install" install-dir))
-                     (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
+                     (#$dd 440 1 (string-append syslinux-dir "/" #$mbr) device))
           (error "failed to install SYSLINUX")))))
 
+(define install-extlinux-mbr
+  (install-extlinux "mbr.bin"))
+
+(define install-extlinux-gpt
+  (install-extlinux "gptmbr.bin"))
+
 \f
 
 ;;;
@@ -115,6 +121,11 @@ TIMEOUT ~a~%"
   (bootloader
    (name 'extlinux)
    (package syslinux)
-   (installer install-extlinux)
+   (installer install-extlinux-mbr)
    (configuration-file "/boot/extlinux/extlinux.conf")
    (configuration-file-generator extlinux-configuration-file)))
+
+(define extlinux-bootloader-gpt
+  (bootloader
+   (inherit extlinux-bootloader)
+   (installer install-extlinux-gpt)))
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] tests: Add syslinux gpt test.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
                   ` (5 preceding siblings ...)
  2017-05-18 10:13 ` bug#26339: [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt Mathieu Othacehe
@ 2017-05-18 10:26 ` Mathieu Othacehe
  2017-06-12 20:29   ` [bug#26339] " Ludovic Courtès
  2017-05-21 13:57 ` bug#26339: [PATCH] scripts: system: Handle unspecified bootloader package and installer Mathieu Othacehe
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-18 10:26 UTC (permalink / raw)
  To: 26339

* gnu/tests/install.scm (%test-installed-syslinux-os): New exported
  variable.
  (%minimal-syslinux-os, %minimal-syslinux-os-source): New variables.
  (%syslinux-gpt-installation-script): New variable.
* gnu/system/install.scm (installation-os)[packages]: Add syslinux.
---

Hi,

Here's a test installing a GuixSD system with extlinux-bootloader-gpt
as a bootloader.

I had to rewrite %minimal-syslinux-os as a copy of %minimal-os, but the only
change is the bootloader field. A better idea to avoid rewritting is welcome :)

Thanks,

Mathieu

 gnu/system/install.scm |  1 +
 gnu/tests/install.scm  | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index 9a6febfeb..888998347 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -343,6 +343,7 @@ Use Alt-F2 for documentation.
     (packages (cons* (canonical-package glibc) ;for 'tzselect' & co.
                      parted gptfdisk ddrescue
                      grub                  ;mostly so xrefs to its manual work
+                     syslinux
                      cryptsetup
                      mdadm
                      dosfstools         ;mkfs.fat, for the UEFI boot partition
diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index b104efcfd..9dcb41ba1 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -18,6 +18,7 @@
 
 (define-module (gnu tests install)
   #:use-module (gnu)
+  #:use-module (gnu bootloader extlinux)
   #:use-module (gnu tests)
   #:use-module (gnu tests base)
   #:use-module (gnu system)
@@ -34,6 +35,7 @@
   #:use-module (guix gexp)
   #:use-module (guix utils)
   #:export (%test-installed-os
+            %test-installed-syslinux-os
             %test-separate-store-os
             %test-separate-home-os
             %test-raid-root-os
@@ -77,6 +79,39 @@
                                                   (guix combinators)))))
                     %base-services))))
 
+(define-os-with-source (%minimal-syslinux-os
+                        %minimal-syslinux-os-source)
+  (use-modules (gnu) (gnu tests) (gnu bootloader extlinux)
+               (srfi srfi-1))
+
+  (operating-system
+    (host-name "liberigilo")
+    (timezone "Europe/Paris")
+    (locale "en_US.UTF-8")
+
+    (bootloader (bootloader-configuration
+                 (bootloader extlinux-bootloader-gpt)
+                 (device "/dev/vdb")))
+    (kernel-arguments '("console=ttyS0"))
+    (file-systems (cons (file-system
+                          (device "my-root")
+                          (title 'label)
+                          (mount-point "/")
+                          (type "ext4"))
+                        %base-file-systems))
+    (users (cons (user-account
+                  (name "alice")
+                  (comment "Bob's sister")
+                  (group "users")
+                  (supplementary-groups '("wheel" "audio" "video"))
+                  (home-directory "/home/alice"))
+                 %base-user-accounts))
+    (services (cons (service marionette-service-type
+                             (marionette-configuration
+                              (imported-modules '((gnu services herd)
+                                                  (guix combinators)))))
+                    %base-services))))
+
 (define (operating-system-with-current-guix os)
   "Return a variant of OS that uses the current Guix."
   (operating-system
@@ -121,6 +156,30 @@ guix system init /mnt/etc/config.scm /mnt --no-substitutes
 sync
 reboot\n")
 
+(define %syslinux-gpt-installation-script
+  ;; Shell script of a simple installation.
+  ;; As syslinux 6.0.3 does not handle 64bits ext4 partitions,
+  ;; we make sure to pass -O '^64bit' to mkfs.
+  "\
+. /etc/profile
+set -e -x
+guix --version
+
+export GUIX_BUILD_OPTIONS=--no-grafts
+guix build isc-dhcp
+parted --script /dev/vdb mklabel gpt \\
+  mkpart ext2 1M 1G \\
+  set 1 legacy_boot on
+mkfs.ext4 -L my-root -O '^64bit' /dev/vdb1
+mount /dev/vdb1 /mnt
+df -h /mnt
+herd start cow-store /mnt
+mkdir /mnt/etc
+cp /etc/target-config.scm /mnt/etc/config.scm
+guix system init /mnt/etc/config.scm /mnt --no-substitutes
+sync
+reboot\n")
+
 (define* (run-install target-os target-os-source
                       #:key
                       (script %simple-installation-script)
@@ -232,6 +291,20 @@ build (current-guix) and then store a couple of full system images.")
       (run-basic-test %minimal-os command
                       "installed-os")))))
 
+(define %test-installed-syslinux-os
+  (system-test
+   (name "installed-syslinux-os")
+   (description
+    "...")
+   (value
+    (mlet* %store-monad ((image (run-install %minimal-syslinux-os
+                                             %minimal-syslinux-os-source
+                                             #:script
+                                             %syslinux-gpt-installation-script))
+                         (command (qemu-command/writable-image image)))
+      (run-basic-test %minimal-syslinux-os command
+                      "installed-syslinux-os")))))
+
 \f
 ;;;
 ;;; Separate /home.
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] doc: Adapt to multiple bootloader support.
  2017-05-16 13:03 ` bug#26339: [PATCH] doc: Adapt to multiple bootloader support Mathieu Othacehe
@ 2017-05-20 20:49   ` Danny Milosavljevic
  2017-05-22  8:11     ` Mathieu Othacehe
  2017-05-20 21:12   ` Tomáš Čech
  1 sibling, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-05-20 20:49 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

On Tue, 16 May 2017 15:03:06 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:
> Here's the doc patch. While writting it, I noticed that using
> <boot-parameters> for <bootloader-configuration>'s menu-entry fields
> was maybe not a good idea.
> 
> <boot-parameters> has no default values and it might be hard to understand
> by final users. WDYT ?

From an understanding standpoint I don't think it's that bad.

What worries me more is that now AND BEFORE, you can't boot anything other than Linux, no bootsector chainloading or anything.

I'm not sure what the use case that "menu-entries" is trying to address is, then.  I mean both the current generation and previous generations are automatically there and you can't specify any menu-entries but Linux, so what are you gonna specify?  Also, <operating-system> already allows overriding kernel-arguments, too.

Luckily, Tomáš Čech just noticed that "menu-entries" changed, so presumably he uses it.  Will ask what use case he has...

> +(boot-parameters
>    (label "The Other Distro")
> -  (linux "/boot/old/vmlinux-2.6.32")
> -  (linux-arguments '("root=/dev/sda2"))
> +  (root-device "my-root")
> +  (boot-name 'grub)
> +  (store-device "my-root")
> +  (store-mount-point "/")
> +  (kernel "/boot/old/vmlinux-2.6.32")
> +  (kernel-arguments '("root=/dev/sda2"))
>    (initrd "/boot/old/initrd"))
>  @end example

This here isn't so bad.

> +@item @code{root-device}
> +The root device identifier. It has to correspond exactly to the device
> +field of the <file-system> object representing the OS's root file
> +system, so it might be a device path like @code{"/dev/sda3"}.
> +
> +@item @code{boot-device}

Did you mean "boot-name" ?

> +The name of the bootloader used to boot this entry (@code{'grub} or
> +@code{'syslinux} for instance).

This one is a strange implementation detail to expose for menu entries, though.  Maybe have operating-system-bootcfg magically complete it if it's unset?

Then add here "If in doubt, don't specify it.".

> +@item @code{store-device}
> +The device where the kernel and initrd are to be found---i.e., for GRUB
> +@dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
> +
> +Depending on the bootloader, this may be a file system label (a
> +string), a file system UUID (a bytevector, @pxref{File Systems}), or
> +@code{#f}. If set to @code{#f}, GRUB will search the device containing
> +the file specified by the @code{linux} field (@pxref{search,,, grub,
> +GNU GRUB manual}).  It must @emph{not} be an OS device name such as
> +@file{/dev/sda1}.

Maybe default to #f in <boot-parameters> in gnu/system.scm ?

Then add here "If in doubt, don't specify it.".

> +@item @code{store-mount-point}
> +The mount point of the above device on the system.  You probably want
> +to set it to @code{"/"}.  GuixSD uses it to strip the prefix of store
> +file names for systems where @file{/gnu} or @file{/gnu/store} is on a
> +separate partition.

Maybe default to "/" in <boot-parameters? in gnu/system.scm ?

Then add here "If in doubt, don't specify it.".

That would make the amount of new fields the user has to specify to one, just "root-device".

That said, I'm wondering whether we should keep menu-entries at all (or if we do, maybe make it bootloader-specific like it was? At least then you can add entries that Guix doesn't use already).  Let's see what Tomáš says it's for :)

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] doc: Adapt to multiple bootloader support.
  2017-05-16 13:03 ` bug#26339: [PATCH] doc: Adapt to multiple bootloader support Mathieu Othacehe
  2017-05-20 20:49   ` Danny Milosavljevic
@ 2017-05-20 21:12   ` Tomáš Čech
  2017-05-20 21:19     ` Mathieu Othacehe
  1 sibling, 1 reply; 204+ messages in thread
From: Tomáš Čech @ 2017-05-20 21:12 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

On Tue, May 16, 2017 at 03:03:06PM +0200, Mathieu Othacehe wrote:
> ...
> @example
>-(menu-entry
>+(boot-parameters
>   (label "The Other Distro")
>-  (linux "/boot/old/vmlinux-2.6.32")
>-  (linux-arguments '("root=/dev/sda2"))
>+  (root-device "my-root")
>+  (boot-name 'grub)

Is anywhere documented what does this line means?

>+  (store-device "my-root")
>+  (store-mount-point "/")
>+  (kernel "/boot/old/vmlinux-2.6.32")
>+  (kernel-arguments '("root=/dev/sda2"))
>   (initrd "/boot/old/initrd"))
> @end example

TIA,

S_W

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] doc: Adapt to multiple bootloader support.
  2017-05-20 21:12   ` Tomáš Čech
@ 2017-05-20 21:19     ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-20 21:19 UTC (permalink / raw)
  To: Tomáš Čech; +Cc: 26339


>>+  (boot-name 'grub)
>
> Is anywhere documented what does this line means?

Mmh, I forget it in the doc patch sorry. This field is used to restore
the correct bootloader when doing a "guix system switch-generation".

In your case you can use any value. We definitely need to change this.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] scripts: system: Handle unspecified bootloader package and installer.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
                   ` (6 preceding siblings ...)
  2017-05-18 10:26 ` bug#26339: [PATCH] tests: Add syslinux gpt test Mathieu Othacehe
@ 2017-05-21 13:57 ` Mathieu Othacehe
  2017-06-12 20:32   ` [bug#26339] " Ludovic Courtès
  2017-06-10  8:53 ` bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name Mathieu Othacehe
  2017-10-13 14:08 ` bug#26339: closing bootloader serie Mathieu Othacehe
  9 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-21 13:57 UTC (permalink / raw)
  To: 26339

* guix/scripts/system.system (perform-action): If bootloader installer or
  bootloader package are #f, do not add them to drvs but keep things going.

This allows to write (installer #f) or (package #f) in <bootloader>
definition.

Reported-by: Clément Lassieur <clement@lassieur.org>.

---
 guix/scripts/system.scm | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 5e4574f7c..0e29d3c05 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -653,19 +653,20 @@ output when building a system derivation, such as a disk image."
        (bootloader-installer
         (let ((installer (bootloader-installer bootloader))
               (target    (or target "/")))
-          (bootloader-installer-derivation installer
-                                           bootloader-package
-                                           device target)))
+          (if installer
+              (bootloader-installer-derivation installer
+                                               bootloader-package
+                                               device target)
+              (return #f))))
 
        ;; For 'init' and 'reconfigure', always build BOOTCFG, even if
        ;; --no-bootloader is passed, because we then use it as a GC root.
        ;; See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if (and install-bootloader? bootloader-package)
-                          (list sys bootcfg
-				bootloader-package
-				bootloader-installer)
-                          (list sys bootcfg))
+                      (delete #f
+                              (list sys bootcfg
+                                    bootloader-package
+                                    bootloader-installer))
                       (list sys)))
        (%         (if derivations-only?
                       (return (for-each (compose println derivation-file-name)
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] doc: Adapt to multiple bootloader support.
  2017-05-20 20:49   ` Danny Milosavljevic
@ 2017-05-22  8:11     ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-05-22  8:11 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi Danny,

> From an understanding standpoint I don't think it's that bad.

My concern is about the new fields, that might be hard to understand.

>
> What worries me more is that now AND BEFORE, you can't boot anything other than Linux, no bootsector chainloading or anything.
>
> I'm not sure what the use case that "menu-entries" is trying to address is, then.  I mean both the current generation and previous generations are automatically there and you can't specify any menu-entries but Linux, so what are you gonna specify?  Also, <operating-system> already allows overriding kernel-arguments, too.
>
> Luckily, Tomáš Čech just noticed that "menu-entries" changed, so presumably he uses it.  Will ask what use case he has...

Based on Tomáš answer, I guess menu-entries are used to boot on other
Linux distributions. "reconfigure" is not able to "see" those distributions by
himself, so the only way to add them to bootloader configuration is via
menu-entries.

>
>> +(boot-parameters
>>    (label "The Other Distro")
>> -  (linux "/boot/old/vmlinux-2.6.32")
>> -  (linux-arguments '("root=/dev/sda2"))
>> +  (root-device "my-root")
>> +  (boot-name 'grub)
>> +  (store-device "my-root")
>> +  (store-mount-point "/")
>> +  (kernel "/boot/old/vmlinux-2.6.32")
>> +  (kernel-arguments '("root=/dev/sda2"))
>>    (initrd "/boot/old/initrd"))
>>  @end example
>
> This here isn't so bad.
>
>> +@item @code{root-device}
>> +The root device identifier. It has to correspond exactly to the device
>> +field of the <file-system> object representing the OS's root file
>> +system, so it might be a device path like @code{"/dev/sda3"}.
>> +
>> +@item @code{boot-device}
>
> Did you mean "boot-name" ?

Yes it's a mistake :)

>
>> +The name of the bootloader used to boot this entry (@code{'grub} or
>> +@code{'syslinux} for instance).
>
> This one is a strange implementation detail to expose for menu entries, though.  Maybe have operating-system-bootcfg magically complete it if it's unset?

Yes I totally agree. Maybe set it to 'unknown by default ?

>
> Then add here "If in doubt, don't specify it.".

Ok.

>
>> +@item @code{store-device}
>> +The device where the kernel and initrd are to be found---i.e., for GRUB
>> +@dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
>> +
>> +Depending on the bootloader, this may be a file system label (a
>> +string), a file system UUID (a bytevector, @pxref{File Systems}), or
>> +@code{#f}. If set to @code{#f}, GRUB will search the device containing
>> +the file specified by the @code{linux} field (@pxref{search,,, grub,
>> +GNU GRUB manual}).  It must @emph{not} be an OS device name such as
>> +@file{/dev/sda1}.
>
> Maybe default to #f in <boot-parameters> in gnu/system.scm ?
>
> Then add here "If in doubt, don't specify it.".
>

Ok.

>> +@item @code{store-mount-point}
>> +The mount point of the above device on the system.  You probably want
>> +to set it to @code{"/"}.  GuixSD uses it to strip the prefix of store
>> +file names for systems where @file{/gnu} or @file{/gnu/store} is on a
>> +separate partition.
>
> Maybe default to "/" in <boot-parameters? in gnu/system.scm ?
>
> Then add here "If in doubt, don't specify it.".

Ok.

>
> That would make the amount of new fields the user has to specify to one, just "root-device".
>

Yes seems better.

> That said, I'm wondering whether we should keep menu-entries at all (or if we do, maybe make it bootloader-specific like it was? At least then you can add entries that Guix doesn't use already).  Let's see what Tomáš says it's for :)

I'll propose a new patch.

Thanks !

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
                   ` (7 preceding siblings ...)
  2017-05-21 13:57 ` bug#26339: [PATCH] scripts: system: Handle unspecified bootloader package and installer Mathieu Othacehe
@ 2017-06-10  8:53 ` Mathieu Othacehe
  2017-06-10 14:26   ` Ludovic Courtès
  2017-10-13 14:08 ` bug#26339: closing bootloader serie Mathieu Othacehe
  9 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-06-10  8:53 UTC (permalink / raw)
  To: 26339

* gnu/system.scm: Rename boot-name -> bootloader-name.
* guix/scripts/system.scm: Rename boot-name -> bootloader-name.
---

Hi,

Here's a small patch to rename boot-name to bootloader-name.
If a previous "parameters" files contains "boot-name" instead
of now expected bootloader-name, 'grub bootloader will be set
as default.

Thanks,

Mathieu

 gnu/system.scm          | 16 ++++++++--------
 guix/scripts/system.scm |  6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 96ef06a48..228bf410c 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -104,7 +104,7 @@
             boot-parameters?
             boot-parameters-label
             boot-parameters-root-device
-            boot-parameters-boot-name
+            boot-parameters-bootloader-name
             boot-parameters-store-device
             boot-parameters-store-mount-point
             boot-parameters-kernel
@@ -216,7 +216,7 @@ directly by the user."
   ;; exactly to the device field of the <file-system> object representing the
   ;; OS's root file system, so it might be a device path like "/dev/sda3".
   (root-device      boot-parameters-root-device)
-  (boot-name        boot-parameters-boot-name)
+  (bootloader-name  boot-parameters-bootloader-name)
   (store-device     boot-parameters-store-device)
   (store-mount-point boot-parameters-store-mount-point)
   (kernel           boot-parameters-kernel)
@@ -235,8 +235,8 @@ directly by the user."
       (label label)
       (root-device root)
 
-      (boot-name
-       (match (assq 'boot-name rest)
+      (bootloader-name
+       (match (assq 'bootloader-name rest)
          ((_ args) args)
          (#f       'grub))) ; for compatibility reasons.
 
@@ -306,7 +306,7 @@ The object has its kernel-arguments extended in order to make it bootable."
   (boot-parameters
    (label (menu-entry-label menu-entry))
    (root-device #f)
-   (boot-name 'custom)
+   (bootloader-name 'custom)
    (store-device (menu-entry-device menu-entry))
    (store-mount-point (menu-entry-device-mount-point menu-entry))
    (kernel (menu-entry-linux menu-entry))
@@ -892,7 +892,7 @@ kernel arguments for that derivation to <boot-parameters>."
        (store -> (operating-system-store-file-system os))
        (bootloader  -> (bootloader-configuration-bootloader
                         (operating-system-bootloader os)))
-       (boot-name   -> (bootloader-name bootloader))
+       (bootloader-name -> (bootloader-name bootloader))
        (label -> (kernel->boot-label (operating-system-kernel os))))
     (return (boot-parameters
              (label label)
@@ -903,7 +903,7 @@ kernel arguments for that derivation to <boot-parameters>."
                 (operating-system-kernel-arguments os system.drv root-device)
                 (operating-system-user-kernel-arguments os)))
              (initrd initrd)
-             (boot-name boot-name)
+             (bootloader-name bootloader-name)
              (store-device (fs->boot-device store))
              (store-mount-point (file-system-mount-point store))))))
 
@@ -929,7 +929,7 @@ being stored into the \"parameters\" file)."
                     (kernel-arguments
                      #$(boot-parameters-kernel-arguments params))
                     (initrd #$(boot-parameters-initrd params))
-                    (boot-name #$(boot-parameters-boot-name params))
+                    (bootloader-name #$(boot-parameters-bootloader-name params))
                     (store
                      (device #$(boot-parameters-store-device params))
                      (mount-point #$(boot-parameters-store-mount-point params))))
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index f71b1d71b..35675cc01 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -425,7 +425,7 @@ generation as its default entry.  STORE is an open connection to the store."
   "Return the bootloader name stored in SYSTEM's \"parameters\" file."
   (let ((params (unless-file-not-found
                  (read-boot-parameters-file system))))
-    (boot-parameters-boot-name params)))
+    (boot-parameters-bootloader-name params)))
 
 (define (reinstall-bootloader store number)
   "Re-install bootloader for existing system profile generation NUMBER.
@@ -521,7 +521,7 @@ list of services."
     (let* ((generation  (generation-file-name profile number))
            (params      (read-boot-parameters-file generation))
            (label       (boot-parameters-label params))
-           (boot-name   (boot-parameters-boot-name params))
+           (bootloader-name (boot-parameters-bootloader-name params))
            (root        (boot-parameters-root-device params))
            (root-device (if (bytevector? root)
                             (uuid->string root)
@@ -532,7 +532,7 @@ list of services."
       (format #t (G_ "  canonical file name: ~a~%") (readlink* generation))
       ;; TRANSLATORS: Please preserve the two-space indentation.
       (format #t (G_ "  label: ~a~%") label)
-      (format #t (G_ "  bootloader: ~a~%") boot-name)
+      (format #t (G_ "  bootloader: ~a~%") bootloader-name)
       (format #t (G_ "  root device: ~a~%") root-device)
       (format #t (G_ "  kernel: ~a~%") kernel))))
 
-- 
2.13.1

^ permalink raw reply related	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name.
  2017-06-10  8:53 ` bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name Mathieu Othacehe
@ 2017-06-10 14:26   ` Ludovic Courtès
  2017-06-10 16:33     ` Mathieu Othacehe
  2017-06-11  8:42     ` Mathieu Othacehe
  0 siblings, 2 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-10 14:26 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/system.scm: Rename boot-name -> bootloader-name.
> * guix/scripts/system.scm: Rename boot-name -> bootloader-name.

LGTM!

It might be good to describe it like this:

  * gnu/system (<boot-parameters>)[boot-name]: Rename field to...
  [bootloader-name]: ... this.  Adjust users.
  * gnu/scripts/system.scm: Adjust accordingly.

That makes it clear that we renamed a field and that the rest is purely
mechanical.

Thank you,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name.
  2017-06-10 14:26   ` Ludovic Courtès
@ 2017-06-10 16:33     ` Mathieu Othacehe
  2017-06-11  8:42     ` Mathieu Othacehe
  1 sibling, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-06-10 16:33 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


Hi Ludo,

> That makes it clear that we renamed a field and that the rest is purely
> mechanical.

Ok, pushed as f96752e with an updated commit message.

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name.
  2017-06-10 14:26   ` Ludovic Courtès
  2017-06-10 16:33     ` Mathieu Othacehe
@ 2017-06-11  8:42     ` Mathieu Othacehe
  2017-06-11  9:54       ` bug#26339: "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer Danny Milosavljevic
  1 sibling, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-06-11  8:42 UTC (permalink / raw)
  To: Ludovic Courtès, Danny Milosavljevic; +Cc: 26339


Hi !

Just to review the situation on the bootloader serie, there are still 3
patches, that may have gone unnoticed in #26339, here are the links :

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26339#504 (add extlinux
gpt support).

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26339#507 (add extlinux
gpt test).

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26339#519 (allow user to
specifiy bootloader-configuration without package nor installer).

Then, I'll send new patches adding a theme to extlinux :)

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-06-11  8:42     ` Mathieu Othacehe
@ 2017-06-11  9:54       ` Danny Milosavljevic
  2017-06-11 10:13         ` Danny Milosavljevic
                           ` (2 more replies)
  0 siblings, 3 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-06-11  9:54 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi Mathieu,

On Sun, 11 Jun 2017 10:42:15 +0200
Mathieu Othacehe <m.othacehe@gmail.com> wrote:

>Ok then, would the following bootloader be ok ?
>(define extlinux-bootloader-no-installer
>  (bootloader
>   (inherit extlinux-bootloader)
>   (installer #f)))

Uhh I guess so.  Weird to have the hierarchy like that, though.

Much less strange would be to have a hierarchy like this:
- extlinux-bootloader ; really means extlinux-configuration-style bootloader
  - syslinux-bootloader
  - u-boot-bootloader

Using extlinux-bootloader directly as a user doesn't make a lot of sense - but if they do it, it shouldn't install any bootloader (only extlinux configuration).

If you used syslinux-bootloader, it would do the same as extlinux-bootloader and also install syslinux (mbr.bin, gptmbr.bin).

If you used u-boot-bootloader, it would do the same as extlinux-bootloader and, if you provided an u-boot package to use, also install u-boot (eventually.  The latter is not easy and usually a bad idea except for a select few boards [1]).

> Just to review the situation on the bootloader serie, there are still 3
> patches, that may have gone unnoticed in #26339, here are the links :

> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26339#504 (add extlinux
> gpt support).

Not sure why this goes into extlinux.  Extlinux is just a configuration standard.  It wouldn't have those installation files "mbr.bin", "gptmbr.bin".

According to http://www.syslinux.org/wiki/index.php?title=Mbr it seems these are part of the syslinux bootloader distribution.

It was weird like that before patch 504 but I don't think it makes sense to conflate extlinux with syslinux.

If you do it like that, that means when you use U-Boot (which also uses extlinux config file), extlinux-* will install useless files "mbr.bin" and "gptmbr.bin".  Where would it get those in the first place?  Does it install syslinux too, then?  Apparently.  So now the user machine has two bootloaders, syslinux *and* u-boot ?  I hope it doesn't clobber u-boot in that case.

Really, I think the inheritance should go like this:

- extlinux-bootloader ; really means extlinux-configuration-style bootloader
  - syslinux-bootloader
  - u-boot-bootloader
  - maybe ipxe-bootloader

And I think u-boot-bootloader, when it eventually exists, should not install the u-boot bootloader by default either (i.e. it shouldn't default to a specific u-boot package).

WDYT?

> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26339#507 (add extlinux
> gpt test).

Here, it correctly says syslinux-os.

LGTM!  I think complicating the tests by refactoring %minimal-os is not necessary - so it's OK as is.

> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26339#519 (allow user to
> specifiy bootloader-configuration without package nor installer).

LGTM!

[1] There are a lot of forks of u-boot.  Vendors usually build and install their strange [usually old] u-boot fork on the device.
    Often, mainline u-boot eventually works after some time (i.e. after it was merged upstream), but I wouldn't bet on it.
    So one should load the new bootloader temporarily (by loading it via a RAMload stage like FEL over USB or my using a throwaway SD card or by using a test clip).  Otherwise, if u-boot ever didn't work you couldn't recover without extra external hardware and a lot of pain.  There's no "BIOS setup" where you can revert to a previous version of u-boot or anything.  But if it's only "installed" in RAM, you can just reboot if it doesn't work - it will be gone.
    Also, for comparison, if one "just" broke the Linux kernel installation or the extlinux bootmenu file, u-boot has a console with keyboard, display and serial port support and can boot Linux from TFTP and from other files on SD cards and flash.  So that wouldn't be that bad.
    To get an overview:
    - https://community.nxp.com/thread/436638
    - https://devtalk.nvidia.com/default/topic/802953/jetson-tk1/how-to-compile-amp-install-mainline-u-boot-/
    - https://eewiki.net/display/linuxonarm/i.MX6x+SABRE+Lite+Mainline+U-Boot
    - https://github.com/xobs/u-boot-novena
    - https://archlinuxarm.org/forum/viewtopic.php?f=53&t=7290
    - https://forum.mqmaker.com/t/mainline-u-boot/673/2
    - http://elinux.org/RPi_U-Boot#Mainline
    - https://blogs.s-osg.org/use-mainline-u-boot-non-signed-kernels-exynos-chromebooks/
    - https://forum.odroid.com/viewtopic.php?t=25207

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-06-11  9:54       ` bug#26339: "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer Danny Milosavljevic
@ 2017-06-11 10:13         ` Danny Milosavljevic
  2017-06-12  9:58         ` [bug#26339] " Mathieu Othacehe
  2017-06-12 20:20         ` Ludovic Courtès
  2 siblings, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-06-11 10:13 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

A possible gnu/bootloader/u-boot.scm:

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 David Craven <david@craven.ch>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
;;;
;;; 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/>.

(define-module (gnu bootloader u-boot)
  #:use-module (gnu bootloader extlinux)
  #:use-module (gnu bootloader)
  #:use-module (gnu system)
  #:use-module (gnu packages bootloaders)
  #:use-module (guix gexp)
  #:use-module (guix monads)
  #:use-module (guix records)
  #:use-module (guix utils)
  #:export (u-boot-bootloader))

;;;
;;; Installation procedures.
;;;

(define install-u-boot
  #~(lambda (bootloader device mount-point)
      (if bootloader
        (let ((u-boot-installer (string-append bootloader "/sbin/install-u-boot")) ; doesn't actually exist yet.
              (installation-dir (string-append mount-point "/boot")))
          (unless (zero? (system* u-boot-installer
                                  (string-append "--installdir=" installation-dir)
                                  (string-append "--device" device))
            (error "failed to install U-Boot")))))))

;;;
;;; Bootloader definitions.
;;;

(define u-boot-bootloader
  (bootloader
   (inherit extlinux-bootloader)
   (package #f)
   (name 'u-boot)
   (installer install-u-boot)
   (configuration-file "/boot/extlinux.conf")))

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-06-11  9:54       ` bug#26339: "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer Danny Milosavljevic
  2017-06-11 10:13         ` Danny Milosavljevic
@ 2017-06-12  9:58         ` Mathieu Othacehe
  2017-06-12 20:09           ` Ludovic Courtès
  2017-06-12 20:20         ` Ludovic Courtès
  2 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-06-12  9:58 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339


Hi Danny,

I must admin the disctinction between syslinux and extlinux is a bit
unclear to me.

Reading this page :

http://www.syslinux.org/wiki/index.php?title=EXTLINUX

"EXTLINUX is a Syslinux variant which boots from a Linux filesystem."

Which means that extlinux is a bootloader per-se and the current naming
in gnu/bootloader/extlinux.scm makes sense.

The wikipedia page of syslinux, also explains that syslinux is a "suite
of bootloaders" including :

- syslinux (the original one used for booting from fat and ntfs)
- extlinux
- pxelinux
- memdist

However, I must admit there's something strange here :

--8<---------------cut here---------------start------------->8---
(define u-boot-bootloader
  (bootloader
   (inherit extlinux-bootloader)
   (package #f)
   (name 'u-boot)
   (installer install-u-boot)
   (configuration-file "/boot/extlinux.conf")))
--8<---------------cut here---------------end--------------->8---

The fact that u-boot-bootloader inherits from extlinux-bootloader seems
strange, even if u-boot is configured with a file following extlinux
syntax.

Maybe we could write :

--8<---------------cut here---------------start------------->8---
(define u-boot-bootloader
  (bootloader
   (package #f)
   (name 'u-boot)
   (installer install-u-boot)
   (configuration-file "/boot/extlinux.conf")
   (configuration-file-generator extlinux-configuration-file)))
--8<---------------cut here---------------end--------------->8---

where extlinux-configuration-file is exported from extlinux.scm ?

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-06-12  9:58         ` [bug#26339] " Mathieu Othacehe
@ 2017-06-12 20:09           ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-12 20:09 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> The fact that u-boot-bootloader inherits from extlinux-bootloader seems
> strange, even if u-boot is configured with a file following extlinux
> syntax.
>
> Maybe we could write :
>
> (define u-boot-bootloader
>   (bootloader
>    (package #f)
>    (name 'u-boot)
>    (installer install-u-boot)
>    (configuration-file "/boot/extlinux.conf")
>    (configuration-file-generator extlinux-configuration-file)))
>
> where extlinux-configuration-file is exported from extlinux.scm ?

Given that the configuration file syntax is similar but presumably not
identical (?) and that it’s fairly simple, it may be best to simply have
both ‘extlinux-configuration-file’ and ‘u-boot-configuration-file’.
It’s a case where factorization is probably a bad idea.

WDYT?

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-06-11  9:54       ` bug#26339: "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer Danny Milosavljevic
  2017-06-11 10:13         ` Danny Milosavljevic
  2017-06-12  9:58         ` [bug#26339] " Mathieu Othacehe
@ 2017-06-12 20:20         ` Ludovic Courtès
  2017-06-13  5:07           ` Danny Milosavljevic
  2 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-12 20:20 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 26339

Hi,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> Not sure why this goes into extlinux.  Extlinux is just a configuration standard.  It wouldn't have those installation files "mbr.bin", "gptmbr.bin".
>
> According to http://www.syslinux.org/wiki/index.php?title=Mbr it seems these are part of the syslinux bootloader distribution.
>
> It was weird like that before patch 504 but I don't think it makes sense to conflate extlinux with syslinux.

Oh I understand better now (sorry for not reading messages in the right
order), and I agree with you.

If “extlinux” is just the name of the configuration file format, I would
argue in favor of having (gnu bootloaders extlinux) simply provide
‘extlinux-configuration-file’.  It should not provide ‘install-extlinux’
and ‘extlinux-bootloader’ at all.

Instead these should go to (gnu bootloaders syslinux), with
s/extlinux/syslinux/.

In addition, I think {extlinux,syslinux}.scm and guix.texi should
provide references to the relevant bits of upstream documentation
(documentation for the extlinux format, documentation for the syslinux
MBR and GPT bootloaders, etc.)  This will be useful for those of us
who’re not familiar with the thing (like me :-)).

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt.
  2017-05-18 10:13 ` bug#26339: [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt Mathieu Othacehe
@ 2017-06-12 20:23   ` Ludovic Courtès
  2017-06-13 17:52     ` Mathieu Othacehe
  2017-06-13 14:34   ` Danny Milosavljevic
  1 sibling, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-12 20:23 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/bootloader/extlinux.scm (extlinux-bootloader-gpt): New exported
>   variable.
>  (install-extlinux)[mbr]: New argument.
>  (install-extlinux-mbr, install-extlinux-gpt): New variables.
>  (extlinux-bootloader)[installer]: Use install-extlinux-mbr.

So let’s have a separate (gnu bootloaders syslinux) module like Danny
and I suggested, and let’s keep extlinux.scm focused on just the
extlinux file format.  Sounds good to you?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] tests: Add syslinux gpt test.
  2017-05-18 10:26 ` bug#26339: [PATCH] tests: Add syslinux gpt test Mathieu Othacehe
@ 2017-06-12 20:29   ` Ludovic Courtès
  2017-06-19 16:55     ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-12 20:29 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/tests/install.scm (%test-installed-syslinux-os): New exported
>   variable.
>   (%minimal-syslinux-os, %minimal-syslinux-os-source): New variables.
>   (%syslinux-gpt-installation-script): New variable.
> * gnu/system/install.scm (installation-os)[packages]: Add syslinux.

Awesome!  It’s really helpful, a good way to avoid bitrot.

> --- a/gnu/system/install.scm
> +++ b/gnu/system/install.scm
> @@ -343,6 +343,7 @@ Use Alt-F2 for documentation.
>      (packages (cons* (canonical-package glibc) ;for 'tzselect' & co.
>                       parted gptfdisk ddrescue
>                       grub                  ;mostly so xrefs to its manual work
> +                     syslinux

I don’t think we should provide ‘syslinux’ in the installation image.
The image is already fat enough.

> +(define-os-with-source (%minimal-syslinux-os
> +                        %minimal-syslinux-os-source)

I think you can’t really avoid duplication because
‘define-os-with-source’ needs to see the full source.  You could remove
the unnecessary bits like ‘users’ though.

> +(define %syslinux-gpt-installation-script
> +  ;; Shell script of a simple installation.
> +  ;; As syslinux 6.0.3 does not handle 64bits ext4 partitions,
> +  ;; we make sure to pass -O '^64bit' to mkfs.

Really?  Woow.

> +(define %test-installed-syslinux-os
> +  (system-test
> +   (name "installed-syslinux-os")
> +   (description
> +    "...")

Please expound a bit.  :-)

Otherwise LGTM, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] scripts: system: Handle unspecified bootloader package and installer.
  2017-05-21 13:57 ` bug#26339: [PATCH] scripts: system: Handle unspecified bootloader package and installer Mathieu Othacehe
@ 2017-06-12 20:32   ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-12 20:32 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * guix/scripts/system.system (perform-action): If bootloader installer or
>   bootloader package are #f, do not add them to drvs but keep things going.
>
> This allows to write (installer #f) or (package #f) in <bootloader>
> definition.
>
> Reported-by: Clément Lassieur <clement@lassieur.org>.

What’s the point of setting these to #f?

If really needed, I would rather set them to (const #f) and avoid the
special case in (guix scripts system).

WDYT?

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-06-12 20:20         ` Ludovic Courtès
@ 2017-06-13  5:07           ` Danny Milosavljevic
  2017-10-04 14:55             ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Danny Milosavljevic @ 2017-06-13  5:07 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

Hi Ludo,

On Mon, 12 Jun 2017 22:20:54 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> If “extlinux” is just the name of the configuration file format, 

It depends.

Syslinux-the-website thinks extlinux is the entire bootloader.

And https://fedoraproject.org//wiki/Changes/u-boot_syslinux which is a tracking page for adding support for extlinux.conf to u-boot (back then) says "syslinux style configuration files".

So we can also keep it as Mathieu intended and just overwrite the installer for u-boot.  Looks good to me.

>Given that the configuration file syntax is similar but presumably not identical (?) 

u-boot doesn't support the entire format.  For example it can't currently do submenus.  But the idea with the above Fedora change was to use the same extlinux.conf for ARM and x86_64.  No idea whether they are actually using a subset still.

>and that it’s fairly simple, it may be best to simply have
>both ‘extlinux-configuration-file’ and ‘u-boot-configuration-file’.
>It’s a case where factorization is probably a bad idea.

After looking into it some more, I'm fine with any of the ways to proceed and defer the decision to Mathieu.

At first I thought it would be clearer if we had the extlinux.conf file writer common (also PXEboot and other things use it in the wild) - but it's not that bad to duplicated it.  Maybe a little opaque and the different writers would probably diverge on accident as we added features - but if we were careful it would be OK.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt.
  2017-05-18 10:13 ` bug#26339: [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt Mathieu Othacehe
  2017-06-12 20:23   ` [bug#26339] " Ludovic Courtès
@ 2017-06-13 14:34   ` Danny Milosavljevic
  1 sibling, 0 replies; 204+ messages in thread
From: Danny Milosavljevic @ 2017-06-13 14:34 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

LGTM!

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt.
  2017-06-12 20:23   ` [bug#26339] " Ludovic Courtès
@ 2017-06-13 17:52     ` Mathieu Othacehe
  2017-06-14  7:37       ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-06-13 17:52 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


Hi Ludo,

> So let’s have a separate (gnu bootloaders syslinux) module like Danny
> and I suggested, and let’s keep extlinux.scm focused on just the
> extlinux file format.  Sounds good to you?

Well I'm quite sure that extlinux is more than a file format, it's a
bootloader per-se. Danny seems to agree after digging it up. So I'd like
to commit this patch as is.

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt.
  2017-06-13 17:52     ` Mathieu Othacehe
@ 2017-06-14  7:37       ` Ludovic Courtès
  0 siblings, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-14  7:37 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> So let’s have a separate (gnu bootloaders syslinux) module like Danny
>> and I suggested, and let’s keep extlinux.scm focused on just the
>> extlinux file format.  Sounds good to you?
>
> Well I'm quite sure that extlinux is more than a file format, it's a
> bootloader per-se. Danny seems to agree after digging it up. So I'd like
> to commit this patch as is.

OK then, makes sense (modulo the other comments).  I was surprised to
see the naming situation was this confused.  :-)

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] tests: Add syslinux gpt test.
  2017-06-12 20:29   ` [bug#26339] " Ludovic Courtès
@ 2017-06-19 16:55     ` Mathieu Othacehe
  2017-06-20 20:13       ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-06-19 16:55 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]


Hi Ludo,

> I don’t think we should provide ‘syslinux’ in the installation image.
> The image is already fat enough.

Yep you're right, I added it without really understanding why it has
necessary for the test to succeed.

Now I understand why, it's because the image has no network access, so
every package that will be needed further has to be specified. I add a
packages list to "run-install" to solve this issue.

Thanks,

Mathieu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-tests-Add-extlinux-gpt-test.patch --]
[-- Type: text/x-patch, Size: 6527 bytes --]

From 7cf07ec0e909d99030e2646db9fdfef09d655316 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <m.othacehe@gmail.com>
Date: Thu, 18 May 2017 12:19:53 +0200
Subject: [PATCH] tests: Add extlinux gpt test.

* gnu/tests/install.scm (%test-installed-extlinux-os): New exported
  variable.
  (%minimal-extlinux-os, %minimal-extlinux-os-source): New variables.
  (%extlinux-gpt-installation-script): New variable.
---
 gnu/tests/install.scm | 92 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 86 insertions(+), 6 deletions(-)

diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index b104efcfd..7c5d48104 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -18,12 +18,14 @@
 
 (define-module (gnu tests install)
   #:use-module (gnu)
+  #:use-module (gnu bootloader extlinux)
   #:use-module (gnu tests)
   #:use-module (gnu tests base)
   #:use-module (gnu system)
   #:use-module (gnu system install)
   #:use-module (gnu system vm)
   #:use-module ((gnu build vm) #:select (qemu-command))
+  #:use-module (gnu packages bootloaders)
   #:use-module (gnu packages ocr)
   #:use-module (gnu packages qemu)
   #:use-module (gnu packages package-management)
@@ -34,6 +36,7 @@
   #:use-module (guix gexp)
   #:use-module (guix utils)
   #:export (%test-installed-os
+            %test-installed-extlinux-os
             %test-separate-store-os
             %test-separate-home-os
             %test-raid-root-os
@@ -77,6 +80,38 @@
                                                   (guix combinators)))))
                     %base-services))))
 
+(define (operating-system-add-packages os packages)
+  "Append PACKAGES to OS packages list."
+  (operating-system
+    (inherit os)
+    (packages (append packages (operating-system-packages os)))))
+
+(define-os-with-source (%minimal-extlinux-os
+                        %minimal-extlinux-os-source)
+  (use-modules (gnu) (gnu tests) (gnu bootloader extlinux)
+               (srfi srfi-1))
+
+  (operating-system
+    (host-name "liberigilo")
+    (timezone "Europe/Paris")
+    (locale "en_US.UTF-8")
+
+    (bootloader (bootloader-configuration
+                 (bootloader extlinux-bootloader-gpt)
+                 (device "/dev/vdb")))
+    (kernel-arguments '("console=ttyS0"))
+    (file-systems (cons (file-system
+                          (device "my-root")
+                          (title 'label)
+                          (mount-point "/")
+                          (type "ext4"))
+                        %base-file-systems))
+    (services (cons (service marionette-service-type
+                             (marionette-configuration
+                              (imported-modules '((gnu services herd)
+                                                  (guix combinators)))))
+                    %base-services))))
+
 (define (operating-system-with-current-guix os)
   "Return a variant of OS that uses the current Guix."
   (operating-system
@@ -121,23 +156,51 @@ guix system init /mnt/etc/config.scm /mnt --no-substitutes
 sync
 reboot\n")
 
+(define %extlinux-gpt-installation-script
+  ;; Shell script of a simple installation.
+  ;; As syslinux 6.0.3 does not handle 64bits ext4 partitions,
+  ;; we make sure to pass -O '^64bit' to mkfs.
+  "\
+. /etc/profile
+set -e -x
+guix --version
+
+export GUIX_BUILD_OPTIONS=--no-grafts
+guix build isc-dhcp
+parted --script /dev/vdb mklabel gpt \\
+  mkpart ext2 1M 1G \\
+  set 1 legacy_boot on
+mkfs.ext4 -L my-root -O '^64bit' /dev/vdb1
+mount /dev/vdb1 /mnt
+df -h /mnt
+herd start cow-store /mnt
+mkdir /mnt/etc
+cp /etc/target-config.scm /mnt/etc/config.scm
+guix system init /mnt/etc/config.scm /mnt --no-substitutes
+sync
+reboot\n")
+
 (define* (run-install target-os target-os-source
                       #:key
                       (script %simple-installation-script)
+                      (packages '())
                       (os (marionette-operating-system
-                           ;; Since the image has no network access, use the
-                           ;; current Guix so the store items we need are in
-                           ;; the image.
                            (operating-system
-                             (inherit (operating-system-with-current-guix
-                                       installation-os))
+                             ;; Since the image has no network access, use the
+                             ;; current Guix so the store items we need are in
+                             ;; the image and add packages provided.
+                             (inherit (operating-system-add-packages
+                                       (operating-system-with-current-guix
+                                        installation-os)
+                                       packages))
                              (kernel-arguments '("console=ttyS0")))
                            #:imported-modules '((gnu services herd)
                                                 (guix combinators))))
                       (target-size (* 1200 MiB)))
   "Run SCRIPT (a shell script following the GuixSD installation procedure) in
 OS to install TARGET-OS.  Return a VM image of TARGET-SIZE bytes containing
-the installed system."
+the installed system.  The packages specified in PACKAGES will be appended to
+packages defined in installation-os."
 
   (mlet* %store-monad ((_      (set-grafting #f))
                        (system (current-system))
@@ -232,6 +295,23 @@ build (current-guix) and then store a couple of full system images.")
       (run-basic-test %minimal-os command
                       "installed-os")))))
 
+(define %test-installed-extlinux-os
+  (system-test
+   (name "installed-extlinux-os")
+   (description
+    "Test basic functionality of an OS booted with an extlinux bootloader.  As
+per %test-installed-os, this test is expensive in terms of CPU and storage.")
+   (value
+    (mlet* %store-monad ((image (run-install %minimal-extlinux-os
+                                             %minimal-extlinux-os-source
+                                             #:packages
+                                             (list syslinux)
+                                             #:script
+                                             %extlinux-gpt-installation-script))
+                         (command (qemu-command/writable-image image)))
+      (run-basic-test %minimal-extlinux-os command
+                      "installed-extlinux-os")))))
+
 \f
 ;;;
 ;;; Separate /home.
-- 
2.13.1


^ permalink raw reply related	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] tests: Add syslinux gpt test.
  2017-06-19 16:55     ` Mathieu Othacehe
@ 2017-06-20 20:13       ` Ludovic Courtès
  2017-06-21  8:05         ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-06-20 20:13 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hello!

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> I don’t think we should provide ‘syslinux’ in the installation image.
>> The image is already fat enough.
>
> Yep you're right, I added it without really understanding why it has
> necessary for the test to succeed.
>
> Now I understand why, it's because the image has no network access, so
> every package that will be needed further has to be specified. I add a
> packages list to "run-install" to solve this issue.

Sounds good.

> From 7cf07ec0e909d99030e2646db9fdfef09d655316 Mon Sep 17 00:00:00 2001
> From: Mathieu Othacehe <m.othacehe@gmail.com>
> Date: Thu, 18 May 2017 12:19:53 +0200
> Subject: [PATCH] tests: Add extlinux gpt test.
>
> * gnu/tests/install.scm (%test-installed-extlinux-os): New exported
>   variable.
>   (%minimal-extlinux-os, %minimal-extlinux-os-source): New variables.
>   (%extlinux-gpt-installation-script): New variable.
  ^^
Extra space.  :-)

Please also mention the ‘run-install’ change.

Otherwise LGTM, thanks for taking the time to write this test!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] [PATCH] tests: Add syslinux gpt test.
  2017-06-20 20:13       ` Ludovic Courtès
@ 2017-06-21  8:05         ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-06-21  8:05 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


Hi Ludo,

> Otherwise LGTM, thanks for taking the time to write this test!

Thanks for the review I pushed those two patches as dbaef95 and
a48a20fb.

For the last one (#f package and installer), I have to give it some
thought.

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-06-13  5:07           ` Danny Milosavljevic
@ 2017-10-04 14:55             ` Ludovic Courtès
  2017-10-04 19:56               ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-10-04 14:55 UTC (permalink / raw)
  To: Danny Milosavljevic, Mathieu Othacehe; +Cc: 26339

Hello Danny & Mathieu!

So we’ve had this huge thread at <https://bugs.gnu.org/26339>, and I
think the important bits were applied some time ago already.

Are we still missing something?  If yes, should we close this issue and
open a new one with a clear focus?

(BTW, too bad we missed your talk at the GHM, Mathieu!  ;-))

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer
  2017-10-04 14:55             ` Ludovic Courtès
@ 2017-10-04 19:56               ` Mathieu Othacehe
  0 siblings, 0 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-10-04 19:56 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


Hey Ludo !

> So we’ve had this huge thread at <https://bugs.gnu.org/26339>, and I
> think the important bits were applied some time ago already.
>
> Are we still missing something?  If yes, should we close this issue and
> open a new one with a clear focus?

I think the topic has been covered, and we can close this issue. Is it
ok for you Danny ?

>
> (BTW, too bad we missed your talk at the GHM, Mathieu!  ;-))

Maybe next year ;)

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* bug#26339: closing bootloader serie.
  2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
                   ` (8 preceding siblings ...)
  2017-06-10  8:53 ` bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name Mathieu Othacehe
@ 2017-10-13 14:08 ` Mathieu Othacehe
  2017-10-13 15:31   ` [bug#26339] " Ludovic Courtès
  9 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-10-13 14:08 UTC (permalink / raw)
  To: 26339-done


All the related patches are merged by now. 

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] closing bootloader serie.
  2017-10-13 14:08 ` bug#26339: closing bootloader serie Mathieu Othacehe
@ 2017-10-13 15:31   ` Ludovic Courtès
  2017-10-26  9:43     ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-10-13 15:31 UTC (permalink / raw)
  To: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> All the related patches are merged by now. 

Woohoo!  \o/

Thanks again for your tireless work, to you and Danny.

Hopefully this will unlock GuixSD-on-ARM in the not-too-distant future?

Cheers,
Ludo'.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] closing bootloader serie.
  2017-10-13 15:31   ` [bug#26339] " Ludovic Courtès
@ 2017-10-26  9:43     ` Mathieu Othacehe
  2017-10-26 17:14       ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-10-26  9:43 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


Hi Ludo,

> Thanks again for your tireless work, to you and Danny.

:) Thanks to you for your support.

> Hopefully this will unlock GuixSD-on-ARM in the not-too-distant future?

Actually, I'm trying to produce a disk-image for a beaglebone black
board. The problem I have is that a lot of packages have to be built on
native target and qemu is really slow.

So I have a naive question : why can't I cross-compile everything when
building a disk-image ?

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] closing bootloader serie.
  2017-10-26  9:43     ` Mathieu Othacehe
@ 2017-10-26 17:14       ` Ludovic Courtès
  2017-10-26 17:33         ` Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-10-26 17:14 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Hi,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> Hopefully this will unlock GuixSD-on-ARM in the not-too-distant future?
>
> Actually, I'm trying to produce a disk-image for a beaglebone black
> board. The problem I have is that a lot of packages have to be built on
> native target and qemu is really slow.
>
> So I have a naive question : why can't I cross-compile everything when
> building a disk-image ?

You could cross-compile stuff, but many packages with fail to
cross-compile.

That said, I experimented with cross-compiled GuixSD (that is, ‘guix
system build --target=foo-linux-gnu’), and I think that’s promising,
with the caveat that you have to restrict your package set to those that
can actually be cross-compiled.  Should we try to get it off the ground?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] closing bootloader serie.
  2017-10-26 17:14       ` Ludovic Courtès
@ 2017-10-26 17:33         ` Mathieu Othacehe
  2017-10-26 22:20           ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-10-26 17:33 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26339


> That said, I experimented with cross-compiled GuixSD (that is, ‘guix
> system build --target=foo-linux-gnu’), and I think that’s promising,
> with the caveat that you have to restrict your package set to those that
> can actually be cross-compiled.  Should we try to get it off the ground?

That would be really interesting. But to build an arm GuixSD installer
for example, it would require that are all the packages needed to set-up
the rootfs of the installer are cross-compilable, right ?

Also, something I don't understand here. This does not work (without
armhf offloading machine):

--8<---------------cut here---------------start------------->8---
./pre-inst-env guix system disk-image --file-system-type=iso9660 --system=armhf-linux  gnu/system/boards/beaglebone-black.scm

guix system: error: build failed: a `armhf-linux' is required to build `/gnu/store/pswlzi1bwdzalfidbzf5w96fbdiv3dc1-linux-libre-arm-omap2plus-4.13.8.drv', but I am a `x86_64-linux'
--8<---------------cut here---------------end--------------->8---

but this works :

--8<---------------cut here---------------start------------->8---
./pre-inst-env guix build  --target=arm-linux-gnueabihf linux-libre-arm-omap2plus

/gnu/store/53lcpmpkbba661h3lrnxms1dfz750gw5-linux-libre-arm-omap2plus-4.13.8
--8<---------------cut here---------------end--------------->8---

What's the difference between --system=armhf-linux and
--target=arm-linux-gnueabihf ? Why guix system do not use the already
cross-compiled kernel and asks me to build it on an armhf machine ?

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* [bug#26339] closing bootloader serie.
  2017-10-26 17:33         ` Mathieu Othacehe
@ 2017-10-26 22:20           ` Ludovic Courtès
  2017-10-27  7:52             ` bug#26339: " Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-10-26 22:20 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 26339

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> That said, I experimented with cross-compiled GuixSD (that is, ‘guix
>> system build --target=foo-linux-gnu’), and I think that’s promising,
>> with the caveat that you have to restrict your package set to those that
>> can actually be cross-compiled.  Should we try to get it off the ground?
>
> That would be really interesting. But to build an arm GuixSD installer
> for example, it would require that are all the packages needed to set-up
> the rootfs of the installer are cross-compilable, right ?

Yes.  So in my experiments I had ‘services’ and ‘packages’ almost empty,
to be sure.

> What's the difference between --system=armhf-linux and
> --target=arm-linux-gnueabihf ?

‘--target’ specifies a cross-compilation triplet, where ‘--system’
specifies the system you want to build on.  Without offloading, your
x86_64 machine can only build for ‘x86_64-linux’ or ‘i686-linux’.

Conversely cross-compilation does not depend on offloading, it’s just
regular cross-compilation.

Does that make sense?

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: bug#26339: closing bootloader serie.
  2017-10-26 22:20           ` Ludovic Courtès
@ 2017-10-27  7:52             ` Mathieu Othacehe
  2017-10-29 15:47               ` Ludovic Courtès
  0 siblings, 1 reply; 204+ messages in thread
From: Mathieu Othacehe @ 2017-10-27  7:52 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


> Does that make sense?

Yes, it is now much clearer, thank you !

My qemu virtualized ARM machine has been compiling for a week now
(is it normal to have so few substitutes btw ?) and is not over yet.

So, I'm really interested by the --target on guix system. Do you happend
to have a draft of your experiments :) ?

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: bug#26339: closing bootloader serie.
  2017-10-27  7:52             ` bug#26339: " Mathieu Othacehe
@ 2017-10-29 15:47               ` Ludovic Courtès
  2017-11-09 10:47                 ` GuixSD on armhf Mathieu Othacehe
  0 siblings, 1 reply; 204+ messages in thread
From: Ludovic Courtès @ 2017-10-29 15:47 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

Hi,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> Does that make sense?
>
> Yes, it is now much clearer, thank you !
>
> My qemu virtualized ARM machine has been compiling for a week now
> (is it normal to have so few substitutes btw ?) and is not over yet.

It’s not normal to have so few substitutes.  ARM substitutes are always
lagging behind on our build farm, but hopefully we’ll get additional
ARM build machines soon.

> So, I'm really interested by the --target on guix system. Do you happend
> to have a draft of your experiments :) ?

Here’s a very crude patch that mixes a couple of experiments, i hope it
can be of any use to you.  :-)

For a start, I could polish the ‘let-system’ and ‘with-system’ patches,
if you want.

My idea was to eventually have a Shepherd service whose ‘start’ method
would be something like:

  (virtual-machine
    (with-system (target "arm-linux-gnueabihf")
      (operating-system
        …)))

IOW, a service that starts a GuixSD VM for another architecture.

Thoughts?

Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 12056 bytes --]

Unstaged
modified   .dir-locals.el
@@ -72,6 +72,7 @@
    (eval . (put 'run-with-state 'scheme-indent-function 1))
    (eval . (put 'wrap-program 'scheme-indent-function 1))
    (eval . (put 'with-imported-modules 'scheme-indent-function 1))
+   (eval . (put 'let-system 'scheme-indent-function 1))
 
    (eval . (put 'call-with-container 'scheme-indent-function 1))
    (eval . (put 'container-excursion 'scheme-indent-function 1))
modified   gnu/services.scm
@@ -25,7 +25,8 @@
   #:use-module (guix profiles)
   #:use-module (guix sets)
   #:use-module (guix ui)
-  #:use-module ((guix utils) #:select (source-properties->location))
+  #:use-module ((guix utils) #:select (%current-target-system
+                                       source-properties->location))
   #:use-module (guix modules)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
@@ -265,6 +266,7 @@ This is a shorthand for (map (lambda (svc) ...) %base-services)."
 (define (system-derivation mentries mextensions)
   "Return as a monadic value the derivation of the 'system' directory
 containing the given entries."
+  (pk 'sysdrv (%current-target-system))
   (mlet %store-monad ((entries    mentries)
                       (extensions (sequence %store-monad mextensions)))
     (lower-object
modified   guix/gexp.scm
@@ -32,6 +32,7 @@
   #:export (gexp
             gexp?
             with-imported-modules
+            let-system
 
             gexp-input
             gexp-input?
@@ -167,7 +168,9 @@ returns its output file name of OBJ's OUTPUT."
     ((? derivation? drv)
      (derivation->output-path drv output))
     ((? string? file)
-     file)))
+     file)
+    (#f
+     thing)))
 
 (define (register-compiler! compiler)
   "Register COMPILER as a gexp compiler."
@@ -234,6 +237,51 @@ The expander specifies how an object is converted to its sexp representation."
     (return drv)))
 
 \f
+;;;
+;;; System dependencies.
+;;;
+
+;; Binding form for the current system and cross-compilation target.
+(define-record-type <system-binding>
+  (system-binding proc)
+  system-binding?
+  (proc system-binding-proc))
+
+(define-syntax let-system
+  (syntax-rules ()
+    "Introduce a system binding in a gexp.  The simplest form is:
+
+  (let-system system
+    (cond ((string=? system \"x86_64-linux\") ...)
+          (else ...)))
+
+which binds SYSTEM to the currently targeted system.  The second form is
+similar, but it also shows the cross-compilation target:
+
+  (let-system (system target)
+    ...)
+
+Here TARGET is bound to the cross-compilation triplet or #f."
+    ((_ (system target) exp0 exp ...)
+     (system-binding (lambda (system target)
+                       exp0 exp ...)))
+    ((_ system exp0 exp ...)
+     (system-binding (lambda (system target)
+                       exp0 exp ...)))))
+
+(define-gexp-compiler (system-binding-compiler (binding <system-binding>)
+                                               system target)
+  (match binding
+    (($ <system-binding> proc)
+     (let ((obj (proc system target)))
+       (match (and (struct? obj) (lookup-compiler obj))
+         (#f
+          (with-monad %store-monad
+            (return obj)))
+         (lower
+          (lower obj system #:target target)))))))
+
+\f
 ;;;
 ;;; File declarations.
 ;;;
@@ -485,14 +533,16 @@ corresponding input list as a monadic value.  When TARGET is true, use it as
 the cross-compilation target triplet."
   (with-monad %store-monad
     (sequence %store-monad
-              (map (match-lambda
-                     (((? struct? thing) sub-drv ...)
-                      (mlet %store-monad ((drv (lower-object
-                                                thing system #:target target)))
-                        (return `(,drv ,@sub-drv))))
-                     (input
-                      (return input)))
-                   inputs))))
+              (filter-map (match-lambda
+                            (((? struct? thing) sub-drv ...)
+                             (mlet %store-monad ((drv (lower-object
+                                                       thing system #:target target)))
+                               (if drv
+                                   (return `(,drv ,@sub-drv))
+                                   (return #f))))
+                            (input
+                             (return input)))
+                          inputs))))
 
 (define* (lower-reference-graphs graphs #:key system target)
   "Given GRAPHS, a list of (FILE-NAME INPUT ...) lists for use as a
@@ -817,6 +867,51 @@ environment."
                          (identifier-syntax modules)))
     body ...))
 
+;; (define-syntax alpha-rename
+;;   (syntax-rules (lambda begin)
+;;     ((_ (lambda (bindings ...) body ...) (env ...))
+;;      (lambda (y ...)
+;;        (alpha-rename (begin body ...)
+;;                      ((bindings ...) env ...))))
+;;     ((_ (begin exp ...) (env ...))
+;;      (begin (alpha-rename exp (env ...)) ...))
+;;     ((_ id (env ...))
+;;      (letrec-syntax ((lookup (syntax-rules (id)
+;;                                ((_ ((id alpha) _ (... ...)))
+;;                                 alpha)
+;;                                ((_ (_ rest (... ...)))
+;;                                 (lookup (rest (... ...))))
+;;                                ((_ ())
+;;                                 id))))
+;;        (lookup (env ...))))))
+
+(define-syntax alpha-rename
+  (lambda (s)
+    (syntax-case s (lambda begin)
+      ((_ (lambda (bindings ...) body ...) (env ...))
+       (with-syntax (((formals ...)
+                      (generate-temporaries #'(bindings ...))))
+         #'(lambda (formals ...)
+             (alpha-rename (begin body ...)
+                           (((bindings formals) ...) env ...)))))
+      ((_ (begin exp ...) (env ...))
+       #'(begin (alpha-rename exp (env ...)) ...))
+      ((_ (proc arg ...) (env ...))
+       #'((alpha-rename proc (env ...))
+          (alpha-rename arg (env ...))
+          ...))
+      ((_ id (env ...))
+       (identifier? (pk #'(env ...) #'id))
+       #'(letrec-syntax ((lookup (syntax-rules (id)
+                                   ((_ ((id alpha) _ (... ...)))
+                                    alpha)
+                                   ((_ (_ rest (... ...)))
+                                    (lookup (rest (... ...))))
+                                   ((_ ())
+                                    id))))
+           (lookup (env ...)))))))
+
+
 (define-syntax gexp
   (lambda (s)
     (define (collect-escapes exp)
modified   guix/profiles.scm
@@ -1211,7 +1211,8 @@ the entries in MANIFEST."
                              (hooks %default-profile-hooks)
                              (locales? #t)
                              (allow-collisions? #f)
-                             system target)
+                             system
+                             (target (%current-target-system)))
   "Return a derivation that builds a profile (aka. 'user environment') with
 the given MANIFEST.  The profile includes additional derivations returned by
 the monadic procedures listed in HOOKS--such as an Info 'dir' file, etc.
modified   guix/scripts/system.scm
@@ -931,7 +931,8 @@ resulting from command-line parsing."
                              #:install-bootloader? bootloader?
                              #:target target #:device device
                              #:gc-root (assoc-ref opts 'gc-root)))))
-        #:system system))))
+        #:system system
+        #:target "arm-linux-gnueabihf"))))
 
 (define (process-command command args opts)
   "Process COMMAND, one of the 'guix system' sub-commands.  ARGS is its
@@ -1010,15 +1011,15 @@ argument list and OPTS is the option alist."
            (fail))))
       args))
 
-  (with-error-handling
-    (let* ((opts     (parse-command-line args %options
-                                         (list %default-options)
-                                         #:argument-handler
-                                         parse-sub-command))
-           (args     (option-arguments opts))
-           (command  (assoc-ref opts 'action)))
-      (parameterize ((%graft? (assoc-ref opts 'graft?)))
-        (process-command command args opts)))))
+  (let* ((opts     (parse-command-line args %options
+                                       (list %default-options)
+                                       #:argument-handler
+                                       parse-sub-command))
+         (args     (option-arguments opts))
+         (command  (assoc-ref opts 'action)))
+    (parameterize ((%graft? (assoc-ref opts 'graft?))
+                   (%current-target-system "arm-linux-gnueabihf"))
+      (process-command command args opts))))
 
 ;;; Local Variables:
 ;;; eval: (put 'call-with-service-upgrade-info 'scheme-indent-function 1)
modified   guix/store.scm
@@ -1136,18 +1136,24 @@ topological order."
   boolean)
 
 (define substitutable-paths
-  (operation (query-substitutable-paths (store-path-list paths))
-             "Return the subset of PATHS that is substitutable."
-             store-path-list))
+  (let ((proc (operation (query-substitutable-paths (store-path-list paths))
+                         "Return the subset of PATHS that is substitutable."
+                         store-path-list)))
+    (lambda (store lst)
+      (pk 's-p lst)
+      (proc store lst))))
 
 (define substitutable-path-info
-  (operation (query-substitutable-path-infos (store-path-list paths))
-             "Return information about the subset of PATHS that is
+  (let ((proc (operation (query-substitutable-path-infos (store-path-list paths))
+                         "Return information about the subset of PATHS that is
 substitutable.  For each substitutable path, a `substitutable?' object is
 returned; thus, the resulting list can be shorter than PATHS.  Furthermore,
 that there is no guarantee that the order of the resulting list matches the
 order of PATHS."
-             substitutable-path-list))
+                         substitutable-path-list)))
+    (lambda (store lst)
+      (pk 'subst-p-i lst)
+      (proc store lst))))
 
 (define built-in-builders
   (let ((builders (operation (built-in-builders)
@@ -1428,7 +1434,8 @@ where FILE is the entry's absolute file name and STAT is the result of
 (define* (run-with-store store mval
                          #:key
                          (guile-for-build (%guile-for-build))
-                         (system (%current-system)))
+                         (system (%current-system))
+                         target)
   "Run MVAL, a monadic value in the store monad, in STORE, an open store
 connection, and return the result."
   ;; Initialize the dynamic bindings here to avoid bad surprises.  The
@@ -1436,7 +1443,7 @@ connection, and return the result."
   ;; bind-time and not at call time, which can be disconcerting.
   (parameterize ((%guile-for-build guile-for-build)
                  (%current-system system)
-                 (%current-target-system #f))
+                 (%current-target-system target))
     (call-with-values (lambda ()
                         (run-with-state mval store))
       (lambda (result store)
modified   tests/gexp.scm
@@ -258,6 +258,23 @@
            (((thing "out"))
             (eq? thing file))))))
 
+(test-assert "let-system"
+  (list `(begin ,(%current-system) #t) '() '())
+  (let ((exp  #~(begin
+                  #$(let-system system system)
+                  #t)))
+    (list (gexp->sexp* exp)
+          (gexp-inputs exp)
+          (gexp-native-inputs exp))))
+
+(test-assert "let-system, target"
+  (list `(begin ,(%current-system) #t))
+  (let ((exp #~(list #$@(let-system (system target)
+                          (list system target)))))
+    (list (gexp->sexp* exp)
+          (gexp-inputs exp)
+          (gexp-native-inputs exp))))
+
 (test-assert "ungexp + ungexp-native"
   (let* ((exp    (gexp (list (ungexp-native %bootstrap-guile)
                              (ungexp coreutils)


^ permalink raw reply	[flat|nested] 204+ messages in thread

* GuixSD on armhf.
  2017-10-29 15:47               ` Ludovic Courtès
@ 2017-11-09 10:47                 ` Mathieu Othacehe
  2017-11-10 23:39                   ` Chris Marusich
  2017-11-11 11:35                   ` Ludovic Courtès
  0 siblings, 2 replies; 204+ messages in thread
From: Mathieu Othacehe @ 2017-11-09 10:47 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


Hi Ludo,

> IOW, a service that starts a GuixSD VM for another architecture.
>
> Thoughts?

Thanks for this patch ! For now I'm still trying to build a GuixSD image
directly on an armhf system.

About that, i made some progress, but i'm now stuck on
"load-in-linux-vm" part of system generation. This part is starting a
qemu machine, inside the qemu machine i'm using for this dev. It takes
about half an hour, just to boot !

Does anyone know how could I speed this up, by buying or renting a
powerful arm machine ? by skipping somehow load-in-linux-vm part ?

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: GuixSD on armhf.
  2017-11-09 10:47                 ` GuixSD on armhf Mathieu Othacehe
@ 2017-11-10 23:39                   ` Chris Marusich
  2017-11-11 11:35                   ` Ludovic Courtès
  1 sibling, 0 replies; 204+ messages in thread
From: Chris Marusich @ 2017-11-10 23:39 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]

Mathieu Othacehe <m.othacehe@gmail.com> writes:

> Hi Ludo,
>
>> IOW, a service that starts a GuixSD VM for another architecture.
>>
>> Thoughts?
>
> Thanks for this patch ! For now I'm still trying to build a GuixSD image
> directly on an armhf system.
>
> About that, i made some progress, but i'm now stuck on
> "load-in-linux-vm" part of system generation. This part is starting a
> qemu machine, inside the qemu machine i'm using for this dev. It takes
> about half an hour, just to boot !
>
> Does anyone know how could I speed this up, by buying or renting a
> powerful arm machine ? by skipping somehow load-in-linux-vm part ?
>
> Thanks,
>
> Mathieu

I may be totally out of context here, but I'll just mention that we
apparently have some procedures for running builders in "containers"
rather than a qemu virtual machine.  Perhaps you can avoid one of those
load-in-linux-vm calls by running something in a container instead.

Check out:

    guix/gnu/build/linux-container.scm
    guix/gnu/system/linux-container.scm

You might find something you can use.

-- 
Chris

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

^ permalink raw reply	[flat|nested] 204+ messages in thread

* Re: GuixSD on armhf.
  2017-11-09 10:47                 ` GuixSD on armhf Mathieu Othacehe
  2017-11-10 23:39                   ` Chris Marusich
@ 2017-11-11 11:35                   ` Ludovic Courtès
  1 sibling, 0 replies; 204+ messages in thread
From: Ludovic Courtès @ 2017-11-11 11:35 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: guix-devel

Heya,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

>> IOW, a service that starts a GuixSD VM for another architecture.
>>
>> Thoughts?
>
> Thanks for this patch ! For now I'm still trying to build a GuixSD image
> directly on an armhf system.
>
> About that, i made some progress, but i'm now stuck on
> "load-in-linux-vm" part of system generation. This part is starting a
> qemu machine, inside the qemu machine i'm using for this dev. It takes
> about half an hour, just to boot !

Perhaps you’ll need real hardware, though I don’t know whether the cheap
SoCs are much faster than QEMU on x86_64.  :-)

I just got an Olimex A20 OLinuXino and I’d like to have it run GuixSD at
some point!

Ludo’.

^ permalink raw reply	[flat|nested] 204+ messages in thread

end of thread, other threads:[~2017-11-11 11:35 UTC | newest]

Thread overview: 204+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-02 13:49 bug#26339: [PATCH 00/18] wip: Support non grub bootloaders Mathieu Othacehe
2017-04-02 13:52 ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
2017-04-02 13:52   ` bug#26339: [PATCH 02/18] system: Add extlinux support Mathieu Othacehe
2017-04-15 16:03     ` Danny Milosavljevic
2017-05-08 20:06     ` Ludovic Courtès
2017-05-09  7:38       ` Mathieu Othacehe
2017-05-09  9:51         ` Ludovic Courtès
2017-05-09 14:30           ` Mathieu Othacehe
2017-05-09 20:40             ` Ludovic Courtès
2017-05-12  0:02               ` Danny Milosavljevic
2017-05-12  8:26                 ` Ludovic Courtès
2017-05-12 11:26                   ` Danny Milosavljevic
2017-05-12 11:36                     ` Ludovic Courtès
2017-05-12 12:18                       ` Mathieu Othacehe
2017-05-13  9:53                         ` Danny Milosavljevic
2017-05-14  7:49                           ` Mathieu Othacehe
2017-05-09 10:25         ` Ludovic Courtès
2017-05-09 14:32           ` Mathieu Othacehe
2017-04-02 13:52   ` bug#26339: [PATCH 03/18] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
2017-04-15 10:10     ` Danny Milosavljevic
2017-04-16  9:58       ` Ludovic Courtès
2017-04-02 13:52   ` bug#26339: [PATCH 04/18] bootloader: Add install procedures and use them Mathieu Othacehe
2017-04-15 16:22     ` Danny Milosavljevic
2017-04-15 17:15       ` Mathieu Othacehe
2017-04-16 21:37         ` Danny Milosavljevic
2017-04-17  8:49           ` Mathieu Othacehe
2017-04-18  8:23             ` Ludovic Courtès
2017-04-02 13:52   ` bug#26339: [PATCH 05/18] system: Rename operating-system-grub.cfg to operating-system-bootcfg Mathieu Othacehe
2017-04-15 12:44     ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 06/18] vm: Reword grub.cfg to boot.cfg Mathieu Othacehe
2017-04-15 12:43     ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 07/18] system: Add bootloader type Mathieu Othacehe
2017-04-15 16:26     ` Danny Milosavljevic
2017-04-15 17:23       ` Mathieu Othacehe
2017-04-15 20:16         ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 08/18] bootloader: Stop using grub module Mathieu Othacehe
2017-04-15 13:33     ` Danny Milosavljevic
2017-04-15 16:44     ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top Mathieu Othacehe
2017-04-15 10:35     ` Danny Milosavljevic
2017-04-15 10:46       ` Mathieu Othacehe
2017-04-15 11:30         ` Danny Milosavljevic
2017-04-15 11:41           ` Mathieu Othacehe
2017-04-15 11:52             ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 10/18] system: Rename kernel->grub-label to kernel->boot-label Mathieu Othacehe
2017-04-15 10:40     ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 11/18] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
2017-04-02 13:52   ` bug#26339: [PATCH 12/18] system: Rename grub-device to fs->boot-device Mathieu Othacehe
2017-04-15 12:45     ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 13/18] scripts: system: Remove unused variables Mathieu Othacehe
2017-04-02 13:52   ` bug#26339: [PATCH 14/18] scripts: system: Rename grub? and install-grub? to bootloader? and install-bootloader? Mathieu Othacehe
2017-04-15 13:25     ` Danny Milosavljevic
2017-04-02 13:52   ` bug#26339: [PATCH 15/18] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
2017-04-02 13:52   ` bug#26339: [PATCH 16/18] scripts: system: Adapt "init" " Mathieu Othacehe
2017-04-02 13:52   ` bug#26339: [PATCH 17/18] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
2017-04-15 16:47     ` Danny Milosavljevic
2017-04-15 17:27       ` Mathieu Othacehe
2017-05-05  7:13         ` Danny Milosavljevic
2017-05-05  7:21           ` Mathieu Othacehe
2017-04-15 18:17       ` problem with commit abae042 Mathieu Othacehe
2017-04-15 18:56         ` Danny Milosavljevic
2017-04-15 19:13           ` Mathieu Othacehe
2017-04-15 19:50         ` bootloader and kernel arguments "--root", "--system", "--load" Danny Milosavljevic
2017-04-15 23:18         ` bug#26339: problem with commit abae042 Leo Famulari
2017-04-15 23:22           ` Danny Milosavljevic
2017-04-15 23:56             ` Leo Famulari
2017-04-02 13:52   ` bug#26339: [PATCH 18/18] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
2017-04-02 18:24   ` bug#26339: [PATCH 01/18] system: Pass <bootloader-parameter> to grub David Craven
2017-04-15 13:04   ` Danny Milosavljevic
2017-04-15 13:58   ` Danny Milosavljevic
2017-04-15 15:39     ` Danny Milosavljevic
2017-04-15 20:17   ` Danny Milosavljevic
2017-04-17  9:01 ` bug#26339: [PATCH v2 00/12] Support for non grub bootloaders Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
2017-04-17 17:08     ` Danny Milosavljevic
2017-05-08  9:37     ` Ludovic Courtès
2017-05-08 13:51       ` Danny Milosavljevic
2017-05-08 15:00         ` Mathieu Othacehe
2017-05-09 14:16           ` Marius Bakke
2017-05-09 14:36             ` Mathieu Othacehe
2017-05-08 19:47         ` Ludovic Courtès
2017-05-08 20:04           ` Danny Milosavljevic
2017-05-09  7:03             ` Ludovic Courtès
2017-05-09  7:21               ` Danny Milosavljevic
2017-05-09  9:45                 ` Ludovic Courtès
2017-05-08 20:16           ` bug#26339: [PATCH] system: Remove circular dependency between (gnu system) and (gnu system grub) Danny Milosavljevic
2017-05-08 21:01             ` Danny Milosavljevic
2017-05-08 14:53       ` bug#26339: [PATCH v2 01/12] system: Pass <bootloader-parameter> to grub Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 02/12] system: Add extlinux support Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 03/12] scripts: system: Rename --no-grub option to --no-bootloader Mathieu Othacehe
2017-04-17 15:54     ` Danny Milosavljevic
2017-04-17  9:01   ` bug#26339: [PATCH v2 04/12] bootloader: Add install procedures and use them Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 05/12] system: Add bootloader type Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 06/12] bootloader: Stop using grub module Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 07/12] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 08/12] scripts: system: Remove unused variables Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 09/12] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 10/12] scripts: system: Adapt "init" " Mathieu Othacehe
2017-04-23  8:39     ` Danny Milosavljevic
2017-04-23  8:53       ` Danny Milosavljevic
2017-04-23 16:38         ` Mathieu Othacehe
2017-04-23 16:34       ` Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 11/12] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
2017-04-17  9:01   ` bug#26339: [PATCH v2 12/12] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
2017-05-06 15:41 ` bug#26339: [PATCH v3 0/9] Support non-grub bootloaders Mathieu Othacehe
2017-05-06 15:41   ` bug#26339: [PATCH v3 1/9] system: Add extlinux support Mathieu Othacehe
2017-05-07 16:41     ` Danny Milosavljevic
2017-05-07 20:01       ` Mathieu Othacehe
2017-05-06 15:41   ` bug#26339: [PATCH v3 2/9] bootloader: Add install procedures and use them Mathieu Othacehe
2017-05-07 16:52     ` Danny Milosavljevic
2017-05-06 15:41   ` bug#26339: [PATCH v3 3/9] system: Add bootloader type Mathieu Othacehe
2017-05-07 16:55     ` Danny Milosavljevic
2017-05-06 15:41   ` bug#26339: [PATCH v3 4/9] bootloader: Stop using grub module Mathieu Othacehe
2017-05-07 16:53     ` Danny Milosavljevic
2017-05-06 15:41   ` bug#26339: [PATCH v3 5/9] bootloader: Add device and type to bootloader-configuration record Mathieu Othacehe
2017-05-07 20:59     ` Danny Milosavljevic
2017-05-06 15:41   ` bug#26339: [PATCH v3 6/9] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
2017-05-07 20:33     ` Danny Milosavljevic
2017-05-07 20:56       ` Danny Milosavljevic
2017-05-08 16:24         ` Mathieu Othacehe
2017-05-08 16:21       ` Mathieu Othacehe
2017-05-07 21:14     ` Danny Milosavljevic
2017-05-08 16:27       ` Mathieu Othacehe
2017-05-06 15:41   ` bug#26339: [PATCH v3 7/9] scripts: system: Adapt "init" " Mathieu Othacehe
2017-05-07 21:08     ` Danny Milosavljevic
2017-05-08 16:26       ` Mathieu Othacehe
2017-05-06 15:41   ` bug#26339: [PATCH v3 8/9] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
2017-05-07 20:54     ` Danny Milosavljevic
2017-05-08 16:22       ` Mathieu Othacehe
2017-05-06 15:41   ` bug#26339: [PATCH v3 9/9] scripts: system: Display bootloader device and type in "list-generations" Mathieu Othacehe
2017-05-07 16:57     ` Danny Milosavljevic
2017-05-14  7:47 ` bug#26339: [PATCH v4 0/7] Support non grub bootloaders Mathieu Othacehe
2017-05-14  7:47   ` bug#26339: [PATCH v4 1/7] bootloader: Add extlinux support Mathieu Othacehe
2017-05-14  8:43     ` Danny Milosavljevic
2017-05-16 12:46       ` Mathieu Othacehe
2017-05-14 13:25     ` Ludovic Courtès
2017-05-16 12:51       ` Mathieu Othacehe
2017-05-16 14:38         ` Danny Milosavljevic
2017-05-16 14:50           ` Mathieu Othacehe
2017-05-16 15:00             ` Danny Milosavljevic
2017-05-16 15:03               ` Mathieu Othacehe
2017-05-14 13:35     ` Ludovic Courtès
2017-05-16 12:55       ` Mathieu Othacehe
2017-05-14  7:47   ` bug#26339: [PATCH v4 2/7] bootloader: Adapt vm to new bootloader API Mathieu Othacehe
2017-05-14  8:47     ` Danny Milosavljevic
2017-05-14 13:28     ` Ludovic Courtès
2017-05-14 14:59       ` Danny Milosavljevic
2017-05-14 19:53         ` Ludovic Courtès
2017-05-14  7:47   ` bug#26339: [PATCH v4 3/7] bootloader: Add bootloader name to boot-parameters record Mathieu Othacehe
2017-05-14  8:47     ` Danny Milosavljevic
2017-05-14 13:29       ` Ludovic Courtès
2017-05-14  7:48   ` bug#26339: [PATCH v4 4/7] scripts: system: Adapt "reconfigure" to new bootloader API Mathieu Othacehe
2017-05-14  8:50     ` Danny Milosavljevic
2017-05-14 13:31     ` Ludovic Courtès
2017-05-14  7:48   ` bug#26339: [PATCH v4 5/7] scripts: system: Adapt "init" " Mathieu Othacehe
2017-05-14  8:51     ` Danny Milosavljevic
2017-05-14 13:31       ` Ludovic Courtès
2017-05-14  7:48   ` bug#26339: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" " Mathieu Othacehe
2017-05-14  8:52     ` Danny Milosavljevic
2017-05-14 13:32       ` Ludovic Courtès
2017-05-14  8:54     ` Danny Milosavljevic
2017-05-16 12:46       ` Mathieu Othacehe
2017-05-14  7:48   ` bug#26339: [PATCH v4 7/7] scripts: system: Display bootloader name in "list-generations" Mathieu Othacehe
2017-05-14 13:33     ` Ludovic Courtès
2017-05-16 13:03 ` bug#26339: [PATCH] doc: Adapt to multiple bootloader support Mathieu Othacehe
2017-05-20 20:49   ` Danny Milosavljevic
2017-05-22  8:11     ` Mathieu Othacehe
2017-05-20 21:12   ` Tomáš Čech
2017-05-20 21:19     ` Mathieu Othacehe
2017-05-18 10:13 ` bug#26339: [PATCH] bootloader: extlinux: Add extlinux-bootloader-gpt Mathieu Othacehe
2017-06-12 20:23   ` [bug#26339] " Ludovic Courtès
2017-06-13 17:52     ` Mathieu Othacehe
2017-06-14  7:37       ` Ludovic Courtès
2017-06-13 14:34   ` Danny Milosavljevic
2017-05-18 10:26 ` bug#26339: [PATCH] tests: Add syslinux gpt test Mathieu Othacehe
2017-06-12 20:29   ` [bug#26339] " Ludovic Courtès
2017-06-19 16:55     ` Mathieu Othacehe
2017-06-20 20:13       ` Ludovic Courtès
2017-06-21  8:05         ` Mathieu Othacehe
2017-05-21 13:57 ` bug#26339: [PATCH] scripts: system: Handle unspecified bootloader package and installer Mathieu Othacehe
2017-06-12 20:32   ` [bug#26339] " Ludovic Courtès
2017-06-10  8:53 ` bug#26339: [PATCH] bootloader: Rename boot-name to bootloader-name Mathieu Othacehe
2017-06-10 14:26   ` Ludovic Courtès
2017-06-10 16:33     ` Mathieu Othacehe
2017-06-11  8:42     ` Mathieu Othacehe
2017-06-11  9:54       ` bug#26339: "extlinux", "extlinux" gpt, bootloader-configuration without package nor installer Danny Milosavljevic
2017-06-11 10:13         ` Danny Milosavljevic
2017-06-12  9:58         ` [bug#26339] " Mathieu Othacehe
2017-06-12 20:09           ` Ludovic Courtès
2017-06-12 20:20         ` Ludovic Courtès
2017-06-13  5:07           ` Danny Milosavljevic
2017-10-04 14:55             ` Ludovic Courtès
2017-10-04 19:56               ` Mathieu Othacehe
2017-10-13 14:08 ` bug#26339: closing bootloader serie Mathieu Othacehe
2017-10-13 15:31   ` [bug#26339] " Ludovic Courtès
2017-10-26  9:43     ` Mathieu Othacehe
2017-10-26 17:14       ` Ludovic Courtès
2017-10-26 17:33         ` Mathieu Othacehe
2017-10-26 22:20           ` Ludovic Courtès
2017-10-27  7:52             ` bug#26339: " Mathieu Othacehe
2017-10-29 15:47               ` Ludovic Courtès
2017-11-09 10:47                 ` GuixSD on armhf Mathieu Othacehe
2017-11-10 23:39                   ` Chris Marusich
2017-11-11 11:35                   ` Ludovic Courtès

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.