@@ 4,8 4,7 @@
#:use-module (gnu bootloader grub)
#:use-module (gnu packages bootloaders)
#:use-module (guix utils)
- #:use-module (gnu system locale)
- )
+ #:use-module (gnu system locale))
(define install-grub-efi-copy
(with-imported-modules '((guix build utils))
@@ 135,3 134,36 @@
(disk-image-installer #f)
(configuration-file (@@ (gnu bootloader grub) grub-cfg))
(configuration-file-generator grub-copy-configuration-file)))
+
+(define* (grub-lvm-configuration-file config entries
+ #:key
+ (locale #f)
+ (system (%current-system))
+ (old-entries '())
+ (store-crypto-devices '())
+ store-directory-prefix)
+ (let* ((original-grub-cfg
+ ((@@ (gnu bootloader grub) make-grub-configuration)
+ grub-efi config entries
+ #:locale locale
+ #:system system
+ #:old-entries old-entries
+ #:store-crypto-devices store-crypto-devices
+ #:store-directory-prefix store-directory-prefix))
+
+ (builder
+ #~(call-with-output-file #$output
+ (lambda (port)
+ (use-modules (ice-9 textual-ports))
+ ;; Sneek in insmod lvm at beginning of the file
+ (display "insmod lvm\n" port)
+ ;; After, copy the original file.
+ (display (call-with-input-file #$original-grub-cfg get-string-all) port)))))
+ (computed-file "grub.cfg" builder
+ #:options '(#:local-build? #t
+ #:substitutable? #f))))
+
+(define-public grub-lvm-bootloader
+ (bootloader
+ (inherit grub-efi-removable-bootloader)
+ (configuration-file-generator grub-lvm-configuration-file)))