36 lines
708 B
Nix
36 lines
708 B
Nix
![]() |
{ lib, writeErofs }:
|
||
|
{
|
||
|
layers,
|
||
|
labelLower ? "base",
|
||
|
labelUpper ? "image",
|
||
|
}:
|
||
|
|
||
|
let
|
||
|
inherit (lib.lists) toList;
|
||
|
nLayers = builtins.length layers;
|
||
|
mkLabel = seq: if seq + 1 < nLayers then labelLower + toString seq else labelUpper;
|
||
|
f =
|
||
|
{
|
||
|
roots ? [ ],
|
||
|
layers ? [ ],
|
||
|
seq ? 0,
|
||
|
}:
|
||
|
newRoots: {
|
||
|
seq = seq + 1;
|
||
|
roots = roots ++ (toList newRoots);
|
||
|
layers = layers ++ [
|
||
|
(writeErofs ({
|
||
|
roots = toList newRoots;
|
||
|
rootsExclude = roots;
|
||
|
passthru = {
|
||
|
inherit seq;
|
||
|
label = mkLabel seq;
|
||
|
};
|
||
|
label = mkLabel seq;
|
||
|
}))
|
||
|
];
|
||
|
};
|
||
|
acc = lib.foldl f { } layers;
|
||
|
in
|
||
|
acc.layers
|