From 1d1e32b91fca92e32ab95474dcfdddf43bf03193 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 20 Nov 2026 05:09:07 +0000 Subject: run-firecracker-vm: name layer images after their files A layer's image is now firecracker-layer-K-NAME.img, NAME being the layer's file name without .nix (or, for .../NAME/default.nix, NAME). Layers that aren't files, and the base system, keep just the number. --- pkgs/run-firecracker-vm/default.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (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 b7eae84..a0aae13 100644 --- a/pkgs/run-firecracker-vm/default.nix +++ b/pkgs/run-firecracker-vm/default.nix @@ -323,9 +323,20 @@ let toplevels = map (s: s.config.system.build.toplevel) systems; inherit (nixos.config.system.build) toplevel kernel initialRamdisk; + # A layer's name, for its image's: its file's, if it's a file (for + # .../NAME/default.nix, NAME). + layerName = m: + if builtins.isPath m || builtins.isString m && lib.hasPrefix "/" m then + let file = baseNameOf (toString m); in + if file == "default.nix" then baseNameOf (dirOf (toString m)) + else lib.removeSuffix ".nix" file + else null; + 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. - images = lib.imap0 (k: top: pkgs.runCommand "firecracker-layer-${toString k}.img" { + 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); -- cgit v1.3.1