diff --git a/src/nix/modules/service/docker-compose-service.nix b/src/nix/modules/service/docker-compose-service.nix index 061ae8b..c038ac6 100644 --- a/src/nix/modules/service/docker-compose-service.nix +++ b/src/nix/modules/service/docker-compose-service.nix @@ -86,7 +86,8 @@ in description = serviceRef "environment"; }; service.image = mkOption { - type = str; + type = nullOr str; + default = null; description = serviceRef "image"; }; service.command = mkOption { @@ -328,8 +329,9 @@ in volumes environment sysctls - image ; + } // lib.optionalAttrs (config.service.image != null) { + inherit (config.service) image; } // lib.optionalAttrs (config.service.build.context != null) { inherit (config.service) build; } // lib.optionalAttrs (cap_add != []) { diff --git a/src/nix/modules/service/image.nix b/src/nix/modules/service/image.nix index 706a5c1..ae5d214 100644 --- a/src/nix/modules/service/image.nix +++ b/src/nix/modules/service/image.nix @@ -163,17 +163,19 @@ in ''; }; }; - config = { - build.image = builtImage; - build.imageName = config.build.image.imageName; - build.imageTag = - if config.build.image.imageTag != "" - then config.build.image.imageTag - else lib.head (lib.strings.splitString "-" (baseNameOf config.build.image.outPath)); - - service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}"; - image.rawConfig.Cmd = config.image.command; - - image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image); - }; + config = lib.mkMerge [{ + build.image = builtImage; + build.imageName = config.build.image.imageName; + build.imageTag = + if config.build.image.imageTag != "" + then config.build.image.imageTag + else lib.head (lib.strings.splitString "-" (baseNameOf config.build.image.outPath)); + image.rawConfig.Cmd = config.image.command; + image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image); + } + ( lib.mkIf (config.service.build.context == null) + { + service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}"; + }) + ]; } diff --git a/tests/arion-test/default.nix b/tests/arion-test/default.nix index 75f940d..f8ba4c3 100644 --- a/tests/arion-test/default.nix +++ b/tests/arion-test/default.nix @@ -29,7 +29,7 @@ in enable = true; dockerSocket.enable = true; }; - + # no caches, because no internet nix.settings.substituters = lib.mkForce [];