system: Adjust the set of fields with default values.
[jackhill/guix/guix.git] / gnu / system.scm
index 41ea59b..dc8f9ef 100644 (file)
@@ -59,6 +59,7 @@
             operating-system-timezone
             operating-system-locale
             operating-system-file-systems
+            operating-system-activation-script
 
             operating-system-derivation
             operating-system-profile
@@ -86,8 +87,7 @@
 
   (host-name operating-system-host-name)          ; string
 
-  (file-systems operating-system-file-systems     ; list of fs
-                (default '()))
+  (file-systems operating-system-file-systems)    ; list of fs
 
   (users operating-system-users                   ; list of user accounts
          (default '()))
             (default %base-packages))             ; or just PACKAGE
 
   (timezone operating-system-timezone)            ; string
-  (locale   operating-system-locale)              ; string
+  (locale   operating-system-locale               ; string
+            (default "en_US.UTF-8"))
 
   (services operating-system-user-services        ; list of monadic services
             (default %base-services))
@@ -218,7 +219,7 @@ explicitly appear in OS."
          guile-final (@ (gnu packages admin) dmd) guix
          util-linux inetutils isc-dhcp
          net-tools                        ; XXX: remove when Inetutils suffices
-         module-init-tools kbd
+         module-init-tools udev kbd
 
          ;; The packages below are also in %FINAL-INPUTS, so take them from
          ;; there to avoid duplication.
@@ -486,17 +487,22 @@ we're running in the final root."
       ((initrd ((operating-system-initrd os) boot-file-systems)))
     (return #~(string-append #$initrd "/initrd"))))
 
-(define (operating-system-grub.cfg os)
-  "Return the GRUB configuration file for OS."
+(define (kernel->grub-label kernel)
+  "Return a label for the GRUB menu entry that boots KERNEL."
+  (string-append "GNU system with "
+                 (string-titlecase (package-name kernel)) " "
+                 (package-version kernel)
+                 " (technology preview)"))
+
+(define* (operating-system-grub.cfg os #:optional (old-entries '()))
+  "Return the GRUB configuration file for OS.  Use OLD-ENTRIES to populate the
+\"old entries\" menu."
   (mlet* %store-monad
       ((system      (operating-system-derivation os))
        (root-fs ->  (operating-system-root-file-system os))
        (kernel ->   (operating-system-kernel os))
        (entries ->  (list (menu-entry
-                           (label (string-append
-                                   "GNU system with "
-                                   (package-full-name kernel)
-                                   " (technology preview)"))
+                           (label (kernel->grub-label kernel))
                            (linux kernel)
                            (linux-arguments
                             (list (string-append "--root="
@@ -505,7 +511,22 @@ we're running in the final root."
                                   #~(string-append "--load=" #$system
                                                    "/boot")))
                            (initrd #~(string-append #$system "/initrd"))))))
-    (grub-configuration-file (operating-system-bootloader os) entries)))
+    (grub-configuration-file (operating-system-bootloader os) entries
+                             #:old-entries old-entries)))
+
+(define (operating-system-parameters-file os)
+  "Return a file that describes the boot parameters of OS.  The primary use of
+this file is the reconstruction of GRUB menu entries for old configurations."
+  (mlet %store-monad ((initrd   (operating-system-initrd-file os))
+                      (root ->  (operating-system-root-file-system os))
+                      (label -> (kernel->grub-label
+                                 (operating-system-kernel os))))
+    (gexp->file "parameters"
+                #~(boot-parameters (version 0)
+                                   (label #$label)
+                                   (root-device #$(file-system-device root))
+                                   (kernel #$(operating-system-kernel os))
+                                   (initrd #$initrd)))))
 
 (define (operating-system-derivation os)
   "Return a derivation that builds OS."
@@ -514,10 +535,12 @@ we're running in the final root."
        (etc         (operating-system-etc-directory os))
        (boot        (operating-system-boot-script os))
        (kernel  ->  (operating-system-kernel os))
-       (initrd      (operating-system-initrd-file os)))
+       (initrd      (operating-system-initrd-file os))
+       (params      (operating-system-parameters-file os)))
     (file-union "system"
                 `(("boot" ,#~#$boot)
                   ("kernel" ,#~#$kernel)
+                  ("parameters" ,#~#$params)
                   ("initrd" ,initrd)
                   ("profile" ,#~#$profile)
                   ("etc" ,#~#$etc)))))