diff options
| author | Mel <einebeere@gmail.com> | 2024-12-07 15:42:41 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2024-12-07 15:42:41 +0100 |
| commit | a511e64fab20700fad50dedd1f966b4605e637b5 (patch) | |
| tree | 2142d27140d0cedd85c6b3d8880c1952a30d5ed5 /modules/foundation | |
| parent | c8384c12e16efe49673c4e905d5feeea6615b6b4 (diff) | |
| download | network-a511e64fab20700fad50dedd1f966b4605e637b5.tar.zst network-a511e64fab20700fad50dedd1f966b4605e637b5.zip | |
Add image streaming to foundation
Signed-off-by: Mel <einebeere@gmail.com>
Diffstat (limited to 'modules/foundation')
| -rw-r--r-- | modules/foundation/services.nix | 40 |
1 files changed, 33 insertions, 7 deletions
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); |
