Skip to content

linux: keep enough to rebuild images from vmlinux - #571170

Merged
zowoq merged 3 commits into
staging-nixosfrom
wip-emily/push-omlskzuxuzxs
Oct 11, 2026
Merged

zowoq merged 3 commits into
staging-nixosfrom
wip-emily/push-omlskzuxuzxs

Conversation

@emilazy

@emilazy emilazy commented Oct 7, 2026

Copy link
Copy Markdown
Member

This makes assembling a compressed vmlinuz.efi image after the fact on AArch64 cheap, and enables injection of certificates with scripts/insert-sys-cert.

Stacked on top of #571141 and #571142.


This is part of the end‐to‐end NixOS boot security project, funded through NGI Fediversity Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme.

Things done

@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, Atemu, AxerTheAxe, JerrySM64, balsoft, eljamm, lovesegfault, moni-dz, thiagokokada, thoughtpolice and zzzsyyy and removed request for a team October 7, 2026 04:05
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: kernel The Linux kernel labels Oct 7, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team October 7, 2026 04:11
@emilazy
emilazy force-pushed the wip-emily/push-omlskzuxuzxs branch from 9b1eff4 to d0b7646 Compare October 7, 2026 05:03
@emilazy
emilazy force-pushed the wip-emily/push-wuzktvromrzp branch from ea25ed1 to 6ebebc6 Compare October 7, 2026 05:03

@Atemu Atemu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't currently have the capacity to check this detail for myself but does this increase the outPath size which users substitute? If so, a separate output may make sense.

@emilazy

emilazy commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

For linux on x86_64-linux, the dev output goes from 623 MiB before this whole PR stack to 656 MiB after it, dominated by the 384–392 MiB unstripped vmlinux we include (and the actual delta is more like 25 MiB when taking into account the 8 MiB growth of vmlinux from the other changes in the stack).

The tricks we do to strip down the kernel source and build trees predate including the vmlinux and are probably not very high value right now; it’s just a very big output. I could narrow down the exact set of files preserved for image rebuilds to save some of the delta, but it would make it more brittle and noisy in the derivation code, so it didn’t feel worth it for a ~4% difference, especially as compression will likely reduce the gap further.

(We shouldn’t have to include the whole vmlinux, especially now that debugging tools are increasingly using the in‐kernel‐image BTF information rather than relying on a sidecar ELF, but the kernel tooling isn’t really set up to build BTF information for out‐of‐tree modules without doing so; it’d take a bit of custom fiddling to get that working without, and theoretically there are some obscure use cases that could suffer very mildly for the lack of the vmlinux. That’s out of scope for this stack, in any case, and image rebuilds are another use case for vmlinux while we have it around anyway; it would be non‐trivial additional work to stitch an image back together from the raw format it gets converted into for many non‐bzImage formats.)

@emilazy

emilazy commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

Also, to be clear, only the dev output grows bigger, and that only gets substituted if the user is e.g. building a kernel module locally, or opting in to using the image rebuilder; the usual kernel out should be unaffected.

@emilazy
emilazy force-pushed the wip-emily/push-omlskzuxuzxs branch from d0b7646 to c2a8db2 Compare October 8, 2026 17:21
@emilazy
emilazy force-pushed the wip-emily/push-wuzktvromrzp branch from 6ebebc6 to 865e4a7 Compare October 8, 2026 17:21
@emilazy
emilazy force-pushed the wip-emily/push-omlskzuxuzxs branch from c2a8db2 to 8a3d399 Compare October 10, 2026 02:00
@emilazy
emilazy force-pushed the wip-emily/push-wuzktvromrzp branch from 865e4a7 to cf4da14 Compare October 10, 2026 02:00
This makes assembling a compressed `vmlinuz.efi` image after the
fact on AArch64 cheap, and enables injection of certificates with
`scripts/insert-sys-cert`.
@emilazy
emilazy force-pushed the wip-emily/push-omlskzuxuzxs branch from 8a3d399 to 70b7136 Compare October 10, 2026 15:34
Base automatically changed from wip-emily/push-wuzktvromrzp to staging-nixos October 10, 2026 23:33
@nixpkgs-ci nixpkgs-ci Bot closed this Oct 10, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Oct 10, 2026

