unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 33405@debbugs.gnu.org
Subject: [bug#33405] [PATCH 09/10] guix system: De-monadify bootloader installation script.
Date: Fri, 16 Nov 2018 10:36:23 +0100	[thread overview]
Message-ID: <20181116093624.4820-9-ludo@gnu.org> (raw)
In-Reply-To: <20181116093624.4820-1-ludo@gnu.org>

* guix/scripts/system.scm (bootloader-installer-derivation): Rename
to...
(bootloader-installer-script): ... this.  Use 'scheme-file' instead of
'gexp->file'.
(perform-action): Adjust accordingly.  Move 'lower-object' call to the
point where DRVS is computed.
---
 guix/scripts/system.scm | 65 +++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 31 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 14488107b8..6f00f12509 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -175,12 +175,16 @@ TARGET, and register them."
 
     (return *unspecified*)))
 
-(define* (install-bootloader installer-drv
+(define* (install-bootloader installer
                              #:key
                              bootcfg bootcfg-file
                              target)
-  "Call INSTALLER-DRV with error handling, in %STORE-MONAD."
-  (with-monad %store-monad
+  "Run INSTALLER, a bootloader installation script, with error handling, in
+%STORE-MONAD."
+  (mlet %store-monad ((installer-drv (if installer
+                                         (lower-object installer)
+                                         (return #f)))
+                      (bootcfg       (lower-object bootcfg)))
     (let* ((gc-root      (string-append target %gc-roots-directory
                                         "/bootcfg"))
            (temp-gc-root (string-append gc-root ".new"))
@@ -790,19 +794,18 @@ checking this by themselves in their 'check' procedure."
     (warning (G_ "Consider running 'guix pull' before 'reconfigure'.~%"))
     (warning (G_ "Failing to do that may downgrade your system!~%"))))
 
-(define (bootloader-installer-derivation installer
-                                         bootloader device target)
+(define (bootloader-installer-script installer
+                                     bootloader device target)
   "Return a file calling INSTALLER gexp with given BOOTLOADER, DEVICE
 and TARGET arguments."
-  (with-monad %store-monad
-    (gexp->file "bootloader-installer"
-                (with-imported-modules '((gnu build bootloader)
-                                         (guix build utils))
-                  #~(begin
-                      (use-modules (gnu build bootloader)
-                                   (guix build utils)
-                                   (ice-9 binary-ports))
-                      (#$installer #$bootloader #$device #$target))))))
+  (scheme-file "bootloader-installer"
+               (with-imported-modules '((gnu build bootloader)
+                                        (guix build utils))
+                 #~(begin
+                     (use-modules (gnu build bootloader)
+                                  (guix build utils)
+                                  (ice-9 binary-ports))
+                     (#$installer #$bootloader #$device #$target)))))
 
 (define* (perform-action action os
                          #:key skip-safety-checks?
@@ -851,31 +854,31 @@ static checks."
                                                 #:mappings mappings))
        (bootloader -> (bootloader-configuration-bootloader
                        (operating-system-bootloader os)))
-       (bootcfg  (if (eq? 'container action)
-                     (return #f)
-                     (lower-object
-                      (operating-system-bootcfg
-                       os
-                       (if (eq? 'init action)
-                           '()
-                           (map boot-parameters->menu-entry
-                                (profile-boot-parameters)))))))
+       (bootcfg -> (and (not (eq? 'container action))
+                        (operating-system-bootcfg
+                         os
+                         (if (eq? 'init action)
+                             '()
+                             (map boot-parameters->menu-entry
+                                  (profile-boot-parameters))))))
        (bootcfg-file -> (bootloader-configuration-file bootloader))
        (bootloader-installer
+        ->
         (let ((installer (bootloader-installer bootloader))
               (target    (or target "/")))
-          (bootloader-installer-derivation installer
-                                           (bootloader-package bootloader)
-                                           bootloader-target target)))
+          (bootloader-installer-script installer
+                                       (bootloader-package bootloader)
+                                       bootloader-target target)))
 
        ;; For 'init' and 'reconfigure', always build BOOTCFG, even if
        ;; --no-bootloader is passed, because we then use it as a GC root.
        ;; See <http://bugs.gnu.org/21068>.
-       (drvs   -> (if (memq action '(init reconfigure))
-                      (if install-bootloader?
-                          (list sys bootcfg bootloader-installer)
-                          (list sys bootcfg))
-                      (list sys)))
+       (drvs      (mapm %store-monad lower-object
+                        (if (memq action '(init reconfigure))
+                            (if install-bootloader?
+                                (list sys bootcfg bootloader-installer)
+                                (list sys bootcfg))
+                            (list sys))))
        (%         (if derivations-only?
                       (return (for-each (compose println derivation-file-name)
                                         drvs))
-- 
2.19.1

  parent reply	other threads:[~2018-11-16  9:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16  9:21 [bug#33405] [PATCH 00/10] De-monadify and clean up system code Ludovic Courtès
2018-11-16  9:36 ` [bug#33405] [PATCH 01/10] bootloader: De-monadify configuration file generators Ludovic Courtès
2018-11-16  9:36   ` [bug#33405] [PATCH 02/10] system: Simplify kernel argument handling Ludovic Courtès
2018-11-16  9:36   ` [bug#33405] [PATCH 03/10] linux-initrd: Return file-like objects instead of monadic values Ludovic Courtès
2018-11-16  9:36   ` [bug#33405] [PATCH 04/10] system: De-monadify 'operating-system-boot-parameters' Ludovic Courtès
2018-11-16  9:36   ` [bug#33405] [PATCH 05/10] system: Please Emacs Ludovic Courtès
2018-11-16  9:36   ` [bug#33405] [PATCH 06/10] system: De-monadify 'operating-system-bootcfg' Ludovic Courtès
2018-11-16  9:36   ` [bug#33405] [PATCH 07/10] vm: Remove explicit calls to 'operating-system-derivation' Ludovic Courtès
2018-11-16  9:36   ` [bug#33405] [PATCH 08/10] guix system: Simplify bootloader package handling Ludovic Courtès
2018-11-16  9:36   ` Ludovic Courtès [this message]
2018-11-16  9:36   ` [bug#33405] [PATCH 10/10] guix system: Clarify 'perform-action' Ludovic Courtès
2018-11-16 13:39 ` [bug#33405] [PATCH 00/10] De-monadify and clean up system code Mathieu Othacehe
2018-11-16 16:50   ` Ludovic Courtès
2018-11-17  1:14     ` Mathieu Othacehe
2018-11-18 22:42   ` bug#33405: " Ludovic Courtès
2018-11-16 23:32 ` [bug#33405] " Danny Milosavljevic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181116093624.4820-9-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=33405@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).