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 E78B8AFD6; Wed, 26 Nov 2025 18:59:18 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id B6A97AF9E; Wed, 26 Nov 2025 18:59:14 +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 34F0AAEFE for ; Wed, 26 Nov 2025 18:59:12 +0000 (UTC) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-78a8bed470bso1033107b3.0 for ; Wed, 26 Nov 2025 10:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764183550; x=1764788350; 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=9VKtzIoD9zsH4kXPBW7y/4CN97Ek2KCWvNO4CmcZ4+Q=; b=H/fDont38ArnStW+LIWqxvN1g2axOz2AHyKVNLRWmzfvhjc5sjeUlSuCPDu2EX6lLC fcVxCACN1UJht7jkchbktxDouk8xAkYNfd4sz5swJJcGDa7BDQWlasLdwQUzTZMTYWYK Ut90J8JAh6VQ84616uH+d0c7IUMiAhKhaL4mBoSPB9p8XB4NbeULMYewnDIZr/efppNj Dj/ML96dhe7jcRmRYsCOB6H45m7inbM1dRNA79RmsSxhOJt0QpgrS3NM2cZ23k3SVpsi +FvBkud0+9ast4vjqITptsWuDOwgvf71SInqZVZDgAZh+B2HCPANPoh39aWKQSNWvycL LKXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764183550; x=1764788350; 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=9VKtzIoD9zsH4kXPBW7y/4CN97Ek2KCWvNO4CmcZ4+Q=; b=M3FO5RlNSNux342ESPfXQ1RAvO9j29206+FndShv4vAZakH+3x+I/sWPxTqLi4sbxU /xqJxLv0XTinTK2SyG4+cHYpYF8J1WIOhlGogwLJCMH2V5HUHc1+MJ5sw53ivDtmcIsw nEuYWzX+1rQT3jodycAgDPgYMm+bPm+Bu0hljDscxvO+x/V/uvEkn7UuvWGkub8z4Paq 4Bopgvgh43gkpB/THh4WVVUOjPbkOZYPHUP1qZ02TzD473PVm9JSqsxzT5YuHNAwzsVM 1o6OCMgoHqK8o2TWSAMCfGqzdnb0uETh7zFDTtwLWdBfxZJfkvWK0/lDyftF/lGYxb6t KUzA== X-Gm-Message-State: AOJu0YzGXiMSzMm/ssdnF9+4sXA6P016N4dxx7kfz1ky64+VCywUhxZr sVXj4ypINKv/JextaZnNJydq6Tp7q4yslKuQrgDxdlFxv6QI7nr4dkiUvWEU2Q== X-Gm-Gg: ASbGncvjuo2unKMfenut7LAVn31H0nZDbwpLS1JPLmSS8oTR6nW0W/rvnORM+2dvJMJ uRGp/iNbt6mWAik7e4pKpLPnWlg+KtFjYGC0L1SCu5FOBmcWRUrIsbjmvyFf+lYpfgXLXuegUSw YNAMwudFb5rz7JuAgCg1PW3ElHT73Nl4J/0G9UymjfHsCmxDlM9ue9bVVGShOD63WjpQly4bopS 6kMhrb8cjl99XYAWHb6UmM0ohkuGS6ikAdHiE4xm6dBpNdYXPG/wOzoOYr0enbogGhaPWeMcdht JGknHNAeL3KuoP64zSQw5/yEm7ZxdnzSsg45aszW4XyO1x/MdW1YdkOa9r6JwZ1qYvlMQkjoOIt bq3nXPBXeleKZMLLQOVx67g7sc4GOCsWfUBwGLGrwE4fnxBuL2fDz5sinkAuk2LA39SK5XCPzUS jpRrep3/E/c5COGyH7XD8yoxrsnk9FESN1I93wt4X/CfwXLNWjOuIweT2DwL2SXcn+wYW0Qa+oi vjaq9sV9XcuyaF2JVltokDitXyTSitmuto= X-Google-Smtp-Source: AGHT+IFmQaHYKzzaVrIf2ANw64Sy0c9tiQ0rkLf4fRn1GtfxxDXprQYNvP8dQCaHTiNuiXua3LzNYQ== X-Received: by 2002:a05:690c:f92:b0:787:e779:9eb3 with SMTP id 00721157ae682-78ab6f87ab5mr125531287b3.62.1764183549741; Wed, 26 Nov 2025 10:59:09 -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 956f58d0204a3-642f71787f3sm7632978d50.16.2025.11.26.10.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 10:59:09 -0800 (PST) From: Demi Marie Obenour Date: Wed, 26 Nov 2025 13:58:24 -0500 Subject: [PATCH v5 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: <20251126-refactor-verity-v5-2-0aa3d8bd180d@gmail.com> References: <20251126-refactor-verity-v5-0-0aa3d8bd180d@gmail.com> In-Reply-To: <20251126-refactor-verity-v5-0-0aa3d8bd180d@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764183502; l=7193; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=wnNsCPjJmJI9Y+IZ1CWZJ8W+yTNFaM+j7VVLtbZmrL0=; b=Hb0ljhYAU0T1qixE+ulSCPYlLj8jPal6CrKVxHgDnpgba1xe1VC+XXZX1SsZBxU8uxv3vFkTz twlSJ0XYx+3D+yiIQYSVKgVpqI4o709soNdFIwrKn2DvJCSp0q40lHb X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: 5MFJHNOTATGVMJF2J2ACZB3SQYXUSXW3 X-Message-ID-Hash: 5MFJHNOTATGVMJF2J2ACZB3SQYXUSXW3 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. Changes since v5: - Create a temporary symlink named build/spectrum.efi and then run $(MCOPY) -i $@ build/spectrum.efi ::/EFI/Linux, rather than copying the file with its original name. The latter results in an unbootable image. I do not know the reason. Signed-off-by: Demi Marie Obenour --- host/efi.nix | 40 ++++++++++++++++++++++++++++++++++++++++ release/live/Makefile | 17 ++++------------- release/live/default.nix | 27 +++++++++++---------------- release/live/shell.nix | 10 ++++++++-- 4 files changed, 63 insertions(+), 31 deletions(-) diff --git a/host/efi.nix b/host/efi.nix new file mode 100644 index 0000000000000000000000000000000000000000..ecedb6bea6bf29c7a7303dc9062fe12b5c7a9fbd --- /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, 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/release/live/Makefile b/release/live/Makefile index ba81c7e679429e045b24c1591a9f0b72f016cfab..b37ccce42feb3ac7e8ce4faf96a67902b55be808 100644 --- a/release/live/Makefile +++ b/release/live/Makefile @@ -19,22 +19,13 @@ $(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 +# This symlink is necessary. Copying $(EFI_IMAGE) directly +# results in an unbootable image. TODO: figure out why. + ln -s $(EFI_IMAGE) build/spectrum.efi $(MCOPY) -i $@ build/spectrum.efi ::/EFI/Linux $(MCOPY) -i $@ $(SYSTEMD_BOOT_EFI) ::/EFI/BOOT/$(EFINAME) diff --git a/release/live/default.nix b/release/live/default.nix index 2a1dc3e1dd939f21edac582bf39737eb4d46eb0c..ba9bb17e697a6ecfe81e52a4ffbc375ef443b6f3 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 = rootfs; + KERNEL = "${efi.rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; + ROOT_FS = "${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 799d575b4f6e6f3dad8ac1a0a8bc2e3fc46aab44..b0bf957c085d1581a24d8916925611da0a60ec8b 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 = rootfs; + ROOT_FS = efi.rootfs; + EFI_IMAGE = efi; }; } )) (_: {}) -- 2.52.0