From a511e64fab20700fad50dedd1f966b4605e637b5 Mon Sep 17 00:00:00 2001 From: Mel Date: Sat, 7 Dec 2024 15:42:41 +0100 Subject: Add image streaming to foundation Signed-off-by: Mel --- modules/foundation/services.nix | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/foundation/services.nix b/modules/foundation/services.nix index 061bcea..a552d9f 100644 --- a/modules/foundation/services.nix +++ b/modules/foundation/services.nix @@ -11,13 +11,19 @@ let serviceOptions = { options = { image = mkOption { - type = types.submodule { + type = types.nullOr types.package; + default = null; + }; + + fullImage = mkOption { + type = with types; nullOr (submodule { options = { - image = mkOption { type = types.str; }; - imageFile = mkOption { type = types.package; }; - base = mkOption { type = types.nullOr types.anything; }; + image = mkOption { type = str; }; + imageFile = mkOption { type = package; }; + base = mkOption { type = nullOr anything; }; }; - }; + }); + default = null; }; ports = mkOption { @@ -141,9 +147,26 @@ in in "${hostPath}:${containerPath}"; + mkImage = + { + oldImage, + imageStream, + }: + if oldImage != null then + { + inherit (oldImage) image imageFile; + } + else if imageStream != null then + { + inherit imageStream; + } + else + throw "can't use both `fullImage` and `image` together."; + mkOciContainer = { name, + fullImage, image, ports, volumes, @@ -156,7 +179,6 @@ in ... }: { - inherit (image) image imageFile; inherit entrypoint cmd @@ -170,7 +192,11 @@ in "--network-alias=${name}" "--network=${group}" ]; - }; + } + // (mkImage { + oldImage = fullImage; + imageStream = image; + }); in builtins.listToAttrs (map (v: lib.nameValuePair v.fullName (mkOciContainer v)) allServices); -- cgit 1.4.1