From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d02Yt-0000YE-LN for guix-patches@gnu.org; Mon, 17 Apr 2017 05:03:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d02Yq-0001Tr-Es for guix-patches@gnu.org; Mon, 17 Apr 2017 05:03:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:53305) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d02Yq-0001Tg-BB for guix-patches@gnu.org; Mon, 17 Apr 2017 05:03:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d02Yq-0005Qx-40 for guix-patches@gnu.org; Mon, 17 Apr 2017 05:03:04 -0400 Subject: bug#26339: [PATCH v2 05/12] system: Add bootloader type. Resent-Message-ID: From: Mathieu Othacehe Date: Mon, 17 Apr 2017 11:01:41 +0200 Message-Id: <20170417090148.13791-6-m.othacehe@gmail.com> In-Reply-To: <20170417090148.13791-1-m.othacehe@gmail.com> References: <20170417090148.13791-1-m.othacehe@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 26339@debbugs.gnu.org * gnu/system/bootloader.scm ()[type]: New field. (%extlinux-configuration, %grub-configuration, %grub-efi-configuration, %syslinux-configuration): New exported variables. (extlinux-configuration, grub-configuration, grub-efi-configuration, syslinux-configuration): New exported compatibility macros. --- gnu/system/bootloader.scm | 119 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 36 deletions(-) diff --git a/gnu/system/bootloader.scm b/gnu/system/bootloader.scm index fddf038b8..bab6cfab3 100644 --- a/gnu/system/bootloader.scm +++ b/gnu/system/bootloader.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 David Craven +;;; Copyright © 2017 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,10 +23,12 @@ #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix records) + #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (bootloader-configuration bootloader-configuration? bootloader-configuration-bootloader + bootloader-configuration-type bootloader-configuration-device bootloader-configuration-menu-entries bootloader-configuration-default-entry @@ -35,6 +38,13 @@ bootloader-configuration-installer bootloader-configuration-additional-configuration + %extlinux-configuration + %grub-configuration + %grub-efi-configuration + %syslinux-configuration + + lookup-bootloader-configuration + extlinux-configuration grub-configuration grub-efi-configuration @@ -54,6 +64,8 @@ bootloader-configuration? (bootloader bootloader-configuration-bootloader ; package (default #f)) + (type bootloader-configuration-type + (default #f)) ; symbol (device bootloader-configuration-device ; string (default #f)) (menu-entries bootloader-configuration-menu-entries ; list of @@ -126,43 +138,7 @@ TIMEOUT ~a~%" (gexp->derivation "extlinux.conf" builder)) - - - -;;; -;;; Bootloader configurations. -;;; - -(define* (extlinux-configuration #:optional (config (bootloader-configuration))) - (bootloader-configuration - (inherit config) - (configuration-file-name "/boot/extlinux/extlinux.conf") - (configuration-file-generator extlinux-configuration-file))) - -(define* (grub-configuration #:optional (config (bootloader-configuration))) - (bootloader-configuration - (inherit config) - (bootloader (@ (gnu packages bootloaders) grub)) - (configuration-file-name "/boot/grub/grub.cfg") - (configuration-file-generator grub-configuration-file) - (installer install-grub) - (additional-configuration - (let ((additional-config (bootloader-configuration-additional-configuration config))) - (if additional-config additional-config %default-theme))))) - -(define* (grub-efi-configuration #:optional (config (bootloader-configuration))) - (bootloader-configuration - (inherit (grub-configuration config)) - (bootloader (@ (gnu packages bootloaders) grub-efi)))) - -(define* (syslinux-configuration #:optional (config (bootloader-configuration))) - (bootloader-configuration - (inherit (extlinux-configuration config)) - (bootloader (@ (gnu packages bootloaders) syslinux)) - (installer install-syslinux))) - - ;;; ;;; Bootloader install procedures. ;;; @@ -204,4 +180,75 @@ TIMEOUT ~a~%" (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device)) (error "failed to install SYSLINUX"))))) + +;;; +;;; Bootloader configurations. +;;; + +(define* %extlinux-configuration + (bootloader-configuration + (type 'extlinux) + (configuration-file-name "/boot/extlinux/extlinux.conf") + (configuration-file-generator extlinux-configuration-file))) + +(define* %grub-configuration + (bootloader-configuration + (type 'grub) + (bootloader (@ (gnu packages bootloaders) grub)) + (configuration-file-name "/boot/grub/grub.cfg") + (configuration-file-generator grub-configuration-file) + (installer install-grub) + (additional-configuration %default-theme))) + +(define* %grub-efi-configuration + (bootloader-configuration + (inherit %grub-configuration) + (type 'grub-efi) + (bootloader (@ (gnu packages bootloaders) grub-efi)))) + +(define* %syslinux-configuration + (bootloader-configuration + (inherit %extlinux-configuration) + (type 'syslinux) + (bootloader (@ (gnu packages bootloaders) syslinux)) + (installer install-syslinux))) + +(define %bootloader-configurations + (list %extlinux-configuration + %grub-configuration + %grub-efi-configuration + %syslinux-configuration)) + +(define (lookup-bootloader-configuration type) + (or (find (lambda (conf) + (eq? (bootloader-configuration-type conf) + type)) + %bootloader-configurations) + (error "~a: unknown bootloader type" type))) + + +;;; +;;; Compatibility macros. +;;; + +(define-syntax-rule (extlinux-configuration fields ...) + (bootloader-configuration + (inherit %extlinux-configuration) + fields ...)) + +(define-syntax-rule (grub-configuration fields ...) + (bootloader-configuration + (inherit %grub-configuration) + fields ...)) + +(define-syntax-rule (grub-efi-configuration fields ...) + (bootloader-configuration + (inherit %grub-efi-configuration) + fields ...)) + +(define-syntax-rule (syslinux-configuration fields ...) + (bootloader-configuration + (inherit %syslinux-configuration) + fields ...)) + ;;; bootloader.scm ends here -- 2.12.2