summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--modules/foundation/services.nix40
-rw-r--r--services/cgit.nix2
-rw-r--r--services/pds.nix2
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 = [