From patchwork Wed Jan 17 04:23:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lilah Tascheter X-Patchwork-Id: 58999 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 2D0FD27BBEA; Wed, 17 Jan 2024 04:38:30 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED, URIBL_SBL_A autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1FDF427BBE2 for ; Wed, 17 Jan 2024 04:38:29 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPxgj-000268-D8; Tue, 16 Jan 2024 23:38:05 -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 1rPxgi-00025z-Fh for guix-patches@gnu.org; Tue, 16 Jan 2024 23:38:04 -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 1rPxgi-0003P0-A1 for guix-patches@gnu.org; Tue, 16 Jan 2024 23:38:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rPxgh-0005Kp-5n; Tue, 16 Jan 2024 23:38:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68525] [PATCH 1/2] gnu: bootloaders: Add uki packages. 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:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68525 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68525@debbugs.gnu.org Cc: Lilah Tascheter , Efraim Flashner , Vagrant Cascadian X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Efraim Flashner , Vagrant Cascadian Received: via spool by submit@debbugs.gnu.org id=B.170546623420408 (code B ref -1); Wed, 17 Jan 2024 04:38:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jan 2024 04:37:14 +0000 Received: from localhost ([127.0.0.1]:50358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPxft-0005J5-Nq for submit@debbugs.gnu.org; Tue, 16 Jan 2024 23:37:14 -0500 Received: from lists.gnu.org ([2001:470:142::17]:60350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPxfr-0005IY-Id for submit@debbugs.gnu.org; Tue, 16 Jan 2024 23:37:12 -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 1rPxfg-0001zc-FV for guix-patches@gnu.org; Tue, 16 Jan 2024 23:37:00 -0500 Received: from sendmail.purelymail.com ([34.202.193.197]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rPxfe-0003KO-6n for guix-patches@gnu.org; Tue, 16 Jan 2024 23:37:00 -0500 Authentication-Results: purelymail.com; auth=pass DKIM-Signature: a=rsa-sha256; b=p2RF8n/rDUFoXKXJAD77JYIjQoEq2Mf7FDECK7ka/pBtScK+WH0d/G/uhX8kXgpuj6YtA73mvAhvtQiiHJus5nqMo4hhkjqLhs55lLE8uzxBZy+LkabNAwOsXYdOar7bcL4LFK0VzW34iFRSzXxyQBXb5Pk+P0sAajJIXi3Z4ksu1thrNBPp70vrAVWPbKoqJ7ROf+VwyOjmpbDOJ6kfsqKyjr3gYuPCmVERx4N6mef1xmc3rgxfC3JF2cTO1jr7VXQS+qzrAV4kkQM9n1YxLENxyqO0SAs7z+TWnnec+vLRaa8Dx1E4/aqz1mpHGw+kiX24HRjWfJNFSrTHW0nzVg==; s=purelymail1; d=lunabee.space; v=1; bh=s8vpIAJO+n52Yh3EdmZRqYS4sHsw1WBVogfFqDJhfEE=; h=Received:From:To:Subject; DKIM-Signature: a=rsa-sha256; b=ZqYAESOmgknKors1mytanBq+WKJNTUbXEwljwO1Ku2/3xWJj5iKdm4c2MkNp05c7ky8D86s90YBpHnkAIWyAnLqJMWInvzN4MX9tjoAUUoNYBJAO6dGynn2OkZbrUaaTQeQArAKNcH8AZPLaQ6X4fe7vZLq3xDRE+xg/30x8nO2N8eQR7U6v0TG3rNvqvu6Qxngcjt147neJ/dGfVQYAv+2XesSY1Vzy0/1o3Qt/BK+1ZKpnPAAGReCErfRRU4TJzVnTR3ajlNST16nDtKQWPrv8cbZnhA4+Ipv/MvyGHjegC1+jIyXi5Gw/ezZ3Afo/Xa+9DqhwgFHQ7d7II3tqMQ==; s=purelymail1; d=purelymail.com; v=1; bh=s8vpIAJO+n52Yh3EdmZRqYS4sHsw1WBVogfFqDJhfEE=; h=Feedback-ID:Received:From:To:Subject; Feedback-ID: 8937:2070:null:purelymail X-Pm-Original-To: guix-patches@gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -2094701616; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 17 Jan 2024 04:36:50 +0000 (UTC) Date: Tue, 16 Jan 2024 22:23:03 -0600 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail Received-SPF: pass client-ip=34.202.193.197; envelope-from=lilah@lunabee.space; helo=sendmail.purelymail.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_SBL_A=0.1 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , X-Patchwork-Original-From: Lilah Tascheter via Guix-patches From: Lilah Tascheter Reply-To: Lilah Tascheter Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/bootloaders.scm (systemd-stub-name): New procedure. (systemd-version,systemd-source,systemd-stub,ukify): New variables. Change-Id: Ie27bdcbf2c03e895956295f94f280c304393ce8d --- gnu/packages/bootloaders.scm | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index c73a0e665d..32cbb4e704 100644 --- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -46,11 +46,13 @@ (define-module (gnu packages bootloaders) #:use-module (gnu packages compression) #:use-module (gnu packages cross-base) #:use-module (gnu packages disk) + #:use-module (gnu packages efi) #:use-module (gnu packages firmware) #:use-module (gnu packages flex) #:use-module (gnu packages fontutils) #:use-module (gnu packages gcc) #:use-module (gnu packages gettext) + #:use-module (gnu packages gperf) #:use-module (gnu packages linux) #:use-module (gnu packages man) #:use-module (gnu packages mtools) @@ -71,11 +73,13 @@ (define-module (gnu packages bootloaders) #:use-module (gnu packages valgrind) #:use-module (gnu packages virtualization) #:use-module (gnu packages xorg) + #:use-module (gnu packages python-crypto) #:use-module (gnu packages python-web) #:use-module (gnu packages python-xyz) #:use-module (guix build-system gnu) #:use-module (guix build-system meson) #:use-module (guix build-system pyproject) + #:use-module (guix build-system python) #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix gexp) @@ -632,6 +636,96 @@ (define-public syslinux ;; Also contains: license:expat license:isc license:zlib))))) +(define systemd-version "255") +(define systemd-source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/systemd/systemd") + (commit (string-append "v" systemd-version)))) + (file-name (git-file-name "systemd" systemd-version)) + (sha256 + (base32 + "1qdyw9g3jgvsbc1aryr11gpc3075w5pg00mqv4pyf3hwixxkwaq6")))) + +(define-public (systemd-stub-name) + (let ((arch (cond ((target-x86-32?) "ia32") + ((target-x86-64?) "x64") + ((target-arm32?) "arm") + ((target-aarch64?) "aa64") + ((target-riscv64?) "riscv64")))) + (string-append "linux" arch ".efi.stub"))) + +(define-public systemd-stub + (package + (name "systemd-stub") + (version systemd-version) + (source systemd-source) + (build-system meson-build-system) + (arguments + (list + #:configure-flags + `(list "-Defi=true" "-Dsbat-distro=guix" + "-Dsbat-distro-generation=1" ; package revision! + "-Dsbat-distro-summary=Guix System" + "-Dsbat-distro-url=https://guix.gnu.org" + ,(string-append "-Dsbat-distro-pkgname=" name) + ,(string-append "-Dsbat-distro-version=" version)) + #:phases + #~(let ((stub #$(string-append "src/boot/efi/" (systemd-stub-name)))) + (modify-phases %standard-phases + (replace 'build + (lambda* (#:key parallel-build? #:allow-other-keys) + (invoke "ninja" stub + "-j" (if parallel-build? + (number->string (parallel-job-count)) "1")))) + (replace 'install + (lambda _ + (install-file stub (string-append #$output "/libexec")))) + (delete 'check))))) + (inputs (list libcap python-pyelftools `(,util-linux "lib"))) + (native-inputs (list gperf pkg-config python-3 python-jinja2)) + (home-page "https://systemd.io") + (synopsis "Unified kernel image UEFI stub") + (description "Simple UEFi boot stub that loads a conjoined kernel image and +supporting data to their proper locations, before chainloading to the kernel. +Supports measured and/or verified boot environments.") + (license license:lgpl2.1+))) + +(define-public ukify + (package + (name "ukify") + (version systemd-version) + (source systemd-source) + (build-system python-build-system) + (arguments + (list #:phases + #~(modify-phases %standard-phases + (replace 'build + (lambda _ + (substitute* "src/ukify/ukify.py" ; added in python 3.11 + (("datetime\\.UTC") "datetime.timezone.utc")))) + (delete 'check) + (replace 'install + (lambda* (#:key inputs #:allow-other-keys) + (let* ((bin (string-append #$output "/bin")) + (file (string-append bin "/ukify")) + (binutils (assoc-ref inputs "binutils")) + (sbsign (assoc-ref inputs "sbsigntools"))) + (mkdir-p bin) + (copy-file "src/ukify/ukify.py" file) + (wrap-program file + `("PATH" ":" prefix + (,(string-append binutils "/bin") + ,(string-append sbsign "/bin")))))))))) + (inputs (list binutils python-cryptography python-pefile sbsigntools)) + (home-page "https://systemd.io") + (synopsis "Unified kernel image UEFI tool") + (description "@command{ukify} joins together a UKI stub, linux kernel, initrd, +kernel arguments, and optional secure boot signatures into a single, UEFI-bootable +image.") + (license license:lgpl2.1+))) + (define-public dtc (package (name "dtc") From patchwork Wed Jan 17 04:23:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lilah Tascheter X-Patchwork-Id: 58998 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 4ABD427BBE9; Wed, 17 Jan 2024 04:38:28 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D096727BBE2 for ; Wed, 17 Jan 2024 04:38:26 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPxgj-000267-9A; Tue, 16 Jan 2024 23:38:05 -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 1rPxgh-00025j-FN for guix-patches@gnu.org; Tue, 16 Jan 2024 23:38:03 -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 1rPxgh-0003Oq-9w for guix-patches@gnu.org; Tue, 16 Jan 2024 23:38:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rPxgh-0005L2-VE for guix-patches@gnu.org; Tue, 16 Jan 2024 23:38:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68526] [PATCH 2/2] gnu: bootloaders: Add uefi-uki-bootloader. Resent-From: Lilah Tascheter Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 17 Jan 2024 04:38:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68526 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68526@debbugs.gnu.org Cc: Lilah Tascheter X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170546625020439 (code B ref -1); Wed, 17 Jan 2024 04:38:03 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jan 2024 04:37:30 +0000 Received: from localhost ([127.0.0.1]:50363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPxg9-0005JZ-BM for submit@debbugs.gnu.org; Tue, 16 Jan 2024 23:37:29 -0500 Received: from lists.gnu.org ([2001:470:142::17]:33314) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPxg7-0005JM-5k for submit@debbugs.gnu.org; Tue, 16 Jan 2024 23:37:27 -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 1rPxfy-00021q-Tc for guix-patches@gnu.org; Tue, 16 Jan 2024 23:37:19 -0500 Received: from sendmail.purelymail.com ([34.202.193.197]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rPxfw-0003Ml-Vb for guix-patches@gnu.org; Tue, 16 Jan 2024 23:37:18 -0500 Authentication-Results: purelymail.com; auth=pass DKIM-Signature: a=rsa-sha256; b=Fkwos72jvVZG5SvfJuNiI4w1/SKRtYrD7+VYLxUFwj7c6RA+rSwRTqIPlIz0XJ+pxrIIdstSiUTeWKAtpipIVkVYH3qNKaAzsLFaktX4dwIRy7Z7dQIQInldyPEm2rDGlO9Cq3iIi6Eq0OZH+FoBCbE2Ima6AW8AfpLMVDvro1xUJv/4+KNnJL9rAcJ34faOa+jFnGFnCWEbe42a8MpwhJIcmlFNY3CnsVQqm/ZbxZbzfP4kU7EL9BEljLuNbArYSHH/MWoUF07GOG2hvysQ5GCzxO3vKE9QefHbTu3YIP3IpMLD0ojpLb/45MKRy/s9z9nV0P8WCk2UKmKhhiMM5A==; s=purelymail1; d=lunabee.space; v=1; bh=YXAJjYW2GgfCQLfFEEzTEfxGHAAk6tRnnjvDm3bPpLQ=; h=Received:From:To:Subject; DKIM-Signature: a=rsa-sha256; b=i1z3JQO48x9asa+DU1inaIn046V0TTrtq7IZ76BX37jeJjvwbo5cgbBty9VS212h0FsMkB2BqDvWlDwufCoOgCEmmcGAnjxvk2PGC+Cf0tCVHMq4h48bno6yXt9d2ZzTpdPuY1TpHaljPgoTw2FeMtowgqa73pNNl7GwQHrC36S25sBxXVmb56BKyKfsFUVnmI9JiMaeo9kBpFHrda0N2WeEA1f5WCtSNVp7qvu9/A4HMi/0wpvq/jXBHjG2H7H55OJTPJ4PV4H+jhai5nAkper1p71BtTfilhyk3x5iftpdlhy+7b6H1+dKQSffBu8UOY4xjjmk04Sz5zMHw93T1Q==; 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: guix-patches@gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -2094701616; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 17 Jan 2024 04:37:08 +0000 (UTC) Date: Tue, 16 Jan 2024 22:23:04 -0600 Message-ID: <8cad5fa9951dad5f663ca5d441db0ffc181e35fe.1705465384.git.lilah@lunabee.space> In-Reply-To: References: MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail Received-SPF: pass client-ip=34.202.193.197; envelope-from=lilah@lunabee.space; helo=sendmail.purelymail.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , X-Patchwork-Original-From: Lilah Tascheter via Guix-patches From: Lilah Tascheter Reply-To: Lilah Tascheter Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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. @cindex ARM, bootloaders @cindex AArch64, bootloaders @@ -40989,6 +40990,24 @@ Bootloader Configuration unbootable. @end quotation +@vindex uefi-uki-bootloader +@code{uefi-uki-bootloader} boots a linux kernel directly through UEFI, without +an intermediary like GRUB. The main practical advantage of this is allowing +root/store encryption without an extra GRUB password entry and slow decryption +step. + +@vindex uefi-uki-signed-bootloader +@code{uefi-uki-signed-bootloader} is like @code{uefi-uki-bootloader}, except +that it is a procedure that returns a bootloader compatible with UEFI secure +boot. You must provide it with two paths, to an out-of-store secure boot db +certificate, and key, in that order. + +@quotation Note +This bootloader @emph{does not} support booting from any old system generation. +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 directories +served by your TFTP server. @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-name))) + (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-ports)) + + (define disk + (call-with-port + (open-pipe* OPEN_READ findmnt "-fnro" "SOURCE" "-T" target) + (lambda (port) (get-line port)))) ; only 1 line: the device + + (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 vendir)) + + (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/sbsign") + "--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 privkey)))) + +(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))