From 38dec9fcff007aac9f36e596f0740ae0dcad63b7 Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 25 Jun 2025 13:08:36 +0100 Subject: [PATCH] =?UTF-8?q?makeInitrd{,NG}:=20drop=20legacy=20U=E2=80=90Bo?= =?UTF-8?q?ot=20image=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that ARMv5 no longer uses `uImage`, there’s no point in keeping around support for this deprecated format that the rest of the NixOS infrastructure doesn’t handle. Modern U‐Boot setups should not be affected in any way by this. --- .../manual/release-notes/rl-2611.section.md | 2 + .../kernel/initrd-compressor-meta.nix | 7 ---- pkgs/build-support/kernel/make-initrd-ng.nix | 38 +++++-------------- pkgs/build-support/kernel/make-initrd.nix | 33 +++++----------- pkgs/build-support/kernel/make-initrd.sh | 8 +--- 5 files changed, 21 insertions(+), 67 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2611.section.md b/nixos/doc/manual/release-notes/rl-2611.section.md index 798e204a578d..8397e17792cf 100644 --- a/nixos/doc/manual/release-notes/rl-2611.section.md +++ b/nixos/doc/manual/release-notes/rl-2611.section.md @@ -18,6 +18,8 @@ - `boot.vesa` has been removed. It was deprecated in 2020 because Xorg now works better with kernel modesetting. If you still need the legacy VESA 800x600 fallback, set `boot.kernelParams = [ "vga=0x317" "nomodeset" ];` directly. +- Support for the legacy U‐Boot image format has been removed from the initrd generators, as it is deprecated upstream and no longer used by any platform in Nixpkgs. + - Python 2 has been removed from the top-level package set, as it is long past end-of-life. The `python2`, `python27`, `python2Full`, `python27Full`, `python2Packages`, and `python27Packages` attributes, along with the legacy `python`, `pythonFull`, and `pythonPackages` aliases, now throw an error directing you to `python3`. The `isPy2` and `isPy27` package flags have been removed accordingly. The only remaining Python 2 interpreter is vendored inside the `resholve` package for its `oil` dependency and is not exposed for general use. ## Other Notable Changes {#sec-release-26.11-notable-changes} diff --git a/pkgs/build-support/kernel/initrd-compressor-meta.nix b/pkgs/build-support/kernel/initrd-compressor-meta.nix index 52e009967b50..728b9291627f 100644 --- a/pkgs/build-support/kernel/initrd-compressor-meta.nix +++ b/pkgs/build-support/kernel/initrd-compressor-meta.nix @@ -1,18 +1,15 @@ rec { cat = { executable = pkgs: "cat"; - ubootName = "none"; extension = ".cpio"; }; gzip = { executable = pkgs: "${pkgs.gzip}/bin/gzip"; defaultArgs = [ "-9n" ]; - ubootName = "gzip"; extension = ".gz"; }; bzip2 = { executable = pkgs: "${pkgs.bzip2}/bin/bzip2"; - ubootName = "bzip2"; extension = ".bz2"; }; xz = { @@ -29,24 +26,20 @@ rec { "--check=crc32" "--lzma1=dict=512KiB" ]; - ubootName = "lzma"; extension = ".lzma"; }; lz4 = { executable = pkgs: "${pkgs.lz4}/bin/lz4"; defaultArgs = [ "-l" ]; - ubootName = "lz4"; extension = ".lz4"; }; lzop = { executable = pkgs: "${pkgs.lzop}/bin/lzop"; - ubootName = "lzo"; extension = ".lzo"; }; zstd = { executable = pkgs: "${pkgs.zstd}/bin/zstd"; defaultArgs = [ "-10" ]; - ubootName = "zstd"; extension = ".zst"; }; pigz = gzip // { diff --git a/pkgs/build-support/kernel/make-initrd-ng.nix b/pkgs/build-support/kernel/make-initrd-ng.nix index 768af8f5c48d..8fe1f553c9ed 100644 --- a/pkgs/build-support/kernel/make-initrd-ng.nix +++ b/pkgs/build-support/kernel/make-initrd-ng.nix @@ -4,14 +4,13 @@ let # from it. compressors = import ./initrd-compressor-meta.nix; # Get the basename of the actual compression program from the whole - # compression command, for the purpose of guessing the u-boot + # compression command, for the purpose of guessing the # compression type and filename extension. compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1; in { stdenvNoCC, cpio, - ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, @@ -57,22 +56,13 @@ in # symlinks to store paths. prepend ? [ ], - # Whether to wrap the initramfs in a u-boot image. - makeUInitrd ? stdenvNoCC.hostPlatform.linux-kernel.target == "uImage", - - # If generating a u-boot image, the architecture to use. The default - # guess may not align with u-boot's nomenclature correctly, so it can - # be overridden. - # See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L81-106 for a list. - uInitrdArch ? stdenvNoCC.hostPlatform.ubootArch, - - # The name of the compression, as recognised by u-boot. - # See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L195-204 for a list. - # If this isn't guessed, you may want to complete the metadata above and send a PR :) - uInitrdCompression ? - _compressorMeta.ubootName - or (throw "Unrecognised compressor ${_compressorName}, please specify uInitrdCompression"), + # Deprecated; remove in 27.05. + makeUInitrd ? null, + uInitrdArch ? null, + uInitrdCompression ? null, }: +assert lib.assertMsg (makeUInitrd == null && uInitrdArch == null && uInitrdCompression == null) + "makeInitrdNg: U‐Boot legacy image support has been removed as it is deprecated upstream and ARMv5 kernels no longer default to uImage"; stdenvNoCC.mkDerivation (finalAttrs: { __structuredAttrs = true; @@ -83,11 +73,8 @@ stdenvNoCC.mkDerivation (finalAttrs: { inherit name extension - makeUInitrd - uInitrdArch prepend ; - ${if makeUInitrd then "uInitrdCompression" else null} = uInitrdCompression; compress = "${_compressorExecutable} ${lib.escapeShellArgs _compressorArgsReal}"; contentsJSON = builtins.toJSON contents; @@ -95,8 +82,7 @@ stdenvNoCC.mkDerivation (finalAttrs: { nativeBuildInputs = [ makeInitrdNGTool cpio - ] - ++ lib.optional makeUInitrd ubootTools; + ]; buildCommand = '' mkdir -p ./root/{run,tmp,var/empty} @@ -109,13 +95,7 @@ stdenvNoCC.mkDerivation (finalAttrs: { done (cd root && find . -print0 | sort -z | cpio --quiet -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd") - if [ -n "$makeUInitrd" ]; then - mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img - # Compatibility symlink - ln -sf "initrd.img" "$out/initrd" - else - ln -s "initrd" "$out/initrd$extension" - fi + ln -s "initrd" "$out/initrd$extension" ''; passthru = { diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix index 364507ba8e7e..a6624486ffbe 100644 --- a/pkgs/build-support/kernel/make-initrd.nix +++ b/pkgs/build-support/kernel/make-initrd.nix @@ -10,18 +10,16 @@ # of algorithms. let # Some metadata on various compression programs, relevant to naming - # the initramfs file and, if applicable, generating a u-boot image - # from it. + # the initramfs file. compressors = import ./initrd-compressor-meta.nix; # Get the basename of the actual compression program from the whole - # compression command, for the purpose of guessing the u-boot + # compression command, for the purpose of guessing the # compression type and filename extension. compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1; in { stdenvNoCC, cpio, - ubootTools, lib, pkgsBuildHost, # Name of the derivation (not of the resulting file!) @@ -65,22 +63,13 @@ in # symlinks to store paths. prepend ? [ ], - # Whether to wrap the initramfs in a u-boot image. - makeUInitrd ? stdenvNoCC.hostPlatform.linux-kernel.target or "dummy" == "uImage", - - # If generating a u-boot image, the architecture to use. The default - # guess may not align with u-boot's nomenclature correctly, so it can - # be overridden. - # See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L81-106 for a list. - uInitrdArch ? stdenvNoCC.hostPlatform.linuxArch, - - # The name of the compression, as recognised by u-boot. - # See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L195-204 for a list. - # If this isn't guessed, you may want to complete the metadata above and send a PR :) - uInitrdCompression ? - _compressorMeta.ubootName - or (throw "Unrecognised compressor ${_compressorName}, please specify uInitrdCompression"), + # Deprecated; remove in 27.05. + makeUInitrd ? null, + uInitrdArch ? null, + uInitrdCompression ? null, }: +assert lib.assertMsg (makeUInitrd == null && uInitrdArch == null && uInitrdCompression == null) + "makeInitrd: U‐Boot legacy image support has been removed as it is deprecated upstream and ARMv5 kernels no longer default to uImage"; stdenvNoCC.mkDerivation (finalAttrs: { __structuredAttrs = true; @@ -91,18 +80,14 @@ stdenvNoCC.mkDerivation (finalAttrs: { inherit name extension - makeUInitrd - uInitrdArch prepend ; - ${if makeUInitrd then "uInitrdCompression" else null} = uInitrdCompression; builder = ./make-initrd.sh; nativeBuildInputs = [ cpio - ] - ++ lib.optional makeUInitrd ubootTools; + ]; compress = "${_compressorExecutable} ${lib.escapeShellArgs _compressorArgsReal}"; diff --git a/pkgs/build-support/kernel/make-initrd.sh b/pkgs/build-support/kernel/make-initrd.sh index f3bc977279b5..cc30ba0175db 100644 --- a/pkgs/build-support/kernel/make-initrd.sh +++ b/pkgs/build-support/kernel/make-initrd.sh @@ -36,10 +36,4 @@ done (cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +) (cd root && find * .[^.*] -print0 | sort -z | cpio --quiet -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd") -if [ -n "$makeUInitrd" ]; then - mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img - # Compatibility symlink - ln -sf "initrd.img" "$out/initrd" -else - ln -s "initrd" "$out/initrd$extension" -fi +ln -s "initrd" "$out/initrd$extension"