Merge pull request #31 from hercules-ci/fix-image-nixBuild-default
Fix image nix build default
This commit is contained in:
commit
fbf57b4489
2 changed files with 16 additions and 7 deletions
|
@ -7,11 +7,13 @@ let
|
|||
lib.filterAttrs filterFunction config.docker-compose.evaluatedServices
|
||||
);
|
||||
|
||||
filterFunction = _serviceName: service:
|
||||
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 = {
|
||||
|
|
|
@ -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'
|
||||
<code>dockerTools.buildLayeredImage</code>
|
||||
and then load it with <code>docker load</code>.
|
||||
|
||||
By default, an image will be built with Nix unless <option>service.image</option>
|
||||
is set. See also <option>image.name</option>, 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);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue