2013-09-11 22:36:50 +02:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2014-01-29 13:04:00 +01:00
|
|
|
;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
|
2013-09-11 22:36:50 +02:00
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (gnu system grub)
|
|
|
|
#:use-module (guix store)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix derivations)
|
|
|
|
#:use-module (guix records)
|
gnu: vm: Rewrite helper functions as monadic functions.
* gnu/system/dmd.scm (host-name-service, nscd-service, mingetty-service,
syslog-service, guix-service, static-networking-service): Rewrite as
monadic functions.
(dmd-configuration-file): Use 'text-file' instead of
'add-text-to-store'.
* gnu/system/grub.scm (grub-configuration-file): Rewrite as a monadic
function.
* gnu/system/linux.scm (pam-services->directory): Likewise.
* gnu/system/shadow.scm (group-file, passwd-file, guix-build-accounts):
Likewise.
* gnu/system/vm.scm (expression->derivation-in-linux-vm, qemu-image,
union, system-qemu-image): Likewise.
2013-10-03 21:30:30 +02:00
|
|
|
#:use-module (guix monads)
|
2014-04-28 23:40:24 +02:00
|
|
|
#:use-module (guix gexp)
|
2013-09-11 22:36:50 +02:00
|
|
|
#:use-module (ice-9 match)
|
|
|
|
#:use-module (srfi srfi-1)
|
2014-05-18 21:58:01 +02:00
|
|
|
#:export (grub-configuration
|
|
|
|
grub-configuration?
|
|
|
|
grub-configuration-device
|
|
|
|
|
|
|
|
menu-entry
|
2013-09-11 22:36:50 +02:00
|
|
|
menu-entry?
|
2014-05-18 21:58:01 +02:00
|
|
|
|
2013-09-11 22:36:50 +02:00
|
|
|
grub-configuration-file))
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;;
|
|
|
|
;;; Configuration of GNU GRUB.
|
|
|
|
;;;
|
|
|
|
;;; Code:
|
|
|
|
|
2014-05-18 21:58:01 +02:00
|
|
|
(define-record-type* <grub-configuration>
|
|
|
|
grub-configuration make-grub-configuration
|
|
|
|
grub-configuration?
|
|
|
|
(grub grub-configuration-grub ; package
|
|
|
|
(default (@ (gnu packages grub) grub)))
|
|
|
|
(device grub-configuration-device) ; string
|
|
|
|
(menu-entries grub-configuration-menu-entries ; list
|
|
|
|
(default '()))
|
|
|
|
(default-entry grub-configuration-default-entry ; integer
|
2014-08-08 06:50:53 +02:00
|
|
|
(default 0))
|
2014-05-18 21:58:01 +02:00
|
|
|
(timeout grub-configuration-timeout ; integer
|
|
|
|
(default 5)))
|
|
|
|
|
2013-09-11 22:36:50 +02:00
|
|
|
(define-record-type* <menu-entry>
|
|
|
|
menu-entry make-menu-entry
|
|
|
|
menu-entry?
|
|
|
|
(label menu-entry-label)
|
|
|
|
(linux menu-entry-linux)
|
|
|
|
(linux-arguments menu-entry-linux-arguments
|
2014-04-28 23:40:24 +02:00
|
|
|
(default '())) ; list of string-valued gexps
|
|
|
|
(initrd menu-entry-initrd)) ; file name of the initrd as a gexp
|
2013-09-11 22:36:50 +02:00
|
|
|
|
2014-05-18 21:58:01 +02:00
|
|
|
(define* (grub-configuration-file config entries
|
2014-06-25 22:54:52 +02:00
|
|
|
#:key
|
|
|
|
(system (%current-system))
|
|
|
|
(old-entries '()))
|
2014-05-18 21:58:01 +02:00
|
|
|
"Return the GRUB configuration file corresponding to CONFIG, a
|
2014-06-25 22:54:52 +02:00
|
|
|
<grub-configuration> object. OLD-ENTRIES is taken to be a list of menu
|
|
|
|
entries corresponding to old generations of the system."
|
2014-05-18 21:58:01 +02:00
|
|
|
(define all-entries
|
|
|
|
(append entries (grub-configuration-menu-entries config)))
|
|
|
|
|
2014-04-28 23:40:24 +02:00
|
|
|
(define entry->gexp
|
2013-09-11 22:36:50 +02:00
|
|
|
(match-lambda
|
|
|
|
(($ <menu-entry> label linux arguments initrd)
|
2014-04-28 23:40:24 +02:00
|
|
|
#~(format port "menuentry ~s {
|
|
|
|
linux ~a/bzImage ~a
|
gnu: vm: Rewrite helper functions as monadic functions.
* gnu/system/dmd.scm (host-name-service, nscd-service, mingetty-service,
syslog-service, guix-service, static-networking-service): Rewrite as
monadic functions.
(dmd-configuration-file): Use 'text-file' instead of
'add-text-to-store'.
* gnu/system/grub.scm (grub-configuration-file): Rewrite as a monadic
function.
* gnu/system/linux.scm (pam-services->directory): Likewise.
* gnu/system/shadow.scm (group-file, passwd-file, guix-build-accounts):
Likewise.
* gnu/system/vm.scm (expression->derivation-in-linux-vm, qemu-image,
union, system-qemu-image): Likewise.
2013-10-03 21:30:30 +02:00
|
|
|
initrd ~a
|
2013-09-11 22:36:50 +02:00
|
|
|
}~%"
|
2014-04-28 23:40:24 +02:00
|
|
|
#$label
|
|
|
|
#$linux (string-join (list #$@arguments))
|
|
|
|
#$initrd))))
|
|
|
|
|
|
|
|
(define builder
|
|
|
|
#~(call-with-output-file #$output
|
|
|
|
(lambda (port)
|
|
|
|
(format port "
|
|
|
|
set default=~a
|
|
|
|
set timeout=~a
|
|
|
|
search.file ~a/bzImage~%"
|
2014-05-18 21:58:01 +02:00
|
|
|
#$(grub-configuration-default-entry config)
|
|
|
|
#$(grub-configuration-timeout config)
|
2014-04-28 23:40:24 +02:00
|
|
|
#$(any (match-lambda
|
|
|
|
(($ <menu-entry> _ linux)
|
|
|
|
linux))
|
2014-05-18 21:58:01 +02:00
|
|
|
all-entries))
|
2014-06-25 22:54:52 +02:00
|
|
|
#$@(map entry->gexp all-entries)
|
|
|
|
|
|
|
|
#$@(if (pair? old-entries)
|
|
|
|
#~((format port "
|
|
|
|
submenu \"GNU system, old configurations...\" {~%")
|
|
|
|
#$@(map entry->gexp old-entries)
|
|
|
|
(format port "}~%"))
|
|
|
|
#~()))))
|
2013-09-11 22:36:50 +02:00
|
|
|
|
2014-04-28 23:40:24 +02:00
|
|
|
(gexp->derivation "grub.cfg" builder))
|
2013-09-11 22:36:50 +02:00
|
|
|
|
|
|
|
;;; grub.scm ends here
|