Build tooling around nix-snapshotter

This commit is contained in:
Pim Kunis 2024-08-29 06:53:05 +02:00
parent e9899c0d0f
commit 04439a9ee5
6 changed files with 39 additions and 43 deletions

View file

@ -1,4 +1,4 @@
{ self, inputs, pkgs, lib, config, ... }:
{ self, myLib, inputs, pkgs, lib, config, ... }:
let
cfg = config.lab.k3s;
in
@ -167,12 +167,11 @@ in
docker-images.text =
let
imageLinkDir = "/var/docker_images";
imageDefs = import "${self}/container-images.nix";
setupCommands = [
"rm -rf ${imageLinkDir}"
"mkdir -p ${imageLinkDir}"
"rm -rf ${myLib.globals.imageDir}"
"mkdir -p ${myLib.globals.imageDir}"
];
getDockerImageConfig = dockerImage:
@ -196,12 +195,15 @@ in
fromImage = dockerImage;
config = getDockerImageConfig dockerImage;
};
imageLinkPath = "${imageLinkDir}/${name}.tar";
imageLinkPath = "${myLib.globals.imageDir}/${name}.tar";
in
"ln -sf ${nixSnapshotterImage} ${imageLinkPath}";
linkCommandList = lib.attrsets.mapAttrsToList imageDefToLinkCommand imageDefs;
commandList = setupCommands ++ linkCommandList;
# TODO: Creating Docker images like this seems to *explode* in size.
# Doing this for every image we currently have is infeasible.
# I should investigate why the size increases like that.
commandList = setupCommands; # ++ linkCommandList;
in
builtins.concatStringsSep "\n" commandList;
};