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.
This commit is contained in:
Ludovic Courtès 2018-11-15 18:39:18 +01:00
parent a7ef45d9de
commit e34ae75dc1
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
4 changed files with 28 additions and 31 deletions

View File

@ -9860,7 +9860,7 @@ The list of Linux kernel modules that need to be available in the
initial RAM disk. @xref{Initial RAM Disk}. initial RAM disk. @xref{Initial RAM Disk}.
@item @code{initrd} (default: @code{base-initrd}) @item @code{initrd} (default: @code{base-initrd})
A monadic procedure that returns an initial RAM disk for the Linux A procedure that returns an initial RAM disk for the Linux
kernel. This field is provided to support low-level customization and kernel. This field is provided to support low-level customization and
should rarely be needed for casual use. @xref{Initial RAM Disk}. should rarely be needed for casual use. @xref{Initial RAM Disk}.
@ -21917,10 +21917,10 @@ here is how to use it and customize it further.
@cindex initrd @cindex initrd
@cindex initial RAM disk @cindex initial RAM disk
@deffn {Monadic Procedure} raw-initrd @var{file-systems} @ @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
[#:linux-modules '()] [#:mapped-devices '()] @ [#:linux-modules '()] [#:mapped-devices '()] @
[#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f] [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
Return a monadic derivation that builds a raw initrd. @var{file-systems} is Return a derivation that builds a raw initrd. @var{file-systems} is
a list of file systems to be mounted by the initrd, possibly in addition to 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 @code{--root}. the root file system specified on the kernel command line via @code{--root}.
@var{linux-modules} is a list of kernel modules to be loaded at boot time. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
@ -21938,10 +21938,10 @@ When @var{volatile-root?} is true, the root file system is writable but any chan
to it are lost. to it are lost.
@end deffn @end deffn
@deffn {Monadic Procedure} base-initrd @var{file-systems} @ @deffn {Scheme Procedure} base-initrd @var{file-systems} @
[#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@ [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
[#:linux-modules '()] [#:linux-modules '()]
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 @var{linux}. @var{file-systems} is a list of file-systems to be modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
mounted by the initrd, possibly in addition to the root file system specified mounted by the initrd, possibly in addition to the root file system specified
on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device
@ -21961,9 +21961,9 @@ program. That gives a lot of flexibility. The
@code{expression->initrd} procedure builds such an initrd, given the @code{expression->initrd} procedure builds such an initrd, given the
program to run in that initrd. program to run in that initrd.
@deffn {Monadic Procedure} expression->initrd @var{exp} @ @deffn {Scheme Procedure} expression->initrd @var{exp} @
[#:guile %guile-static-stripped] [#:name "guile-initrd"] [#:guile %guile-static-stripped] [#:name "guile-initrd"]
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 @var{guile} and that evaluates @var{exp}, a G-expression, containing @var{guile} and that evaluates @var{exp}, a G-expression,
upon booting. All the derivations referenced by @var{exp} are upon booting. All the derivations referenced by @var{exp} are
automatically copied to the initrd. automatically copied to the initrd.

View File

@ -154,7 +154,7 @@
(default '())) ; list of gexps/strings (default '())) ; list of gexps/strings
(bootloader operating-system-bootloader) ; <bootloader-configuration> (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)) (default base-initrd))
(initrd-modules operating-system-initrd-modules ; list of strings (initrd-modules operating-system-initrd-modules ; list of strings
(thunked) ; it's system-dependent (thunked) ; it's system-dependent
@ -442,7 +442,7 @@ value of the SYSTEM-SERVICE-TYPE service."
(return `(("locale" ,locale))) (return `(("locale" ,locale)))
(mlet %store-monad (mlet %store-monad
((kernel -> (operating-system-kernel os)) ((kernel -> (operating-system-kernel os))
(initrd (operating-system-initrd-file os)) (initrd -> (operating-system-initrd-file os))
(params (operating-system-boot-parameters-file os))) (params (operating-system-boot-parameters-file os)))
(return `(("kernel" ,kernel) (return `(("kernel" ,kernel)
("parameters" ,params) ("parameters" ,params)
@ -870,12 +870,12 @@ hardware-related operations as necessary when booting a Linux container."
(define make-initrd (define make-initrd
(operating-system-initrd os)) (operating-system-initrd os))
(mlet %store-monad ((initrd (make-initrd boot-file-systems (let ((initrd (make-initrd boot-file-systems
#:linux (operating-system-kernel os) #:linux (operating-system-kernel os)
#:linux-modules #:linux-modules
(operating-system-initrd-modules os) (operating-system-initrd-modules os)
#:mapped-devices mapped-devices))) #:mapped-devices mapped-devices)))
(return (file-append initrd "/initrd")))) (file-append initrd "/initrd")))
(define (locale-name->definition* name) (define (locale-name->definition* name)
"Variant of 'locale-name->definition' that raises an error upon failure." "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 parameters of OS. When SYSTEM-KERNEL-ARGUMENTS? is true, add kernel arguments
such as '--root' and '--load' to <boot-parameters>." such as '--root' and '--load' to <boot-parameters>."
(mlet* %store-monad (mlet* %store-monad
((initrd (operating-system-initrd-file os)) ((initrd -> (operating-system-initrd-file os))
(store -> (operating-system-store-file-system os)) (store -> (operating-system-store-file-system os))
(bootloader -> (bootloader-configuration-bootloader (bootloader -> (bootloader-configuration-bootloader
(operating-system-bootloader os))) (operating-system-bootloader os)))

View File

@ -20,8 +20,6 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu system linux-initrd) (define-module (gnu system linux-initrd)
#:use-module (guix monads)
#:use-module (guix store)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module ((guix store) #:use-module ((guix store)
@ -63,7 +61,7 @@
(gzip gzip) (gzip gzip)
(name "guile-initrd") (name "guile-initrd")
(system (%current-system))) (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 containing GUILE and that evaluates EXP, a G-expression, upon booting. All
the derivations referenced by EXP are automatically copied to the initrd." 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") #:references-graphs '("closure")
#:gzip (string-append #$gzip "/bin/gzip"))))) #:gzip (string-append #$gzip "/bin/gzip")))))
(gexp->derivation name builder (computed-file name builder
#:references-graphs `(("closure" ,init)))) #:options
`(#:references-graphs (("closure" ,init)))))
(define (flat-linux-module-directory linux modules) (define (flat-linux-module-directory linux modules)
"Return a flat directory containing the Linux kernel modules listed in "Return a flat directory containing the Linux kernel modules listed in
@ -143,7 +142,7 @@ MODULES and taken from LINUX."
qemu-networking? qemu-networking?
volatile-root? volatile-root?
(on-error 'debug)) (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 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 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 on the kernel command line via '--root'. LINUX-MODULES is a list of kernel
@ -294,7 +293,7 @@ FILE-SYSTEMS."
volatile-root? volatile-root?
(extra-modules '()) ;deprecated (extra-modules '()) ;deprecated
(on-error 'debug)) (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 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 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 on the kernel command line via '--root'. MAPPED-DEVICES is a list of device

View File

@ -189,9 +189,7 @@ made available under the /xchg CIFS share."
#~(when (zero? (system* #$user-builder)) #~(when (zero? (system* #$user-builder))
(reboot)))) (reboot))))
(mlet* %store-monad (let ((initrd (or initrd
((initrd (if initrd ; use the default initrd?
(return initrd)
(base-initrd file-systems (base-initrd file-systems
#:on-error 'backtrace #:on-error 'backtrace
#:linux linux #:linux linux