From patchwork Fri Nov 16 09:36:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 223 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 167C616817; Fri, 16 Nov 2018 09:38:43 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id 6780E167E9 for ; Fri, 16 Nov 2018 09:38:42 +0000 (GMT) Received: from localhost ([::1]:43631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNaaH-00080G-1g for patchwork@mira.cbaines.net; Fri, 16 Nov 2018 04:38:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNaZj-0007FX-NQ for guix-patches@gnu.org; Fri, 16 Nov 2018 04:38:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNaZg-0003Cv-SJ for guix-patches@gnu.org; Fri, 16 Nov 2018 04:38:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50514) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNaZg-0003Ch-Ot for guix-patches@gnu.org; Fri, 16 Nov 2018 04:38:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gNaZg-00016l-KZ for guix-patches@gnu.org; Fri, 16 Nov 2018 04:38:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33405] [PATCH 03/10] linux-initrd: Return file-like objects instead of monadic values. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 16 Nov 2018 09:38:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33405 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33405@debbugs.gnu.org Received: via spool by 33405-submit@debbugs.gnu.org id=B33405.15423610314129 (code B ref 33405); Fri, 16 Nov 2018 09:38:04 +0000 Received: (at 33405) by debbugs.gnu.org; 16 Nov 2018 09:37:11 +0000 Received: from localhost ([127.0.0.1]:54760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gNaYo-00014O-MI for submit@debbugs.gnu.org; Fri, 16 Nov 2018 04:37:11 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55559) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gNaYf-00012L-Ds for 33405@debbugs.gnu.org; Fri, 16 Nov 2018 04:37:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNaYY-0002iR-7y for 33405@debbugs.gnu.org; Fri, 16 Nov 2018 04:36:56 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNaYR-0002dm-Mx; Fri, 16 Nov 2018 04:36:49 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=59268 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gNaYR-0004C1-FC; Fri, 16 Nov 2018 04:36:47 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 16 Nov 2018 10:36:17 +0100 Message-Id: <20181116093624.4820-3-ludo@gnu.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116093624.4820-1-ludo@gnu.org> References: <20181116093624.4820-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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. --- doc/guix.texi | 14 +++++++------- gnu/system.scm | 18 +++++++++--------- gnu/system/linux-initrd.scm | 13 ++++++------- gnu/system/vm.scm | 14 ++++++-------- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index cf3e95eb9f..439bbd7ef5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9860,7 +9860,7 @@ The list of Linux kernel modules that need to be available in the initial RAM disk. @xref{Initial RAM Disk}. @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 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 initial RAM disk -@deffn {Monadic Procedure} raw-initrd @var{file-systems} @ +@deffn {Scheme Procedure} raw-initrd @var{file-systems} @ [#:linux-modules '()] [#:mapped-devices '()] @ [#: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 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. @@ -21938,10 +21938,10 @@ When @var{volatile-root?} is true, the root file system is writable but any chan to it are lost. @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]@ [#: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 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 @@ -21961,9 +21961,9 @@ program. That gives a lot of flexibility. The @code{expression->initrd} procedure builds such an initrd, given the 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"] -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, upon booting. All the derivations referenced by @var{exp} are automatically copied to the initrd. 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) ; - (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 ." (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 . (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.