@nixpkgs-branch-check nixpkgs-branch-check Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR's base branch is set to staging-nixos, but this PR causes 1705 rebuilds.
It is therefore considered a mass rebuild.
Please change the base branch to the right base branch for your changes (probably staging).

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Oct 11, 2026
@zowoq
zowoq added this pull request to the merge queue Oct 11, 2026
Merged via the queue into staging-nixos with commit 48c3567 Oct 11, 2026
59 checks passed
@zowoq
zowoq deleted the wip-emily/push-omlskzuxuzxs branch October 11, 2026 22:56
@theCapypara

Copy link
Copy Markdown
Member

Commit a43236f breaks building the modules on my NixOS config:

structuredAttrs is enabled
pkgs.buildEnv error: two given paths contain a conflicting subpath:
  `/nix/store/93n5879v79ljfdhaglr8p4kxndrgmq0d-v4l2loopback-0.15.4/lib/modules/7.2.11/modules.dep' and
  `/nix/store/36c6ybh6gv1mbnfq5n5sbqy2ghbdcgsa-linux-7.2.11-modules/lib/modules/7.2.11/modules.dep'
hint: this may be caused by two different versions of the same package in buildEnv's `paths` parameter
hint: `pkgs.nix-diff` can be used to compare derivations

Confirmed this by reverting.

kernel/boot config:

  boot.kernelPackages = pkgs.linuxPackages_latest;
  boot.initrd.availableKernelModules = [
    "xhci_pci"
    "thunderbolt"
    "nvme"
    "usbhid"
    "usb_storage"
    "sd_mod"
  ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" "usblp" ];
  boot.extraModulePackages = [ ];

  hardware.enableRedistributableFirmware = true;
  boot.initrd.systemd.enable = true;
  boot.supportedFilesystems.ntfs = true;
  boot.loader.systemd-boot.enable = true;

@Ma27

Ma27 commented Oct 21, 2026

Copy link
Copy Markdown
Member

Is this all the config you've got? Including nixos-hardware stuff?

Asking because just that config builds fine for me and the v4l2loopback thing from the logs doesn't seem to be added anywhere in your config.

Tested on nixpkgs rev 191e87d

@moni-dz

moni-dz commented Oct 21, 2026

Copy link
Copy Markdown
Member

Commit a43236f breaks building the modules on my NixOS config:

structuredAttrs is enabled
pkgs.buildEnv error: two given paths contain a conflicting subpath:
  `/nix/store/93n5879v79ljfdhaglr8p4kxndrgmq0d-v4l2loopback-0.15.4/lib/modules/7.2.11/modules.dep' and
  `/nix/store/36c6ybh6gv1mbnfq5n5sbqy2ghbdcgsa-linux-7.2.11-modules/lib/modules/7.2.11/modules.dep'
hint: this may be caused by two different versions of the same package in buildEnv's `paths` parameter
hint: `pkgs.nix-diff` can be used to compare derivations

Confirmed this by reverting.

kernel/boot config:

  boot.kernelPackages = pkgs.linuxPackages_latest;
  boot.initrd.availableKernelModules = [
    "xhci_pci"
    "thunderbolt"
    "nvme"
    "usbhid"
    "usb_storage"
    "sd_mod"
  ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" "usblp" ];
  boot.extraModulePackages = [ ];

  hardware.enableRedistributableFirmware = true;
  boot.initrd.systemd.enable = true;
  boot.supportedFilesystems.ntfs = true;
  boot.loader.systemd-boot.enable = true;

this is fixed by #575861

@theCapypara

Copy link
Copy Markdown
Member

Is this all the config you've got? Including nixos-hardware stuff?

Sorry yes! I forgot I also had nixos-hardware in there.

@Ma27

Ma27 commented Oct 21, 2026

Copy link
Copy Markdown
Member

All good.
Can you confirm that a newer nixpkgs fixes the issue, please? Otherwise I'd need a new reproducer.

@Jappie3

Jappie3 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

also related: #576406

@theCapypara

Copy link
Copy Markdown
Member

I can confirm this fixes the conflict for me.

#575861 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: kernel The Linux kernel 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants