Remove traces of "GuixSD".
[jackhill/guix/guix.git] / gnu / bootloader / extlinux.scm
index 67b8815..2bb711e 100644 (file)
 
 (define-module (gnu bootloader extlinux)
   #:use-module (gnu bootloader)
-  #:use-module (gnu system)
   #:use-module (gnu packages bootloaders)
   #:use-module (guix gexp)
-  #:use-module (guix monads)
-  #:use-module (guix records)
   #:use-module (guix utils)
-  #:export (extlinux-bootloader))
+  #:export (extlinux-bootloader
+            extlinux-bootloader-gpt))
 
 (define* (extlinux-configuration-file config entries
                                       #:key
@@ -39,11 +37,11 @@ corresponding to old generations of the system."
   (define all-entries
     (append entries (bootloader-configuration-menu-entries config)))
 
-  (define (boot-parameters->gexp params)
-    (let ((label (boot-parameters-label params))
-          (kernel (boot-parameters-kernel params))
-          (kernel-arguments (boot-parameters-kernel-arguments params))
-          (initrd (boot-parameters-initrd params)))
+  (define (menu-entry->gexp entry)
+    (let ((label (menu-entry-label entry))
+          (kernel (menu-entry-linux entry))
+          (kernel-arguments (menu-entry-linux-arguments entry))
+          (initrd (menu-entry-initrd entry)))
       #~(format port "LABEL ~a
   MENU LABEL ~a
   KERNEL ~a
@@ -52,30 +50,31 @@ corresponding to old generations of the system."
   APPEND ~a
 ~%"
                 #$label #$label
-                #$kernel #$kernel #$initrd
+                #$kernel (dirname #$kernel) #$initrd
                 (string-join (list #$@kernel-arguments)))))
 
   (define builder
     #~(call-with-output-file #$output
         (lambda (port)
           (let ((timeout #$(bootloader-configuration-timeout config)))
-            (format port "# This file was generated from your GuixSD configuration.  Any changes
+            (format port "# This file was generated from your Guix configuration.  Any changes
 # will be lost upon reconfiguration.
 UI menu.c32
+MENU TITLE GNU Guix Boot Options
 PROMPT ~a
 TIMEOUT ~a~%"
                     (if (> timeout 0) 1 0)
                     ;; timeout is expressed in 1/10s of seconds.
                     (* 10 timeout))
-            #$@(map boot-parameters->gexp all-entries)
+            #$@(map menu-entry->gexp all-entries)
 
             #$@(if (pair? old-entries)
                    #~((format port "~%")
-                      #$@(map boot-parameters->gexp old-entries)
+                      #$@(map menu-entry->gexp old-entries)
                       (format port "~%"))
                    #~())))))
 
-  (gexp->derivation "extlinux.conf" builder))
+  (computed-file "extlinux.conf" builder))
 
 
 \f
@@ -84,15 +83,7 @@ TIMEOUT ~a~%"
 ;;; Install procedures.
 ;;;
 
-(define dd
-  #~(lambda (bs count if of)
-      (zero? (system* "dd"
-                      (string-append "bs=" (number->string bs))
-                      (string-append "count=" (number->string count))
-                      (string-append "if=" if)
-                      (string-append "of=" of)))))
-
-(define install-extlinux
+(define (install-extlinux mbr)
   #~(lambda (bootloader device mount-point)
       (let ((extlinux (string-append bootloader "/sbin/extlinux"))
             (install-dir (string-append mount-point "/boot/extlinux"))
@@ -100,11 +91,18 @@ TIMEOUT ~a~%"
         (for-each (lambda (file)
                     (install-file file install-dir))
                   (find-files syslinux-dir "\\.c32$"))
-
-        (unless (and (zero? (system* extlinux "--install" install-dir))
-                     (#$dd 440 1 (string-append syslinux-dir "/mbr.bin") device))
+        (unless
+            (and (zero? (system* extlinux "--install" install-dir))
+                 (write-file-on-device
+                  (string-append syslinux-dir "/" #$mbr) 440 device 0))
           (error "failed to install SYSLINUX")))))
 
+(define install-extlinux-mbr
+  (install-extlinux "mbr.bin"))
+
+(define install-extlinux-gpt
+  (install-extlinux "gptmbr.bin"))
+
 \f
 
 ;;;
@@ -115,6 +113,11 @@ TIMEOUT ~a~%"
   (bootloader
    (name 'extlinux)
    (package syslinux)
-   (installer install-extlinux)
+   (installer install-extlinux-mbr)
    (configuration-file "/boot/extlinux/extlinux.conf")
    (configuration-file-generator extlinux-configuration-file)))
+
+(define extlinux-bootloader-gpt
+  (bootloader
+   (inherit extlinux-bootloader)
+   (installer install-extlinux-gpt)))