image: Supply grub-efi from esp partition initializer.

Instead of passing down grub-efi in system-disk-image,
pass it down only where it's necessary - in esp partitions.

Since the esp partitions are only for grub, I renamed them
so that it's more clear to future users of them. They
do not check the bootloader of os at all, they always
initialize grub.

Followup of 1dfe1ebdf6,
fixing regression for mbr-hybrid images.

Fixes: #4538.

* guix/system/image.scm
(esp-partition/grub): Rename from esp-partition; Pass grub-efi to
initialize-efi-partition.
(esp32-partition/grub): Rename from esp32-partition; Pass grub32-efi to
initialize-efi-partition.
(esp-partition, (esp32-partition): Deprecate.
(system-disk-image): Do not supply grub-efi arguments.

Change-Id: I336c3144e8efc3ce872031e631d64d3708546ff8
Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
This commit is contained in:
Rutherther 2025-11-29 13:36:37 +01:00 committed by Efraim Flashner
parent 011a3b932d
commit ca0ed91b40
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351

View file

@ -23,6 +23,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu system image)
#:use-module (guix deprecation)
#:use-module (guix diagnostics)
#:use-module (guix discovery)
#:use-module (guix gexp)
@ -74,9 +75,12 @@
image-without-os
operating-system-for-image
esp-partition/grub
esp32-partition/grub
root-partition
esp-partition
esp32-partition
root-partition
mbr-disk-image
mbr-hybrid-disk-image
@ -125,21 +129,28 @@
parent image record."
(image (operating-system #false) . fields))
(define esp-partition
(define esp-partition/grub
(partition
(size (* 40 (expt 2 20)))
(offset root-offset)
(label "GNU-ESP") ;cosmetic only
;; Use "vfat" here since this property is used when mounting. The actual
;; FAT-ness is based on file system size (16 in this case).
(file-system "vfat")
(flags '(esp))
(initializer (gexp initialize-efi-partition))))
(size (* 40 (expt 2 20)))
(offset root-offset)
(label "GNU-ESP") ;cosmetic only
;; Use "vfat" here since this property is used when mounting. The actual
;; FAT-ness is based on file system size (16 in this case).
(file-system "vfat")
(flags '(esp))
(initializer #~(lambda* (root #:key #:allow-other-keys)
(initialize-efi-partition root #:grub-efi #+grub-efi)))))
(define esp32-partition
(define esp32-partition/grub
(partition
(inherit esp-partition)
(initializer (gexp initialize-efi32-partition))))
(inherit esp-partition/grub)
(initializer #~(lambda* (root #:key #:allow-other-keys)
(initialize-efi32-partition #:grub-efi32 #+grub-efi32)))))
;; Be more transparent. The esp partition unconditinally installs grub.
;; It doesn't look up bootloader of the system.
(define-deprecated/public-alias esp-partition esp-partition/grub)
(define-deprecated/public-alias esp32-partition esp32-partition/grub)
(define root-partition
(partition
@ -166,19 +177,19 @@ parent image record."
(format 'disk-image)
(partition-table-type 'mbr)
(partitions
(list esp-partition root-partition))))
(list esp-partition/grub root-partition))))
(define efi-disk-image
(image-without-os
(format 'disk-image)
(partition-table-type 'gpt)
(partitions (list esp-partition root-partition))))
(partitions (list esp-partition/grub root-partition))))
(define efi32-disk-image
(image-without-os
(format 'disk-image)
(partition-table-type 'gpt)
(partitions (list esp32-partition root-partition))))
(partitions (list esp32-partition/grub root-partition))))
(define iso9660-image
(image-without-os
@ -501,15 +512,6 @@ used in the image."
#:copy-closures? (not
#$(image-shared-store? image))
#:system-directory #$os
;; These two shouldn't be needed unconditionally.
#:grub-efi
#+(if (bootloader-uses-grub-efi? bootloader)
grub-efi
#f)
#:grub-efi32
#+(if (bootloader-uses-grub-efi? bootloader)
grub-efi32
#f)
#:bootloader-package
#+(bootloader-package bootloader)
#:bootloader-installer