diff options
Diffstat (limited to 'pkgs/run-firecracker-vm')
| -rw-r--r-- | pkgs/run-firecracker-vm/default.nix | 13 |
1 files changed, 12 insertions, 1 deletions
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); |
