From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id wMLANJhcp2VUBAAA62LTzQ:P1 (envelope-from ) for ; Wed, 17 Jan 2024 05:50:33 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id wMLANJhcp2VUBAAA62LTzQ (envelope-from ) for ; Wed, 17 Jan 2024 05:50:32 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail1 header.b=IZOf4Tyq; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail1 header.b=qnznObJw; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1705467032; h=from:from:sender:sender:reply-to: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=/2tv0iQs+MuOo1nV6kq6yBVw7yBdaUQCX9XiOE3c+3U=; b=kiwa/yPixDfNbO4CaeX65sFmMeGLWUfLqoz/QiOod4DQarpWu1nNE25SFdEo+I/IBjOMEx Tgi8xjvsBZBd2Diqr92RaP4mZjGVpBbWSNuhsa+s+Wv6KI5wyUZ38zYMYMUy5nz5W0JPTJ Is/sxX7p2sw1Y0YZcJNvGwTIllFntfmxy0G9AMTE6jTI2fMvIyttkY0Hxo9LXn2gCzGopM BswVTPJsxwERbtVqB3Gufrt4Z36Ow5JD3W/GfH3k5F7qF0JWQIbquKksCSQ79frNq7g1+0 3K+UoGcbIamvs0CdTrrqXquyIcoOeXn3UKzabKqrIkj2ZDRnJBqGWgagUr6Usg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705467032; a=rsa-sha256; cv=none; b=l/S4ZJk6vfwPgAKe2zQ+Z4K1bR1RFeLJ5GTe8T8kjGr6TqQgXqcpb3leF9FgboWH8phWhn zw4l6nz5OBGw6Rbo0hg61ycuTsYe814C7KygpEUTf3mFGVSfAza1M/vQn/GtolUtNItic4 8Hsq5mDaO3lPbdhOOziQ7sm1OzW9n2+SHgF0XqEDP31PXdQm1N88/sh5bRAnMRqaHCntTw VNN7CvuqjF7Aai8K+36Saif1PbV8mHDE0gsscbIdyYhhqy/eZk5pzur8Wb4dbp+FF/twrY 8jFMLnOVNonTHUWH8KyCKSKNCZaCUlUdNDc5xi1QGINnT01Fv5eyZXY7AK1MDw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lunabee.space header.s=purelymail1 header.b=IZOf4Tyq; dkim=fail ("headers rsa verify failed") header.d=purelymail.com header.s=purelymail1 header.b=qnznObJw; dmarc=pass (policy=none) header.from=gnu.org; 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" 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 9895EA4FD for ; Wed, 17 Jan 2024 05:50:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPxsK-0003uh-Hz; Tue, 16 Jan 2024 23:50:04 -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 1rPxsI-0003uM-VX for guix-patches@gnu.org; Tue, 16 Jan 2024 23:50:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rPxsI-0005Cl-OU for guix-patches@gnu.org; Tue, 16 Jan 2024 23:50:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rPxsI-0008Qs-Qz; Tue, 16 Jan 2024 23:50:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68524] [PATCH 2/2] gnu: bootloaders: Add uefi-uki-bootloader. Resent-From: Lilah Tascheter Original-Sender: "Debbugs-submit" Resent-CC: efraim@flashner.co.il, vagrant@debian.org, guix-patches@gnu.org Resent-Date: Wed, 17 Jan 2024 04:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68524 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68524@debbugs.gnu.org Cc: Lilah Tascheter , Efraim Flashner , Vagrant Cascadian X-Debbugs-Original-Xcc: Efraim Flashner , Vagrant Cascadian Received: via spool by 68524-submit@debbugs.gnu.org id=B68524.170546695532337 (code B ref 68524); Wed, 17 Jan 2024 04:50:02 +0000 Received: (at 68524) by debbugs.gnu.org; 17 Jan 2024 04:49:15 +0000 Received: from localhost ([127.0.0.1]:50393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPxrX-0008PU-17 for submit@debbugs.gnu.org; Tue, 16 Jan 2024 23:49:15 -0500 Received: from sendmail.purelymail.com ([34.202.193.197]:41784) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPxrV-0008PG-Lu for 68524@debbugs.gnu.org; Tue, 16 Jan 2024 23:49:14 -0500 DKIM-Signature: a=rsa-sha256; b=IZOf4TyqkHhXBMqQt39pP1a4wFL9EAt3C+bVwSXsLfqKbAFssolLscbVpGi2SKbhVBS3I949BorLm/TFMHkeLTWyX+fgLfr4zZBltCNW+Y8a3Wt/dylxrlMnjyGVBpSnIyQVp7gIPGTEavk39sNAXeS1tS65fYivOLheGZWCn6jcqR0uYbOS5FukcU8JU8HPKtTE+ROi8i4X1Y0XiT3sDaTiWe9aYKHRdx01vcVdYHSqd9kTDpcrh6PUFyoEinbBLhDCeJZZhJoGVShk1zlsdkErV7/821PpXlrYkQl7kHDZPpA5rGgk7MKpVpP7JaDRBs3Z9pnr+xDSvEVOGvZZ+Q==; s=purelymail1; d=lunabee.space; v=1; bh=YXAJjYW2GgfCQLfFEEzTEfxGHAAk6tRnnjvDm3bPpLQ=; h=Received:From:To:Subject; DKIM-Signature: a=rsa-sha256; b=qnznObJwJg0RW7Kb3ignaCnyzRmKdKzdLx3UJqpwwj1tYj2LqMUqwEiQ7pEPxOIwd+aZBMQQKFooJgrlfLFJ6VKfOUe4D7BrykIA6g4Bw3NiZXqZCQ+zBVPuZCl149ZzbXN/C9YqFrFRwElsrqa3mBI+3VlKE5/8512jKrmtiH5zKpOFRacGckSaRlyA1eZBRK4GYoPBecQpMcZzuhuXe3yVoryKZyXCv2NUktJHRToMYCMHwM1DIaZ2M3S02ug2M86AlIax7SSVmeZ4av9PnhfgrQZINe4GsT2Ylx2VlrJTeHnQDMgyWWb0u+t1CmjRls2XU0FvxAbsR5FYLsqw0Q==; s=purelymail1; d=purelymail.com; v=1; bh=YXAJjYW2GgfCQLfFEEzTEfxGHAAk6tRnnjvDm3bPpLQ=; h=Feedback-ID:Received:From:To:Subject; Feedback-ID: 8937:2070:null:purelymail X-Pm-Original-To: 68524@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -96528462; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 17 Jan 2024 04:49:01 +0000 (UTC) Date: Tue, 16 Jan 2024 22:48:11 -0600 Message-ID: <8cad5fa9951dad5f663ca5d441db0ffc181e35fe.1705466646.git.lilah@lunabee.space> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail Content-Type: text/plain; charset=UTF-8 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: , From: Lilah Tascheter via Guix-patches Reply-To: Lilah Tascheter 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 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -7.19 X-Spam-Score: -7.19 X-Migadu-Queue-Id: 9895EA4FD X-TUID: s4HGn1Af7qS5 * doc/guix.texi (Bootloader Configuration)[bootloader,targets]: Document uefi-uki-bootloader and uefi-uki-signed-bootloader. * gnu/bootloader/uki.scm: New file. Change-Id: Ie30ef47ea026889727a050131a9b3c0555aa4c21 --- doc/guix.texi | 35 ++++++++++---- gnu/bootloader/uki.scm | 106 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 gnu/bootloader/uki.scm diff --git a/doc/guix.texi b/doc/guix.texi index a66005ee9d..3029740f45 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40881,8 +40881,9 @@ Bootloader Configuration The bootloader to use, as a @code{bootloader} object. For now @code{grub-bootloader}, @code{grub-efi-bootloader}, @code{grub-efi-removable-bootloader}, @code{grub-efi-netboot-bootloader}, -@code{grub-efi-netboot-removable-bootloader}, @code{extlinux-bootloader} -and @code{u-boot-bootloader} are supported. +@code{grub-efi-netboot-removable-bootloader}, @code{extlinux-bootloader}, +@code{u-boot-bootloader}, @code{uefi-uki-bootloader}, and +@code{uefi-uki-signed-bootloader} are supported. =20 @cindex ARM, bootloaders @cindex AArch64, bootloaders @@ -40989,6 +40990,24 @@ Bootloader Configuration unbootable. @end quotation =20 +@vindex uefi-uki-bootloader +@code{uefi-uki-bootloader} boots a linux kernel directly through UEFI, wit= hout +an intermediary like GRUB. The main practical advantage of this is allowin= g +root/store encryption without an extra GRUB password entry and slow decryp= tion +step. + +@vindex uefi-uki-signed-bootloader +@code{uefi-uki-signed-bootloader} is like @code{uefi-uki-bootloader}, exce= pt +that it is a procedure that returns a bootloader compatible with UEFI secu= re +boot. You must provide it with two paths, to an out-of-store secure boot d= b +certificate, and key, in that order. + +@quotation Note +This bootloader @emph{does not} support booting from any old system genera= tion. +You will also need enough space in your EFI System partition to store your +kernel and initramfs, though this likely won't be an issue. +@end quotation + @item @code{targets} This is a list of strings denoting the targets onto which to install the bootloader. @@ -40997,12 +41016,12 @@ Bootloader Configuration For @code{grub-bootloader}, for example, they should be device names understood by the bootloader @command{installer} command, such as @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub, -GNU GRUB Manual}). For @code{grub-efi-bootloader} and -@code{grub-efi-removable-bootloader} they should be mount -points of the EFI file system, usually @file{/boot/efi}. For -@code{grub-efi-netboot-bootloader}, @code{targets} should be the mount -points corresponding to TFTP root directories served by your TFTP -server. +GNU GRUB Manual}). For @code{grub-efi-bootloader}, +@code{grub-efi-removable-bootloader}, @code{uefi-uki-bootloader}, and +@code{uefi-uki-signed-bootloader}, they should be mount points of the EFI = file +system, usually @file{/boot/efi}. For @code{grub-efi-netboot-bootloader}, +@code{targets} should be the mount points corresponding to TFTP root direc= tories +served by your TFTP server. =20 @item @code{menu-entries} (default: @code{'()}) A possibly empty list of @code{menu-entry} objects (see below), denoting diff --git a/gnu/bootloader/uki.scm b/gnu/bootloader/uki.scm new file mode 100644 index 0000000000..3131bae3d7 --- /dev/null +++ b/gnu/bootloader/uki.scm @@ -0,0 +1,106 @@ +;;; GNU Guix --- Functional package management for GNU +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu bootloader uki) + #:use-module (gnu bootloader) + #:use-module (gnu packages bootloaders) + #:use-module (gnu packages efi) + #:use-module (gnu packages linux) + #:use-module (guix gexp) + #:use-module (guix modules)) + +;; config generator makes script creating uki images +;; install runs script +;; install device is path to uefi dir + +(define* (uefi-uki-configuration-file #:optional cert privkey) + (lambda* (config entries #:key (old-entires '()) #:allow-other-keys) + + (define (menu-entry->uki e) + (define stub (file-append systemd-stub "/libexec/" (systemd-stub-nam= e))) + (computed-file "uki.efi" + (with-imported-modules (source-module-closure '((guix build utils)= )) + #~(let ((args (list #$@(menu-entry-linux-arguments e)))) + (use-modules (guix build utils)) + (invoke #$(file-append ukify "/bin/ukify") "build" + "--linux" #$(menu-entry-linux e) + "--initrd" #$(menu-entry-initrd e) + "--os-release" #$(menu-entry-label e) + "--cmdline" (string-join args) + "--stub" #$stub + "-o" #$output))))) + + (program-file "install-uki" + (with-imported-modules (source-module-closure '((guix build utils))) + #~(let* ((target (cadr (command-line))) + (vendir (string-append target "/EFI/Guix")) + (schema (string-append vendir "/boot.mgr")) + (findmnt #$(file-append util-linux "/bin/findmnt")) + (efibootmgr #$(file-append efibootmgr "/sbin/efibootmgr")= )) + (use-modules (guix build utils) (ice-9 popen) (ice-9 textual-p= orts)) + + (define disk + (call-with-port + (open-pipe* OPEN_READ findmnt "-fnro" "SOURCE" "-T" target= ) + (lambda (port) (get-line port)))) ; only 1 line: the devic= e + + (when (file-exists? schema) + (call-with-input-file schema + (lambda (port) + (for-each (lambda (l) + (unless (string-null? l) + (system* efibootmgr "-B" "-L" l))) + (string-split (get-string-all port) #\lf))))) + (when (directory-exists? vendir) (delete-file-recursively vend= ir)) + + (mkdir-p vendir) + (call-with-output-file schema + (lambda (port) + (for-each (lambda (uki label) + (let* ((base (basename uki)) + (out (string-append vendir "/" base))) + #$(if cert ; sign here so we can access root= certs + #~(invoke + #$(file-append sbsigntools "/bin/sbs= ign") + "--cert" #$cert "--key" #$privkey + "--output" out uki) + #~(copy-file uki out)) + (invoke efibootmgr "-c" "-L" label "-d" disk= "-l" + (string-append "\\EFI\\Guix\\" base)) + (put-string port label) + (put-char port #\lf))) + (list #$@(map-in-order menu-entry->uki entries)) + (list #$@(map-in-order menu-entry-label entries)))))))))= ) + +(define install-uefi-uki + #~(lambda (bootloader target mount-point) + (invoke (string-append mount-point "/boot/install-uki.scm") + (string-append mount-point target)))) + +(define* (make-uefi-uki-bootloader #:optional cert privkey) + (bootloader + (name 'uefi-uki) + (package systemd-stub) + (installer install-uefi-uki) + (disk-image-installer #f) + (configuration-file "/boot/install-uki.scm") + (configuration-file-generator (uefi-uki-configuration-file cert privke= y)))) + +(define-public uefi-uki-bootloader (make-uefi-uki-bootloader)) +;; use ukify genkey to generate cert and privkey. DO NOT include in store. +(define-public (uefi-uki-signed-bootloader cert privkey) + (make-uefi-uki-bootloader cert privkey)) --=20 2.41.0