From 9c6d26a412be3b91c5e24c7f080da2d35f7b226d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 21 Nov 2026 05:09:55 +0000 Subject: run-firecracker-vm: no initrds in the images Each layer's system links its own initrd, so each layer's image had one, 19 to 25M, but the guest never reads any of them: Firecracker gets the initrd from the host. Now the images leave all of the systems' initrds out; with nix, the top system's is still in the host's store, where the registration says it is. --- pkgs/run-firecracker-vm/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pkgs/run-firecracker-vm/default.nix') diff --git a/pkgs/run-firecracker-vm/default.nix b/pkgs/run-firecracker-vm/default.nix index b9a2984..dbdf2b6 100644 --- a/pkgs/run-firecracker-vm/default.nix +++ b/pkgs/run-firecracker-vm/default.nix @@ -319,14 +319,20 @@ let layerNames = [ null ] ++ map layerName layers; # the base system: none # Layer k's image: the store paths of its system's closure that aren't - # in the closures of the layers below, as erofs image. + # in the closures of the layers below, as erofs image. Without any of + # the systems' initrds, which Firecracker gets from the host, and which + # the guest never reads (for nix, the host's store still has them). + initrds = map (s: "${s.config.system.build.initialRamdisk}") systems; images = lib.imap0 (k: top: let name = lib.elemAt layerNames k; in pkgs.runCommand "firecracker-layer-${toString k}${lib.optionalString (name != null) "-${lib.strings.sanitizeDerivationName name}"}.img" { nativeBuildInputs = [ pkgs.erofs-utils pkgs.gnutar ]; closure = pkgs.closureInfo { rootPaths = [ top ]; }; below = map (t: pkgs.closureInfo { rootPaths = [ t ]; }) (lib.take k toplevels); + inherit initrds; } '' - for b in $below; do cat $b/store-paths; done | sort -u > below + for b in $below; do cat $b/store-paths; done > below + printf '%s\n' $initrds >> below + sort -u -o below below sort $closure/store-paths | comm -23 - below | tar -c -P --verbatim-files-from \ --transform 'flags=rSh;s|^/nix/store/||' \ -- cgit v1.3.1