X-Git-Url: https://git.hcoop.net/jackhill/guix/guix.git/blobdiff_plain/571fb008a576378883c053be186d2c620290ea39..6616b22b12f682955610bed800e3497e0cdc801b:/gnu/bootloader.scm diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index a381f67145..01bdd4acaa 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2017 David Craven ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2017 Leo Famulari +;;; Copyright © 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,6 +24,7 @@ #:use-module (guix records) #:use-module (guix ui) #:use-module (srfi srfi-1) + #:use-module (ice-9 match) #:export (menu-entry menu-entry? menu-entry-label @@ -32,6 +34,9 @@ menu-entry-initrd menu-entry-device-mount-point + menu-entry->sexp + sexp->menu-entry + bootloader bootloader? bootloader-name @@ -76,6 +81,35 @@ (default '())) ; list of string-valued gexps (initrd menu-entry-initrd)) ; file name of the initrd as a gexp +(define (menu-entry->sexp entry) + "Return ENTRY serialized as an sexp." + (match entry + (($ label device mount-point linux linux-arguments initrd) + `(menu-entry (version 0) + (label ,label) + (device ,device) + (device-mount-point ,mount-point) + (linux ,linux) + (linux-arguments ,linux-arguments) + (initrd ,initrd))))) + +(define (sexp->menu-entry sexp) + "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a +record." + (match sexp + (('menu-entry ('version 0) + ('label label) ('device device) + ('device-mount-point mount-point) + ('linux linux) ('linux-arguments linux-arguments) + ('initrd initrd) _ ...) + (menu-entry + (label label) + (device device) + (device-mount-point mount-point) + (linux linux) + (linux-arguments linux-arguments) + (initrd initrd))))) + ;;; ;;; Bootloader record. @@ -108,7 +142,7 @@ (bootloader bootloader-configuration-bootloader) ; (target bootloader-configuration-target ;string (default #f)) - (menu-entries bootloader-configuration-menu-entries ;list of + (menu-entries bootloader-configuration-menu-entries ;list of (default '())) (default-entry bootloader-configuration-default-entry ;integer (default 0))