Subject: [PATCH] image: Add mbr-raw-image-type and use by default.

From: Josselin Poiret <[email-masked]>
Date: Thu, 27 Jul 2023 18:35:08 +0200

From: Josselin Poiret <[email-masked]>

* gnu/system/image.scm (mbr-disk-image, mbr-raw-image-type): New variables.
* guix/scripts/system.scm (%default-options): Use mbr-raw-image-type by
default.
---

How about this for now?  I think the bootloader/image-type situation is not
clear, but at least this keeps the behavior of the previous default option.

 gnu/system/image.scm    | 16 ++++++++++++++++
 guix/scripts/system.scm |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 841e7e0c7e..92e659753e 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -76,6 +76,7 @@ (define-module (gnu system image)
             esp32-partition
             root-partition
 
+            mbr-disk-image
             efi-disk-image
             iso9660-image
             docker-image
@@ -84,6 +85,7 @@ (define-module (gnu system image)
             raw-with-offset-disk-image
 
             image-with-os
+            mbr-raw-image-type
             efi-raw-image-type
             efi32-raw-image-type
             qcow2-image-type
@@ -145,6 +147,15 @@ (define root-partition
    (flags '(boot))
    (initializer (gexp initialize-root-partition))))
 
+(define mbr-disk-image
+  (image-without-os
+   (format 'disk-image)
+   (partition-table-type 'mbr)
+   (partitions
+    (list (partition
+           (inherit root-partition)
+           (offset root-offset))))))
+
 (define efi-disk-image
   (image-without-os
    (format 'disk-image)
@@ -201,6 +212,11 @@ (define-syntax-rule (image-with-os base-image os)
    (inherit base-image)
    (operating-system os)))
 
+(define mbr-raw-image-type
+  (image-type
+   (name 'mbr-raw)
+   (constructor (cut image-with-os mbr-disk-image <>))))
+
 (define efi-raw-image-type
   (image-type
    (name 'efi-raw)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index d7163dd3eb..95c68a5f33 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -1168,7 +1168,7 @@ (define %default-options
     (debug . 0)
     (verbosity . #f)                              ;default
     (validate-reconfigure . ,ensure-forward-reconfigure)
-    (image-type . efi-raw)
+    (image-type . mbr-raw)
     (image-size . guess)
     (install-bootloader? . #t)
     (label . #f)

base-commit: c7e45139faa27b60f2c7d0a4bc140f9793d97d47
-- 
2.41.0