| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 |
|
| 21 | (define-module (gnu bootloader)
|
| 22 | #:use-module (guix discovery)
|
| 23 | #:use-module (guix records)
|
| 24 | #:use-module (guix ui)
|
| 25 | #:use-module (srfi srfi-1)
|
| 26 | #:export (menu-entry
|
| 27 | menu-entry?
|
| 28 | menu-entry-label
|
| 29 | menu-entry-device
|
| 30 | menu-entry-linux
|
| 31 | menu-entry-linux-arguments
|
| 32 | menu-entry-initrd
|
| 33 | menu-entry-device-mount-point
|
| 34 |
|
| 35 | bootloader
|
| 36 | bootloader?
|
| 37 | bootloader-name
|
| 38 | bootloader-package
|
| 39 | bootloader-installer
|
| 40 | bootloader-configuration-file
|
| 41 | bootloader-configuration-file-generator
|
| 42 |
|
| 43 | bootloader-configuration
|
| 44 | bootloader-configuration?
|
| 45 | bootloader-configuration-bootloader
|
| 46 | bootloader-configuration-target
|
| 47 | bootloader-configuration-menu-entries
|
| 48 | bootloader-configuration-default-entry
|
| 49 | bootloader-configuration-timeout
|
| 50 | bootloader-configuration-theme
|
| 51 | bootloader-configuration-terminal-outputs
|
| 52 | bootloader-configuration-terminal-inputs
|
| 53 | bootloader-configuration-serial-unit
|
| 54 | bootloader-configuration-serial-speed
|
| 55 | bootloader-configuration-additional-configuration
|
| 56 |
|
| 57 | %bootloaders
|
| 58 | lookup-bootloader-by-name))
|
| 59 |
|
| 60 |
|
| 61 | |
| 62 | |
| 63 | |
| 64 |
|
| 65 | (define-record-type* <menu-entry>
|
| 66 | menu-entry make-menu-entry
|
| 67 | menu-entry?
|
| 68 | (label menu-entry-label)
|
| 69 | (device menu-entry-device |
| 70 | (default #f))
|
| 71 | (device-mount-point menu-entry-device-mount-point
|
| 72 | (default #f))
|
| 73 | (linux menu-entry-linux)
|
| 74 | (linux-arguments menu-entry-linux-arguments
|
| 75 | (default '())) |
| 76 | (initrd menu-entry-initrd)) |
| 77 |
|
| 78 |
|
| 79 | |
| 80 | |
| 81 | |
| 82 |
|
| 83 | |
| 84 | |
| 85 | |
| 86 |
|
| 87 | (define-record-type* <bootloader>
|
| 88 | bootloader make-bootloader
|
| 89 | bootloader?
|
| 90 | (name bootloader-name)
|
| 91 | (package bootloader-package)
|
| 92 | (installer bootloader-installer)
|
| 93 | (configuration-file bootloader-configuration-file)
|
| 94 | (configuration-file-generator bootloader-configuration-file-generator))
|
| 95 |
|
| 96 |
|
| 97 | |
| 98 | |
| 99 | |
| 100 |
|
| 101 | |
| 102 | |
| 103 |
|
| 104 | (define-record-type* <bootloader-configuration>
|
| 105 | bootloader-configuration make-bootloader-configuration
|
| 106 | bootloader-configuration?
|
| 107 | (bootloader bootloader-configuration-bootloader) |
| 108 | (device bootloader-configuration-device |
| 109 | (default #f))
|
| 110 | (target %bootloader-configuration-target |
| 111 | (default #f))
|
| 112 | (menu-entries bootloader-configuration-menu-entries |
| 113 | (default '()))
|
| 114 | (default-entry bootloader-configuration-default-entry |
| 115 | (default 0))
|
| 116 | (timeout bootloader-configuration-timeout |
| 117 | (default 5))
|
| 118 | (theme bootloader-configuration-theme |
| 119 | (default #f))
|
| 120 | (terminal-outputs bootloader-configuration-terminal-outputs |
| 121 | (default '(gfxterm)))
|
| 122 | (terminal-inputs bootloader-configuration-terminal-inputs |
| 123 | (default '()))
|
| 124 | (serial-unit bootloader-configuration-serial-unit |
| 125 | (default #f))
|
| 126 | (serial-speed bootloader-configuration-serial-speed |
| 127 | (default #f))
|
| 128 | (additional-configuration bootloader-configuration-additional-configuration |
| 129 | (default #f)))
|
| 130 |
|
| 131 | (define (bootloader-configuration-target config)
|
| 132 | (or (%bootloader-configuration-target config)
|
| 133 | (let ((device (bootloader-configuration-device config)))
|
| 134 | (when device
|
| 135 | (warning
|
| 136 | (G_ "The 'device' field of bootloader configurations is deprecated.~%"))
|
| 137 | (warning (G_ "Use 'target' instead.~%")))
|
| 138 | device)))
|
| 139 |
|
| 140 |
|
| 141 | |
| 142 | |
| 143 | |
| 144 |
|
| 145 | (define (bootloader-modules)
|
| 146 | "Return the list of bootloader modules."
|
| 147 | (all-modules (map (lambda (entry)
|
| 148 | `(,entry . "gnu/bootloader"))
|
| 149 | %load-path)))
|
| 150 |
|
| 151 | (define %bootloaders
|
| 152 | |
| 153 | (delay (fold-module-public-variables (lambda (obj result)
|
| 154 | (if (bootloader? obj)
|
| 155 | (cons obj result)
|
| 156 | result))
|
| 157 | '()
|
| 158 | (bootloader-modules))))
|
| 159 |
|
| 160 | (define (lookup-bootloader-by-name name)
|
| 161 | "Return the bootloader called NAME."
|
| 162 | (or (find (lambda (bootloader)
|
| 163 | (eq? name (bootloader-name bootloader)))
|
| 164 | (force %bootloaders))
|
| 165 | (leave (G_ "~a: no such bootloader~%") name)))
|