gnu: bootloader: efi-bootloader-chain: Allow multiple HOOKS.

* gnu/bootloader.scm (efi-bootloader-profile): Allow multiple HOOKS.
(efi-bootloader-chain): Allow multiple HOOKS.

Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
This commit is contained in:
Stefan 2020-11-07 22:15:53 +01:00 committed by Danny Milosavljevic
parent 841bc2df97
commit ede4117f7f
No known key found for this signature in database
GPG key ID: E71A35542C30BAA5

View file

@ -232,7 +232,7 @@ (define (lookup-bootloader-by-name name)
(force %bootloaders)) (force %bootloaders))
(leave (G_ "~a: no such bootloader~%") name))) (leave (G_ "~a: no such bootloader~%") name)))
(define (efi-bootloader-profile files bootloader-package hook) (define (efi-bootloader-profile files bootloader-package hooks)
"Creates a profile with BOOTLOADER-PACKAGE and a directory collection/ with "Creates a profile with BOOTLOADER-PACKAGE and a directory collection/ with
links to additional FILES from the store. This collection is meant to be used links to additional FILES from the store. This collection is meant to be used
by the bootloader installer. by the bootloader installer.
@ -243,7 +243,9 @@ (define (efi-bootloader-profile files bootloader-package hook)
into the collection/ directory. into the collection/ directory.
FILES may contain file like objects produced by functions like plain-file, FILES may contain file like objects produced by functions like plain-file,
local-file, etc., or package contents produced with file-append." local-file, etc., or package contents produced with file-append.
HOOKS lists additional hook functions to modify the profile."
(define (bootloader-collection manifest) (define (bootloader-collection manifest)
(define build (define build
(with-imported-modules '((guix build utils) (with-imported-modules '((guix build utils)
@ -303,9 +305,8 @@ (define (name-is-store-entry? name)
(hook . bootloader-collection)))) (hook . bootloader-collection))))
(profile (content (packages->manifest (list bootloader-package))) (profile (content (packages->manifest (list bootloader-package)))
(name "efi-bootloader-profile") (name "bootloader-profile")
(hooks (append (list bootloader-collection) (hooks (append (list bootloader-collection) hooks))
(or hook '())))
(locales? #f) (locales? #f)
(allow-collisions? #f) (allow-collisions? #f)
(relative-symlinks? #f))) (relative-symlinks? #f)))
@ -313,7 +314,7 @@ (define (name-is-store-entry? name)
(define* (efi-bootloader-chain files (define* (efi-bootloader-chain files
final-bootloader final-bootloader
#:key #:key
hook (hooks '())
installer) installer)
"Define a bootloader chain with FINAL-BOOTLOADER as the final bootloader and "Define a bootloader chain with FINAL-BOOTLOADER as the final bootloader and
certain directories and files from the store given in the list of FILES. certain directories and files from the store given in the list of FILES.
@ -326,19 +327,18 @@ (define* (efi-bootloader-chain files
If a directory name in FILES ends with '/', then the directory content instead If a directory name in FILES ends with '/', then the directory content instead
of the directory itself will be symlinked into the collection/ directory. of the directory itself will be symlinked into the collection/ directory.
The PROFILE-HOOK function can be used to further modify the bootloader profile. The procedures in the HOOKS list can be used to further modify the bootloader
profile. It is possible to pass a single function instead of a list.
If the INSTALLER argument is used, then this function will be called to install If the INSTALLER argument is used, then this function will be called to install
the bootloader. Otherwise the installer of the FINAL-BOOTLOADER will be called. the bootloader. Otherwise the installer of the FINAL-BOOTLOADER will be called."
Independent of the INSTALLER argument, all files in the mentioned collection/
directory of the bootloader profile will be copied into the bootloader target
directory after the actual bootloader installer has been called."
(let* ((final-installer (or installer (let* ((final-installer (or installer
(bootloader-installer final-bootloader))) (bootloader-installer final-bootloader)))
(profile (efi-bootloader-profile files (profile (efi-bootloader-profile files
(bootloader-package final-bootloader) (bootloader-package final-bootloader)
hook))) (if (list? hooks)
hooks
(list hooks)))))
(bootloader (bootloader
(inherit final-bootloader) (inherit final-bootloader)
(package profile) (package profile)