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 | |
| parent | c8384c12e16efe49673c4e905d5feeea6615b6b4 (diff) | |
| download | network-a511e64fab20700fad50dedd1f966b4605e637b5.tar.zst network-a511e64fab20700fad50dedd1f966b4605e637b5.zip | |
Add image streaming to foundation
Signed-off-by: Mel <einebeere@gmail.com>
| -rw-r--r-- | modules/foundation/services.nix | 40 | ||||
| -rw-r--r-- | services/cgit.nix | 2 | ||||
| -rw-r--r-- | services/pds.nix | 2 |
3 files changed, 35 insertions, 9 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); diff --git a/services/cgit.nix b/services/cgit.nix index 8b87f80..a60b0e7 100644 --- a/services/cgit.nix +++ b/services/cgit.nix @@ -36,7 +36,7 @@ let in { foundation.services.cgit = { - image = { imageFile = cgitImage; image = "cgit:${cgit.version}"; }; + fullImage = { imageFile = cgitImage; image = "cgit:${cgit.version}"; }; ports = [ [ cgitLocalPort 80 ] ]; volumes = [ diff --git a/services/pds.nix b/services/pds.nix index 45be843..68ca66a 100644 --- a/services/pds.nix +++ b/services/pds.nix @@ -30,7 +30,7 @@ in }; foundation.services.pds = { - image = { imageFile = pdsImage; image = "pds:${pds.version}"; }; + fullImage = { imageFile = pdsImage; image = "pds:${pds.version}"; }; ports = [ [ pdsLocalPort 3000 ] ]; volumes = [ |
