From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id A97901B3A7; Wed, 19 Nov 2025 08:16:34 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 733B71B407; Wed, 19 Nov 2025 08:16:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by atuin.qyliss.net (Postfix) with ESMTPS id 776371B405 for ; Wed, 19 Nov 2025 08:16:30 +0000 (UTC) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-787f28f89faso61266997b3.1 for ; Wed, 19 Nov 2025 00:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763540188; x=1764144988; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=W4fxbK0t1sill7/hwXyvkB4VM4q9sn39YfIMw7rhrlc=; b=BjmLDNKGycvJKHKuRla+jJAw9y6tSHeOwpqS0W+Esdnk6kDUJwEA6WYnqF2pJWo7Uk XTSaRGirLMHrXNdx0/ZNjtDz17N0uCzGufU0+TqttQLzZyFIb0OIdBAhWrmvG2OOfgNU WUSaC1a9C2/Hflz4vvn9zvtWvZFgL1cQFsmAwDvqOn+wnjd8APguXbXYDzFtAtGz+rVR FWKT2vLDiUKdufxJR4vXcbNqYd7uUYgDNlFjDiXbiffVWcLG4fHbKtbwuwxkkNQpECG/ Eo1vDbLqqUUhcLfFOMEu2fvVtUTRIzWZBVEPvAyqLwnssjemkPloFSdyT/DzpsV0RVnU mY5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763540188; x=1764144988; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=W4fxbK0t1sill7/hwXyvkB4VM4q9sn39YfIMw7rhrlc=; b=cvWczU+VDm/hNQ0t8j+g7hPjJOR+EGC6Xkldk/PGe69n1Tl8gRpmASgm2E7rv0ZiQa OLTIX2coWMOlRybynKTIpy00d+yMLC1SHo5SIZ0OykSX70vKyCYnYU2DnkVDBggVT+TH Y/w1OE9su0vHxpRKE4EEqUWoz2QsCf9QCp1WiOmoyt2yYvvIUPK8gGtwULUwxdRZObSs MFnyJuluYnwFn2XVK7oRlPa2acipn6m/llGVsXhp+drqj4t+E12ALqgAk3XK+BLpu/0V hAy+Xx/SJMwnuduUrktdg4lYC6TPtAzfFVeGXUMOTTxTVT6ZZI2cebv02Y5LXmPZg5bM z+ag== X-Gm-Message-State: AOJu0YxqjKAqrWWBRkXmecSl7mRW3PNDU9yUnQgRDVuhlP/2T0EYPkSq ZTtViWEAuk2jjx9jcun4mkEat77Xc8duaWoChR5zNeMaxIbN1xiTm4l92z6s8Q== X-Gm-Gg: ASbGnctRZp2SHYRrLFx1CFwIGX09NcrOrsbjD+wiBs51albsWGwAY6v5DiHNhXYpAbv CauXrlbXs3T7YBGmRTcxuQCzLBCF2g9ViT36vPbqRF4Ahg4rZ+xvChr+Y2knlaxRGKzzx0wCxYU QMHcJFlF9e34DDhhiZJ3u5ZoNUKoG8MTPnFdBx3UwkhmprFtn5yCetTcx3wTF+Icm194UzMFIk+ YK86Lw1o9d3T+tFwUf4TMiD5G1swQFSXNpzWyZho8MErsqLvEgUeaA6M8u/viYdzadzvkDj8YNV 6h7n2grky3FoupXao3Zq5MzkOY6dea4vfiN3oTBIj6Upd3oP/TSdRD6oS3smsn+nXKPWMgJisz+ CVJ5IOTOZj2gwvlW/LEItuWmjpMCV0VNV1hl0r7SPPFOyjphGf5RhJYmtf0NHTbSrk2KAFlighX ju6BL0f1xBbmADboJI8urIuHZqpJ+GKzUMPBoGBIid2d8g7BcMutwm55LPo+uVW3a4K7rN/wyxA 1GB5jU3NDnx8XSsubK8FAUyidqLfBEzEe2Xov2DdRuy0Q== X-Google-Smtp-Source: AGHT+IG8dsYfAXX5XzSJ/CPcVRf9U7QI8wPhNMhp/tzuS9Sbbob88HsjHbe7RASCuAa/3WQTVLyvaQ== X-Received: by 2002:a05:690c:c92:b0:786:66e4:ccba with SMTP id 00721157ae682-78929f4eeb9mr162649567b3.57.1763540188027; Wed, 19 Nov 2025 00:16:28 -0800 (PST) Received: from localhost.localdomain (h96-60-249-169.cncrtn.broadband.dynamic.tds.net. [96.60.249.169]) by smtp.gmail.com with UTF8SMTPSA id 00721157ae682-78821de192asm60713747b3.8.2025.11.19.00.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 00:16:27 -0800 (PST) From: Demi Marie Obenour Date: Wed, 19 Nov 2025 03:15:59 -0500 Subject: [PATCH v4 2/2] Move UKI creation to a separate derivation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251119-refactor-verity-v4-2-9bc56d5216c0@gmail.com> References: <20251119-refactor-verity-v4-0-9bc56d5216c0@gmail.com> In-Reply-To: <20251119-refactor-verity-v4-0-9bc56d5216c0@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763540157; l=8052; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=/1K1EYZNCnmKw/yGbHL8yIaNFIQF8meWrbLXtfYvNcc=; b=jaxa2ls6HFGvvMaE7TvipdWUSMLekDU5KwYx6nY4aucfa315LBt7U4xC32ZWRraMaAPBb68Jp 70uyAEbSpwWB99K1M2mUfDc1XOLCo8MYhnXDwdyaJskevgMmhSJVi+I X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: I6VI5YSIRPFJBJRYBBMS5TV5I5A52T4N X-Message-ID-Hash: I6VI5YSIRPFJBJRYBBMS5TV5I5A52T4N X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Demi Marie Obenour , Alyssa Ross X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: It will be used by the update code later. No functional change intended, other than a trivial shell script refactoring. Signed-off-by: Demi Marie Obenour --- I kept release/live/default.nix using the UKI's systemd because the old code did it that way. Changing this would be better in a separate commit. --- host/efi.nix | 40 ++++++++++++++++++++++++++++++++++++++++ host/rootfs/Makefile | 8 ++++---- release/live/Makefile | 16 ++-------------- release/live/default.nix | 27 +++++++++++---------------- release/live/shell.nix | 10 ++++++++-- 5 files changed, 65 insertions(+), 36 deletions(-) diff --git a/host/efi.nix b/host/efi.nix new file mode 100644 index 0000000000000000000000000000000000000000..d0ce260bd908c186059b75a1b4f42258b0e62bff --- /dev/null +++ b/host/efi.nix @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2021-2024 Alyssa Ross +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour + +import ../lib/call-package.nix ( +{ callSpectrumPackage, config, cryptsetup, rootfs +, runCommand, stdenv, systemdUkify +}: +let + initramfs = callSpectrumPackage ./initramfs {}; + kernel = "${rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; + systemd = systemdUkify.overrideAttrs ({ mesonFlags ? [], ... }: { + # The default limit is too low to build a generic aarch64 distro image: + # https://github.com/systemd/systemd/pull/37417 + mesonFlags = mesonFlags ++ [ "-Defi-stub-extra-sections=3000" ]; + }); +in + +runCommand "spectrum-efi" { + nativeBuildInputs = [ cryptsetup systemd ]; + __structuredAttrs = true; + unsafeDiscardReferences = { out = true; }; + dontFixup = true; + passthru = { inherit initramfs rootfs systemd; }; +} '' + read -r roothash < ${rootfs}/rootfs.verity.roothash + { \ + printf "[UKI]\nDeviceTreeAuto=" + if [ -d ${rootfs.kernel}/dtbs ]; then + find ${rootfs.kernel}/dtbs -name '*.dtb' -print0 | tr '\0' ' ' + fi + } | ukify build \ + --output "$out" \ + --config /dev/stdin \ + --linux ${kernel} \ + --initrd ${initramfs} \ + --os-release $'NAME="Spectrum"\n' \ + --cmdline "ro intel_iommu=on roothash=$roothash" + '' +) (_: {}) diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index 055185064d84d9450c2076fdeb410b21d00f1d40..4c14d3acfa8f7ffd276fdfb684d08bf58fd80a15 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -46,6 +46,10 @@ FIFOS = etc/s6-linux-init/run-image/service/s6-svscan-log/fifo BUILD_FILES = build/etc/s6-rc +# This rule produces three files but Make only (portably) +# supports one output per rule. Instead of resorting to temporary +# files, a timestamp file is created as the last step. The actual +# outputs are produced as side-effects. build/verity-timestamp: $(ROOT_FS) $(VERITYSETUP) format \ --root-hash-file $(ROOT_FS_VERITY_ROOTHASH) \ @@ -54,10 +58,6 @@ build/verity-timestamp: $(ROOT_FS) echo >> $(ROOT_FS_VERITY_ROOTHASH) touch -- $(ROOT_FS_DIR)/verity-timestamp -# This rule produces three files but Make only (portably) -# supports one output per rule. Instead of resorting to temporary -# files, a timestamp file is created as the last step. The actual -# outputs are produced as side-effects. $(ROOT_FS): ../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUILD_FILES) build/empty build/fifo file-list.mk mkdir -p $(ROOT_FS_DIR) && \ { \ diff --git a/release/live/Makefile b/release/live/Makefile index 7372b41d94bfb10f7761955d9d1a246e9785b7f8..d61248e94599adc5229d0ad38d54b9f649d66ca1 100644 --- a/release/live/Makefile +++ b/release/live/Makefile @@ -19,23 +19,11 @@ $(dest): ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sf build/empty: mkdir -p $@ -build/spectrum.efi: $(DTBS) $(KERNEL) $(INITRAMFS) $(ROOT_FS_VERITY_ROOTHASH) - { \ - printf "[UKI]\nDeviceTreeAuto=" && \ - find $(DTBS) -name '*.dtb' -print0 | tr '\0' ' ' ;\ - } | $(UKIFY) build \ - --output $@ \ - --config /dev/stdin \ - --linux $(KERNEL) \ - --initrd $(INITRAMFS) \ - --os-release $$'NAME="Spectrum"\n' \ - --cmdline "ro intel_iommu=on roothash=$$(cat $(ROOT_FS_VERITY_ROOTHASH))" - -build/boot.fat: $(SYSTEMD_BOOT_EFI) build/spectrum.efi +build/boot.fat: $(SYSTEMD_BOOT_EFI) $(EFI_IMAGE) build/empty $(TRUNCATE) -s 440401920 $@ $(MKFS_FAT) $@ $(MMD) -i $@ ::/EFI ::/EFI/BOOT ::/EFI/Linux - $(MCOPY) -i $@ build/spectrum.efi ::/EFI/Linux + $(MCOPY) -i $@ $(EFI_IMAGE) ::/EFI/Linux/spectrum.efi $(MCOPY) -i $@ $(SYSTEMD_BOOT_EFI) ::/EFI/BOOT/$(EFINAME) clean: diff --git a/release/live/default.nix b/release/live/default.nix index 7adaefef330daf11372cff0d2d04cca400efba1f..ac2d7a55fd4fe0c02108309ecea20e368000af0d 100644 --- a/release/live/default.nix +++ b/release/live/default.nix @@ -3,10 +3,9 @@ # SPDX-FileCopyrightText: 2022 Unikie import ../../lib/call-package.nix ( -{ callSpectrumPackage, spectrum-build-tools, rootfs, src +{ callSpectrumPackage, spectrum-build-tools, src , lib, pkgsStatic, stdenvNoCC , cryptsetup, dosfstools, jq, mtools, util-linux -, systemdUkify }: let @@ -14,14 +13,12 @@ let stdenv = stdenvNoCC; - systemd = systemdUkify.overrideAttrs ({ mesonFlags ? [], ... }: { - # The default limit is too low to build a generic aarch64 distro image: - # https://github.com/systemd/systemd/pull/37417 - mesonFlags = mesonFlags ++ [ "-Defi-stub-extra-sections=3000" ]; - }); - - initramfs = callSpectrumPackage ../../host/initramfs {}; efiArch = stdenv.hostPlatform.efiArch; + + efi = callSpectrumPackage ../../host/efi.nix {}; + + # The initramfs and rootfs must match those used to build the UKI. + inherit (efi) initramfs rootfs systemd; in stdenv.mkDerivation { @@ -40,17 +37,15 @@ stdenv.mkDerivation { sourceRoot = "source/release/live"; nativeBuildInputs = [ - cryptsetup dosfstools jq spectrum-build-tools mtools systemd util-linux + cryptsetup dosfstools jq spectrum-build-tools mtools util-linux ]; env = { - INITRAMFS = initramfs; - KERNEL = "${rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; - ROOT_FS_DIR = rootfs; + KERNEL = "${efi.rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; + ROOT_FS_DIR = "${efi.rootfs}"; SYSTEMD_BOOT_EFI = "${systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi"; + EFI_IMAGE = efi; EFINAME = "BOOT${toUpper efiArch}.EFI"; - } // lib.optionalAttrs stdenv.hostPlatform.linux-kernel.DTB or false { - DTBS = "${rootfs.kernel}/dtbs"; }; buildFlags = [ "dest=$(out)" ]; @@ -63,6 +58,6 @@ stdenv.mkDerivation { unsafeDiscardReferences = { out = true; }; dontFixup = true; - passthru = { inherit initramfs rootfs; }; + passthru = { inherit efi initramfs rootfs; }; } ) (_: {}) diff --git a/release/live/shell.nix b/release/live/shell.nix index c5db7b732ef048b4c0cb87a4c5ea614e993db516..ffaa9a571c662810348822a5952d479d251a25e5 100644 --- a/release/live/shell.nix +++ b/release/live/shell.nix @@ -1,7 +1,12 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2024 Alyssa Ross -import ../../lib/call-package.nix ({ callSpectrumPackage, stdenv, qemu_kvm, rootfs }: +import ../../lib/call-package.nix ( +{ callSpectrumPackage, stdenv, qemu_kvm }: + +let + efi = callSpectrumPackage ../../host/efi.nix {}; +in (callSpectrumPackage ./. {}).overrideAttrs ( { nativeBuildInputs ? [], env ? {}, ... }: @@ -10,7 +15,8 @@ import ../../lib/call-package.nix ({ callSpectrumPackage, stdenv, qemu_kvm, root env = env // { OVMF_CODE = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd"; - ROOT_FS_DIR = rootfs; + ROOT_FS_DIR = efi.rootfs; + EFI_IMAGE = efi; }; } )) (_: {}) -- 2.52.0