summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-11-15 18:39:18 +0100
committerLudovic Courtès <ludo@gnu.org>2018-11-18 23:37:44 +0100
commite34ae75dc14acb97f661a2787a3c626d7ce65b24 (patch)
tree54735b47e5ba6745355e26359ad4e4b7e36454b5 /gnu
parenta7ef45d9de8c6b0d584769404c8754cd3da8fe29 (diff)
downloadguix-e34ae75dc14acb97f661a2787a3c626d7ce65b24.tar.gz
linux-initrd: Return file-like objects instead of monadic values.
This is an incompatible change visible to users via the 'initrd' field
of 'operating-system'.  However, assuming the user's 'initrd' value
tail-calls to 'raw-initrd' or 'base-initrd', the switch to non-monadic
style is invisible.

* gnu/system/linux-initrd.scm (expression->initrd): Use 'computed-file'
instead of 'gexp->derivation'.
(raw-initrd, base-initrd): Adjust docstring to mention non-monadic
return.
* gnu/system/vm.scm (expression->derivation-in-linux-vm): Adjust
accordingly.
* gnu/system.scm (operating-system-directory-base-entries)
(operating-system-initrd-file)
(operating-system-boot-parameters): Adjust accordingly.
* doc/guix.texi (operating-system Reference)
(Initial RAM Disk): Update.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/system.scm18
-rw-r--r--gnu/system/linux-initrd.scm13
-rw-r--r--gnu/system/vm.scm14
3 files changed, 21 insertions, 24 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index b218efc875..4ea9391c4a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -154,7 +154,7 @@
                     (default '()))                ; list of gexps/strings
   (bootloader operating-system-bootloader)        ; <bootloader-configuration>
 
-  (initrd operating-system-initrd                 ; (list fs) -> M derivation
+  (initrd operating-system-initrd                 ; (list fs) -> file-like
           (default base-initrd))
   (initrd-modules operating-system-initrd-modules ; list of strings
                   (thunked)                       ; it's system-dependent
@@ -442,7 +442,7 @@ value of the SYSTEM-SERVICE-TYPE service."
           (return `(("locale" ,locale)))
           (mlet %store-monad
               ((kernel  ->  (operating-system-kernel os))
-               (initrd      (operating-system-initrd-file os))
+               (initrd  ->  (operating-system-initrd-file os))
                (params      (operating-system-boot-parameters-file os)))
             (return `(("kernel" ,kernel)
                       ("parameters" ,params)
@@ -870,12 +870,12 @@ hardware-related operations as necessary when booting a Linux container."
   (define make-initrd
     (operating-system-initrd os))
 
-  (mlet %store-monad ((initrd (make-initrd boot-file-systems
-                                           #:linux (operating-system-kernel os)
-                                           #:linux-modules
-                                           (operating-system-initrd-modules os)
-                                           #:mapped-devices mapped-devices)))
-    (return (file-append initrd "/initrd"))))
+  (let ((initrd (make-initrd boot-file-systems
+                             #:linux (operating-system-kernel os)
+                             #:linux-modules
+                             (operating-system-initrd-modules os)
+                             #:mapped-devices mapped-devices)))
+    (file-append initrd "/initrd")))
 
 (define (locale-name->definition* name)
   "Variant of 'locale-name->definition' that raises an error upon failure."
@@ -957,7 +957,7 @@ listed in OS.  The C library expects to find it under
 parameters of OS.  When SYSTEM-KERNEL-ARGUMENTS? is true, add kernel arguments
 such as '--root' and '--load' to <boot-parameters>."
   (mlet* %store-monad
-      ((initrd (operating-system-initrd-file os))
+      ((initrd -> (operating-system-initrd-file os))
        (store -> (operating-system-store-file-system os))
        (bootloader  -> (bootloader-configuration-bootloader
                         (operating-system-bootloader os)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index a5a111908f..a53d3cb106 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -20,8 +20,6 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu system linux-initrd)
-  #:use-module (guix monads)
-  #:use-module (guix store)
   #:use-module (guix gexp)
   #:use-module (guix utils)
   #:use-module ((guix store)
@@ -63,7 +61,7 @@
                              (gzip gzip)
                              (name "guile-initrd")
                              (system (%current-system)))
-  "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
+  "Return as a file-like object a Linux initrd (a gzipped cpio archive)
 containing GUILE and that evaluates EXP, a G-expression, upon booting.  All
 the derivations referenced by EXP are automatically copied to the initrd."
 
@@ -100,8 +98,9 @@ the derivations referenced by EXP are automatically copied to the initrd."
                         #:references-graphs '("closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
 
-  (gexp->derivation name builder
-                    #:references-graphs `(("closure" ,init))))
+  (computed-file name builder
+                 #:options
+                 `(#:references-graphs (("closure" ,init)))))
 
 (define (flat-linux-module-directory linux modules)
   "Return a flat directory containing the Linux kernel modules listed in
@@ -143,7 +142,7 @@ MODULES and taken from LINUX."
                       qemu-networking?
                       volatile-root?
                       (on-error 'debug))
-  "Return a monadic derivation that builds a raw initrd, with kernel
+  "Return as a file-like object a raw initrd, with kernel
 modules taken from LINUX.  FILE-SYSTEMS is a list of file-systems to be
 mounted by the initrd, possibly in addition to the root file system specified
 on the kernel command line via '--root'. LINUX-MODULES is a list of kernel
@@ -294,7 +293,7 @@ FILE-SYSTEMS."
                       volatile-root?
                       (extra-modules '())         ;deprecated
                       (on-error 'debug))
-  "Return a monadic derivation that builds a generic initrd, with kernel
+  "Return as a file-like object a generic initrd, with kernel
 modules taken from LINUX.  FILE-SYSTEMS is a list of file-systems to be
 mounted by the initrd, possibly in addition to the root file system specified
 on the kernel command line via '--root'.  MAPPED-DEVICES is a list of device
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index d43b71cbaf..6064e0f899 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -189,14 +189,12 @@ made available under the /xchg CIFS share."
                   #~(when (zero? (system* #$user-builder))
                       (reboot))))
 
-  (mlet* %store-monad
-      ((initrd       (if initrd                   ; use the default initrd?
-                         (return initrd)
-                         (base-initrd file-systems
-                                      #:on-error 'backtrace
-                                      #:linux linux
-                                      #:linux-modules %base-initrd-modules
-                                      #:qemu-networking? #t))))
+  (let ((initrd (or initrd
+                    (base-initrd file-systems
+                                 #:on-error 'backtrace
+                                 #:linux linux
+                                 #:linux-modules %base-initrd-modules
+                                 #:qemu-networking? #t))))
 
     (define builder
       ;; Code that launches the VM that evaluates EXP.