aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-21 05:09:55 +0000
committertv <tv@krebsco.de>2026-11-21 05:09:55 +0000
commit9c6d26a412be3b91c5e24c7f080da2d35f7b226d (patch)
treef2cbab31a4b7948cea026ed654ae06ee0a89b548 /pkgs
parent86d6f7341fedd5e0e78969d2c37829a0012dc3ae (diff)
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.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/run-firecracker-vm/default.nix10
1 files changed, 8 insertions, 2 deletions
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/||' \