From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CHTONy+8iGOF6QAAbAwnHQ (envelope-from ) for ; Thu, 01 Dec 2022 15:37:35 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GAXnNy+8iGMMGgAA9RJhRA (envelope-from ) for ; Thu, 01 Dec 2022 15:37:35 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6CF143FB51 for ; Thu, 1 Dec 2022 15:37:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0kgA-0008Cj-1k; Thu, 01 Dec 2022 09:36:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0kg8-000886-6S for guix-patches@gnu.org; Thu, 01 Dec 2022 09:36:44 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0kg7-0002fa-Ti for guix-patches@gnu.org; Thu, 01 Dec 2022 09:36:43 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0kVm-00089L-0y for guix-patches@gnu.org; Thu, 01 Dec 2022 09:26:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#48314] [PATCH] Install guix system on Raspberry Pi Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 01 Dec 2022 14:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48314 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Stefan Cc: Vagrant Cascadian , Danny Milosavljevic , Ludovic =?UTF-8?Q?Court=C3=A8s?= , phodina , 48314@debbugs.gnu.org Received: via spool by 48314-submit@debbugs.gnu.org id=B48314.166990474131315 (code B ref 48314); Thu, 01 Dec 2022 14:26:01 +0000 Received: (at 48314) by debbugs.gnu.org; 1 Dec 2022 14:25:41 +0000 Received: from localhost ([127.0.0.1]:40004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0kVQ-000891-5F for submit@debbugs.gnu.org; Thu, 01 Dec 2022 09:25:41 -0500 Received: from mail-qk1-f177.google.com ([209.85.222.177]:46598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0kVN-00088u-8e for 48314@debbugs.gnu.org; Thu, 01 Dec 2022 09:25:38 -0500 Received: by mail-qk1-f177.google.com with SMTP id d8so1230763qki.13 for <48314@debbugs.gnu.org>; Thu, 01 Dec 2022 06:25:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WFP/HPGbpxnksa9Z1ET0mu1uAsqG1Ns5+lcNgF1RAyg=; b=ZfY4fJRKJW0y3dXcrmzuccaDf10FW5SkTrXfY9+Irnf0seHcjpe0Kpoh5vb5ySOEpj ksFmzWm0u0laYr9L75OC1tEeJQJ+xVgtKR26sqDc1Aq/N+/zDDxsPzyYN3O1Y/AlIlDP KNY1UyAYZM0bgTx2+YSHixMIdqjkcuMfCRXld9fMSvYzFQu3R4mwW7JJbB0XSAFid/BP Ph7hiXbKfHnhEWEoFeEMlrLseP62QojNuokJ1hDnfpe1/6mgQcR5QNVaWsGguKuwVkpD pzT37FZR71yiYisH7wh66+y6/flltkS5tFzIwj+4T/8B8ZbXM4tcK4Ybh1XXeE1AHIcF Smfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WFP/HPGbpxnksa9Z1ET0mu1uAsqG1Ns5+lcNgF1RAyg=; b=NpFVs+LrZJMeMhogDA+XEfjK6xniKAn4pKDi+JKB6sFAwaqGwex4rbwfIk9DTNUCr3 H7EQnwJC87vBuc1J1QoMU+u1b7uaoxNyKnxQ3ALl/9rTHOge2rdIzKGVIRyNhqniYbAz Ow1j3d7S6R09+qzMiuNW87Kfe+by5rcjD0YYaSHu2tecrSBPHUq9JAI8uzsotZzuM4wR HcD/1Y2bhekClmamo/ZpTY8TU+PJDsT7hfVgEWUJsAz3ZG5YWzLSN8qpbRkPKUBlKlah an92yCqkVNoB4DMd1u4UoZB7xn7X+4SfI7CAnipWzOhfQZigO4txv14oMbww1/gqlODy qm2g== X-Gm-Message-State: ANoB5pntZXyNrjRDusRx1/Mbg0FwTdX2CSXrd7KxCh0u70h7diZn6VId K4bJdoEBUp9VcMISptqn9w8= X-Google-Smtp-Source: AA0mqf7vYtf7Ib8lcIuxRkAESxEd+hziF5z00d61bu2YWQg2pjdJ6cgiI7iFLRhAyfsFxAf2BvAd9Q== X-Received: by 2002:a05:620a:3cc:b0:6fa:3204:330b with SMTP id r12-20020a05620a03cc00b006fa3204330bmr44401777qkm.114.1669904731491; Thu, 01 Dec 2022 06:25:31 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id bl21-20020a05620a1a9500b006ce9e880c6fsm3483883qkb.111.2022.12.01.06.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 06:25:31 -0800 (PST) From: Maxim Cournoyer In-Reply-To: <204332DD-AA02-4A31-9B48-FB3FAB9BD8F3@vodafonemail.de> (Stefan's message of "Thu, 22 Sep 2022 18:18:59 +0200") References: <2IN6BsQe0_wSC9iwf7LHT5LUk7wXLVXytkDtcg7RIYByyYFTsuC9BZPR_wdv4eDMncsZfy17h7z9jIRRSC6kfV2odXkt0hp4Lilq5sGYdVo=@protonmail.com> <204332DD-AA02-4A31-9B48-FB3FAB9BD8F3@vodafonemail.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Date: Thu, 01 Dec 2022 09:25:29 -0500 Message-ID: <87tu2fi4km.fsf_-_@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1669905455; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=FWR0swL/3kaLq0Ay8lc12ONjLX0c5JYzjgubzbo56J4=; b=ZMDvascDDyMGf8hLTilGjTk8br/b5JdxP8/yP+dR0vA9cz/m9cmMUmRXk3vd+abGVcYmPL /l3y3HUp1VxFxvsQcRINwM1fxNrM1T1kK1E1aKDVQkzu2Bi/AQ1Rry1u8ZwbEzykZUDK1O BE31eGPoNEB17w0VJy1IqxeSPsqgqJ6hPRgRXLunbAwI28TRG4oNm1cEJmjpz3DE1TQKzb 7PJbVGgmvj8wFbzO8wBWGlDNonqA0krOCJOvRU02purGlNyru5iTpCnJBXM7Vg2T9mvZxb 58pgtOkNPRorJnHePRaHc6JR818lDlY4eKyCF/mRMU1x0fsHahp9NGyor0XTqA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1669905455; a=rsa-sha256; cv=none; b=O9HrT4DPZE/1oNGf0qJIUjZojPmlfl6N8FSDoCf2mlFJcOMggOqI2yCQVAAldAeyVgzvt9 +/tJ5lv9N/mHJWSip0X2EIYiBFZR4iTGYDBD0W2cOHcDN0AGYReDInP/NQWnNPZ1u5EZJY HyXVuNJein0eikKrAu94vSQim8/2nZVV1rIyDAFjRsFAE9hQtg8Vm5/M/FVorvJz5YvVHB jQOZGEVdy24BW2b8c8tbK47A0YvZaxzWLjq/58xK+bFlmeUP7eKav+xH5O1qmCmO9h+e9T a3ZyetLfH+jgMmjdvRrVRFYv4ONTXic9tyIRZk+gYIylGZFOxI8zTV7GgNaIow== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=ZfY4fJRK; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 4.74 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=ZfY4fJRK; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6CF143FB51 X-Spam-Score: 4.74 X-Migadu-Scanner: scn0.migadu.com X-TUID: EPI8SVFBSyVj Hi Stefan! Some comments/question for this proposed change. Stefan writes: [...] > gnu: linux: Fix the extra-version parameter in make-linux-libre*. This first commit LGTM. I'll push it shortly. [...] > gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootload= er. > > From: Stefan > > * doc/guix.texi (Bootloader Configuration): Describe the new > =E2=80=98grub-efi-netboot-removable-bootloader=E2=80=99. Mention used su= b-directories and > that the UEFI Boot Manager is not modified. Advice to disable write-acce= ss > over TFTP. > * gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages a= nd > collect everything directly in the profile, avoiding a separate collection > directory. Renamed the profile from "bootloader-profile" to > "efi-bootloader-profile". > [bootloader-collection]: Renamed to =E2=80=A6 > [efi-bootloader-profile-hook]: =E2=80=A6 this and removed unused modules = and the > creation of the now unneeded collection directory. > (efi-bootloader-chain): Added packages and disk-image-installer arguments. > Removed handling of the collection directory, now only calling the given > installer procedure. > * gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper. > (make-grub-configuration): New helper based on (grub-configuration-file). > Adding grub argument, fixed indentation, removend code to get grub. > (grub-configuration-file): Now using (make-grub-configuration). > (grub-efi-configuration-file): New function using (make-grub-configuratio= n). > Instead of getting the grub-efi package from the bootloader-configuration > this function refers to the grub-efi package directly. > (grub-cfg): New variable to replace "/boot/grub/grub.cfg". > (install-grub-efi-netboot): Removed, the functionality got moved. > (make-grub-efi-netboot-installer): New helper function to return a custom= ized > installer for a certain efi-sub-directory. The installer basically copies > a pre-installed efi-bootloader-profile, and adds needed symlinks for boot= ing > over network, or =E2=80=93 on an ESP =E2=80=93 an intermediate grub-cfg t= o load the final > grub-cfg file. > (grub-bootloader): Now using the grub-cfg variable. > (grub-efi-bootloader): Now using the grub-cfg variable. Removed inherita= nce, > giving complete set of fields. > (make-grub-efi-netboot-bootloader): New helper function. > (grub-efi-netboot-bootloader): Now using the helper. > (grub-efi-netboot-removable-bootloader): New bootloader using the helper. > It uses the efi-sub-directory "efi/boot" for removable media. > * gnu/packages/bootloaders.scm (make-grub-efi-netboot): New function to r= eturn > a grub-efi package pre-installed via grub-mknetdir, customized for an > efi-sub-directory and able to boot via network and local storage. > > The rework allows to use an (efi-bootloader-chain) like this, which is ab= le > to boot over network or local storage, depending on the symlink-support at > the bootloader-target: > > (operating-system > (bootloader > (bootloader-configuration > (bootloader > (efi-bootloader-chain > grub-efi-netboot-removable-bootloader > #:packages (list my-firmware-package > my-u-boot-package) > #:files (list (plain-file "config.txt" > "kernel=3Du-boot.bin")) > #:hooks my-special-bootloader-profile-manipulator)) > (target "/booti/efi") > =E2=80=A6)) > =E2=80=A6) > ) That's *a lot* of text :-). For the future, some of the things there are improvements rather than necessary changes it seems, so could have been split into something different, smaller & easier to review. I've standardized to use the imperative tense in the change log message (Added -> Add for example). [...] > +(define (grub-configuration-file config . args) > + (let* ((bootloader (bootloader-configuration-bootloader config)) > + (grub (bootloader-package bootloader))) > + (apply make-grub-configuration grub config args))) > + > +(define (grub-efi-configuration-file . args) > + (apply make-grub-configuration grub-efi args)) > + > +(define grub-cfg "/boot/grub/grub.cfg") In GRUB-EFI-CONFIGURATION-FILE above, why do we hard-code grub-efi instead of retrieving it from config the same as for GRUB-CONFIGURATION-FILE? It seems that'd be preferable, as otherwise someone cannot override GRUB-EFI with their own variant, no? > >=20=20 > ;;; > @@ -674,42 +681,31 @@ fi~%")))) > ((target-arm?) "--target=3Darm-efi")) > "--efi-directory" target-esp))))) >=20=20 > -(define (install-grub-efi-netboot subdir) > - "Define a grub-efi-netboot bootloader installer for installation in SU= BDIR, > -which is usually efi/Guix or efi/boot." > - (let* ((system (string-split (nix-system->gnu-triplet > - (or (%current-target-system) > - (%current-system))) > - #\-)) > - (arch (first system)) > - (boot-efi-link (match system > - ;; These are the supportend systems and the na= mes > - ;; defined by the UEFI standard for removable = media. > - (("i686" _ ...) "/bootia32.efi") > - (("x86_64" _ ...) "/bootx64.efi") > - (("arm" _ ...) "/bootarm.efi") > - (("aarch64" _ ...) "/bootaa64.efi") > - (("riscv" _ ...) "/bootriscv32.efi") > - (("riscv64" _ ...) "/bootriscv64.efi") > - ;; Other systems are not supported, although d= efined. > - ;; (("riscv128" _ ...) "/bootriscv128.efi") > - ;; (("ia64" _ ...) "/bootia64.efi") > - ((_ ...) #f))) > - (core-efi (string-append > - ;; This is the arch dependent file name of GRUB, e.g. > - ;; i368-efi/core.efi or arm64-efi/core.efi. > - (match arch > - ("i686" "i386") > - ("aarch64" "arm64") > - ("riscv" "riscv32") > - (_ arch)) > - "-efi/core.efi"))) > - (with-imported-modules > - '((guix build union)) > - #~(lambda (bootloader target mount-point) > - "Install the BOOTLOADER, which must be the package grub, as e.g. > -bootx64.efi or bootaa64.efi into SUBDIR, which is usually efi/Guix or ef= i/boot, > -below the directory TARGET for the system whose root is mounted at MOUNT= -POINT. > +(define* (make-grub-efi-netboot-installer grub-efi grub-cfg subdir) > + "Make a bootloader-installer for a grub-efi-netboot bootloader, which = expects > +its files in SUBDIR and its configuration file in GRUB-CFG. > + > +As a grub-efi-netboot package is already preinstalled by 'grub-mknetdir'= , the > +installer basically copies all files from the bootloader-package (or pro= file) > +into the bootloader-target directory. > + > +Additionally for network booting over TFTP, two relative symlinks to the= store > +and to the GRUB-CFG file are necessary. Due to this a TFTP root directo= ry must > +not be located on a FAT file-system. > + > +If the bootloader-target does not support symlinks, then it is assumed t= o be a > +kind of EFI System Partition (ESP). In this case an intermediate config= uration > +file is created with the help of GRUB-EFI to load the GRUB-CFG. > + > +The installer is usable for any efi-bootloader-chain, which prepares the > +bootloader-profile in a way ready for copying. > + > +The installer does not manipulate the system's 'UEFI Boot Manager'." > + (with-imported-modules '((guix build union)) > + #~(lambda (bootloader target mount-point) > + "Copy the BOOTLOADER, which must be a preinstalled grub-efi-netb= oot > +package with a SUBDIR like efi/boot or efi/Guix, below the directory > +TARGET for the system whose root is mounted at MOUNT-POINT. >=20=20 > MOUNT-POINT is the last argument in 'guix system init /etc/config.scm mn= t/point' > or '/' for other 'guix system' commands. > @@ -719,17 +715,18 @@ bootloader-configuration in: I've unified the above docstring as one; otherwise it was mangled with Scheme and it wouldn't have appeared as a whole in the online documentation system of Guile. I've improved the writing a bit (I think!), use gexps in some places, and other smallish changes that amount to: --8<---------------cut here---------------start------------->8--- 4 files changed, 80 insertions(+), 76 deletions(-) doc/guix.texi | 17 +++++++++-------- gnu/bootloader.scm | 11 +++++------ gnu/bootloader/grub.scm | 77 ++++++++++++++++++++++++++++++++++++++++-= ------------------------------------ gnu/packages/bootloaders.scm | 51 ++++++++++++++++++++++++++---------------= ---------- modified doc/guix.texi @@ -38083,17 +38083,18 @@ NFS servers, you also need a properly configured = DHCP server to make the booting over netboot possible. For all this we can currently only recommend you t= o look for instructions about @acronym{PXE, Preboot eXecution Environment}. =20 -If a local EFI System Partition (ESP) or a similar partition with a FAT fi= le -system is mounted in @code{targets}, then symlinks cannot be created. In = this -case everything will be prepared for booting from local storage, simialar = as if -using @code{grub-efi-bootloader}, with the difference that all GRUB binari= es -reside on @code{targets}, too, like needed for booting over network. +If a local EFI System Partition (ESP) or a similar partition with a FAT +file system is mounted in @code{targets}, then symlinks cannot be +created. In this case everything will be prepared for booting from +local storage, matching the behavior of @code{grub-efi-bootloader}, with +the difference that all GRUB binaries are copied to @code{targets}, +necessary for booting over the network. =20 @vindex grub-efi-netboot-removable-bootloader @code{grub-efi-netboot-removable-bootloader} is identical to -@code{grub-efi-netboot-bootloader} with the exception that the sub-directo= ry -@file{efi/boot} will be used instead of @file{efi/Guix} to comply to the U= EFI -specification for removable media. +@code{grub-efi-netboot-bootloader} with the exception that the +sub-directory @file{efi/boot} will be used instead of @file{efi/Guix} to +comply with the UEFI specification for removable media. =20 @quotation Note This @emph{will} overwrite the GRUB file from any other operating systems = that modified gnu/bootloader.scm @@ -361,8 +361,7 @@ (define name-ends-with-/? (cut string-suffix? "/" <>)) (define (name-is-store-entry? name) "Return #t if NAME is a direct store entry and nothing insid= e." (not (string-index (strip-store-file-name name) #\/))) - (let* ((output #$output) - (files '#$files) + (let* ((files '#$files) (directories (filter name-ends-with-/? files)) (names-from-directories (append-map (lambda (directory) @@ -370,11 +369,11 @@ (define (name-is-store-entry? name) directories)) (names (append names-from-directories (remove name-ends-with-/? files)))) - (mkdir-p output) + (mkdir-p #$output) (if (every file-exists? names) (begin (for-each (lambda (name) - (symlink-to name output + (symlink-to name #$output (if (name-is-store-entry? name) strip-store-file-name basename))) @@ -410,7 +409,7 @@ (define* (efi-bootloader-chain final-bootloader The package of the FINAL-BOOTLOADER and all PACKAGES and FILES will be pla= ced in an efi-bootloader-profile, which will be passed to the INSTALLER. =20 -FILES may contain file like objects produced by procedures like plain-file, +FILES may contain file-like objects produced by procedures like plain-file, local-file, etc., or package contents produced with file-append. =20 If a directory name in FILES ends with '/', then the directory content ins= tead @@ -424,7 +423,7 @@ (define* (efi-bootloader-chain final-bootloader FINAL-BOOTLOADER will be called. =20 If the DISK-IMAGE-INSTALLER is used, then this gexp procedure will be call= ed -to install the efi-bootloader-profile into a disk-image. Otherwise the +to install the efi-bootloader-profile into a disk image. Otherwise the disk-image-installer of the FINAL-BOOTLOADER will be called." (bootloader (inherit final-bootloader) modified gnu/bootloader/grub.scm @@ -685,7 +685,7 @@ (define* (make-grub-efi-netboot-installer grub-efi grub= -cfg subdir) "Make a bootloader-installer for a grub-efi-netboot bootloader, which ex= pects its files in SUBDIR and its configuration file in GRUB-CFG. =20 -As a grub-efi-netboot package is already preinstalled by 'grub-mknetdir', = the +As a grub-efi-netboot package is already pre-installed by 'grub-mknetdir',= the installer basically copies all files from the bootloader-package (or profi= le) into the bootloader-target directory. =20 @@ -700,12 +700,12 @@ (define* (make-grub-efi-netboot-installer grub-efi gr= ub-cfg subdir) The installer is usable for any efi-bootloader-chain, which prepares the bootloader-profile in a way ready for copying. =20 -The installer does not manipulate the system's 'UEFI Boot Manager'." - (with-imported-modules '((guix build union)) - #~(lambda (bootloader target mount-point) - "Copy the BOOTLOADER, which must be a preinstalled grub-efi-netboot -package with a SUBDIR like efi/boot or efi/Guix, below the directory -TARGET for the system whose root is mounted at MOUNT-POINT. +The installer does not manipulate the system's 'UEFI Boot Manager'. + +The returned installer accepts the BOOTLOADER, TARGET and MOUNT-POINT +arguments. Its job is to copy the BOOTLOADER, which must be a pre-install= ed +grub-efi-netboot package with a SUBDIR like efi/boot or efi/Guix, below the +directory TARGET for the system whose root is mounted at MOUNT-POINT. =20 MOUNT-POINT is the last argument in 'guix system init /etc/config.scm mnt/= point' or '/' for other 'guix system' commands. @@ -720,13 +720,14 @@ (define* (make-grub-efi-netboot-installer grub-efi gr= ub-cfg subdir) =E2=80=A6) =20 TARGET is required to be an absolute directory name, usually mounted via N= FS, -and finally needs to be provided by a TFTP server as the TFTP root directo= ry. +and finally needs to be provided by a TFTP server as +the TFTP root directory. =20 Usually the installer will be used to prepare network booting over TFTP. = Then GRUB will load tftp://server/SUBDIR/grub.cfg and this file will instruct i= t to load more files from the store like tftp://server/gnu/store/=E2=80=A6-linu= x=E2=80=A6/Image. =20 -To make this possible two symlinks will be created. The first symlink poi= nts +To make this possible two symlinks are created. The first symlink points relatively form MOUNT-POINT/TARGET/SUBDIR/grub.cfg to MOUNT-POINT/boot/grub/grub.cfg, and the second symlink points relatively f= rom MOUNT-POINT/TARGET/%store-prefix to MOUNT-POINT/%store-prefix. @@ -740,16 +741,18 @@ (define* (make-grub-efi-netboot-installer grub-efi gr= ub-cfg subdir) accesses outside its TFTP root directory. This all may need to be conside= red for security aspects. It is advised to disable any TFTP write access! =20 -The installer can also be used to prepare booting from local storages, if = the +The installer can also be used to prepare booting from local storage, if t= he underlying file-system, like FAT on an EFI System Partition (ESP), does not support symlinks. In this case the MOUNT-POINT/TARGET/SUBDIR/grub.cfg wil= l be created with the help of GRUB-EFI to load the /boot/grub/grub.cfg file. A symlink to the store is not needed in this case." + (with-imported-modules '((guix build union)) + #~(lambda (bootloader target mount-point) ;; In context of a disk image creation TARGET will be #f and an ;; installer is expected to do necessary installations on MOUNT-PO= INT, - ;; which will become the root file system. - ;; If TARGET is #f, this installer has nothing to do, as it only c= ares - ;; about the EFI System Partition (ESP). + ;; which will become the root file system. If TARGET is #f, this + ;; installer has nothing to do, as it only cares about the EFI Sys= tem + ;; Partition (ESP). (when target (use-modules ((guix build union) #:select (symlink-relative)) (ice-9 popen) @@ -779,35 +782,35 @@ (define* (make-grub-efi-netboot-installer grub-efi gr= ub-cfg subdir) (mkdir-p (dirname grub-cfg-link)) (false-if-exception (delete-file grub-cfg-link)) (if (unspecified? - (false-if-exception (symlink-relative grub-cfg grub-cfg-li= nk))) - ;; Symlinks are supported. - (begin - ;; Prepare the symlink to the store. - (mkdir-p (dirname store-link)) - (false-if-exception (delete-file store-link)) - (symlink-relative store store-link)) - ;; Creating symlinks does not seem to be supported. - ;; Probably an ESP is used. - ;; Instead we can script to search and load the actual grub.= cfg. - (let* ((probe #$(file-append grub-efi "/sbin/grub-probe")) - (port - (open-pipe* OPEN_READ probe "--target=3Dfs_uuid" gr= ub-cfg)) - (search-root - (match (read-line port) - ((? eof-object?) + (false-if-exception (symlink-relative grub-cfg grub-cfg-l= ink))) + ;; Symlinks are supported. + (begin + ;; Prepare the symlink to the store. + (mkdir-p (dirname store-link)) + (false-if-exception (delete-file store-link)) + (symlink-relative store store-link)) + ;; Creating symlinks does not seem to be supported. Proba= bly + ;; an ESP is used. Add a script to search and load the ac= tual + ;; grub.cfg. + (let* ((probe #$(file-append grub-efi "/sbin/grub-probe")) + (port (open-pipe* OPEN_READ probe "--target=3Dfs_uu= id" + grub-cfg)) + (search-root + (match (read-line port) + ((? eof-object?) ;; There is no UUID available. As a fallback se= arch ;; everywhere for the grub.cfg. (string-append "search --file --set " #$grub-cf= g)) - (fs-uuid + (fs-uuid ;; The UUID to load the grub.cfg from is known. (string-append "search --fs-uuid --set " fs-uui= d)))) - (load-grub-cfg (string-append "configfile " #$grub-cf= g))) - (close-pipe port) - (with-output-to-file grub-cfg-link - (lambda () - (display (string-join (list search-root - load-grub-cfg) - "\n"))))))))))) + (load-grub-cfg (string-append "configfile " #$grub-= cfg))) + (close-pipe port) + (with-output-to-file grub-cfg-link + (lambda () + (display (string-join (list search-root + load-grub-cfg) + "\n"))))))))))) =20 =20 modified gnu/packages/bootloaders.scm @@ -427,8 +427,8 @@ (define-public (make-grub-efi-netboot name subdir) (build-system trivial-build-system) (arguments (let* ((system (string-split (nix-system->gnu-triplet - (or (%current-target-system) - (%current-system))) + (or (%current-target-system) + (%current-system))) #\-)) (arch (first system)) (boot-efi @@ -454,29 +454,30 @@ (define-public (make-grub-efi-netboot name subdir) ("riscv" "riscv32") (_ arch)) "-efi/core.efi"))) - `(#:modules ((guix build utils)) - #:builder - (begin - (use-modules (guix build utils)) - (let* ((bootloader (assoc-ref %build-inputs "grub-efi")) - (net-dir (assoc-ref %outputs "out")) - (sub-dir (string-append net-dir "/" ,subdir "/")) - (boot-efi (string-append sub-dir ,boot-efi)) - (core-efi (string-append sub-dir ,core-efi))) - ;; Install GRUB, which refers to the grub.cfg, with support f= or - ;; encrypted partitions, - (setenv "GRUB_ENABLE_CRYPTODISK" "y") - (invoke/quiet (string-append bootloader "/bin/grub-mknetdir") - (string-append "--net-directory=3D" net-dir) - (string-append "--subdir=3D" ,subdir) - ;; These modules must be preloaded to allow boo= ting - ;; from an ESP or a similar partition with a FAT - ;; file system. - (string-append "--modules=3Dpart_msdos part_gpt= fat")) - ;; Move GRUB's core.efi to the removable media name. - (false-if-exception (delete-file boot-efi)) - (rename-file core-efi boot-efi)))))) - (inputs `(("grub-efi" ,grub-efi))) + (list + #:modules ((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (let* ((bootloader #$(this-package-input "grub-efi")) + (net-dir #$output) + (sub-dir (string-append net-dir "/" #$subdir "/")) + (boot-efi (string-append sub-dir #$boot-efi)) + (core-efi (string-append sub-dir #$core-efi))) + ;; Install GRUB, which refers to the grub.cfg, with support = for + ;; encrypted partitions, + (setenv "GRUB_ENABLE_CRYPTODISK" "y") + (invoke/quiet (string-append bootloader "/bin/grub-mknetdir") + (string-append "--net-directory=3D" net-dir) + (string-append "--subdir=3D" #$subdir) + ;; These modules must be pre-loaded to allow b= ooting + ;; from an ESP or a similar partition with a F= AT + ;; file system. + (string-append "--modules=3Dpart_msdos part_gp= t fat")) + ;; Move GRUB's core.efi to the removable media name. + (false-if-exception (delete-file boot-efi)) + (rename-file core-efi boot-efi)))))) + (inputs (list grub-efi)) (synopsis (package-synopsis grub-efi)) (description (package-description grub-efi)) (home-page (package-home-page grub-efi)) --8<---------------cut here---------------end--------------->8--- It's a pity we do not have tests for that, but I'll try to test it manually and if it works I can push it shortly. I'd still like feedback on my question above. --=20 Thanks, Maxim