diff --git a/src/nix/modules/composition/images.nix b/src/nix/modules/composition/images.nix
index 9a9b04c..bedf8e8 100644
--- a/src/nix/modules/composition/images.nix
+++ b/src/nix/modules/composition/images.nix
@@ -7,11 +7,13 @@ let
lib.filterAttrs filterFunction config.docker-compose.evaluatedServices
);
- filterFunction = _serviceName: service:
- service.config.image.nixBuild;
+ filterFunction = serviceName: service:
+ builtins.addErrorContext "while evaluating whether the service ${serviceName} defines an image"
+ service.config.image.nixBuild;
- addDetails = _serviceName: service:
- let
+ addDetails = serviceName: service:
+ builtins.addErrorContext "while evaluating the image for service ${serviceName}"
+ (let
inherit (service.config) build;
in {
image = build.image.outPath;
@@ -20,7 +22,7 @@ let
if build.image.imageTag != ""
then build.image.imageTag
else lib.head (lib.strings.splitString "-" (baseNameOf build.image.outPath));
- };
+ });
in
{
options = {
diff --git a/src/nix/modules/service/image.nix b/src/nix/modules/service/image.nix
index f530165..a3b91b5 100644
--- a/src/nix/modules/service/image.nix
+++ b/src/nix/modules/service/image.nix
@@ -1,4 +1,4 @@
-{ pkgs, lib, config, ... }:
+{ pkgs, lib, config, options, ... }:
let
inherit (lib) types mkOption;
inherit (types) attrsOf listOf nullOr package str unspecified bool;
@@ -32,6 +32,8 @@ let
done;
'';
};
+
+ priorityIsDefault = option: option.highestPrio >= (lib.mkDefault true).priority;
in
{
options = {
@@ -58,8 +60,11 @@ in
Whether to build this image with Nixpkgs'
dockerTools.buildLayeredImage
and then load it with docker load
.
+
+ By default, an image will be built with Nix unless
+ is set. See also , which defaults to
+ the service name.
'';
- default = true;
};
image.name = mkOption {
type = str;
@@ -111,5 +116,7 @@ in
service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}";
image.rawConfig.Cmd = config.image.command;
+
+ image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image);
};
}