summaryrefslogtreecommitdiff
path: root/modules/foundation
diff options
context:
space:
mode:
Diffstat (limited to 'modules/foundation')
-rw-r--r--modules/foundation/services.nix40
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);