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
|
lib.filterAttrs filterFunction config.docker-compose.evaluatedServices
|
||||||
);
|
);
|
||||||
|
|
||||||
filterFunction = _serviceName: service:
|
filterFunction = serviceName: service:
|
||||||
service.config.image.nixBuild;
|
builtins.addErrorContext "while evaluating whether the service ${serviceName} defines an image"
|
||||||
|
service.config.image.nixBuild;
|
||||||
|
|
||||||
addDetails = _serviceName: service:
|
addDetails = serviceName: service:
|
||||||
let
|
builtins.addErrorContext "while evaluating the image for service ${serviceName}"
|
||||||
|
(let
|
||||||
inherit (service.config) build;
|
inherit (service.config) build;
|
||||||
in {
|
in {
|
||||||
image = build.image.outPath;
|
image = build.image.outPath;
|
||||||
|
@ -20,7 +22,7 @@ let
|
||||||
if build.image.imageTag != ""
|
if build.image.imageTag != ""
|
||||||
then build.image.imageTag
|
then build.image.imageTag
|
||||||
else lib.head (lib.strings.splitString "-" (baseNameOf build.image.outPath));
|
else lib.head (lib.strings.splitString "-" (baseNameOf build.image.outPath));
|
||||||
};
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, lib, config, ... }:
|
{ pkgs, lib, config, options, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) types mkOption;
|
inherit (lib) types mkOption;
|
||||||
inherit (types) attrsOf listOf nullOr package str unspecified bool;
|
inherit (types) attrsOf listOf nullOr package str unspecified bool;
|
||||||
|
@ -32,6 +32,8 @@ let
|
||||||
done;
|
done;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
priorityIsDefault = option: option.highestPrio >= (lib.mkDefault true).priority;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -58,8 +60,11 @@ in
|
||||||
Whether to build this image with Nixpkgs'
|
Whether to build this image with Nixpkgs'
|
||||||
<code>dockerTools.buildLayeredImage</code>
|
<code>dockerTools.buildLayeredImage</code>
|
||||||
and then load it with <code>docker load</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 {
|
image.name = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
|
@ -111,5 +116,7 @@ in
|
||||||
|
|
||||||
service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}";
|
service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}";
|
||||||
image.rawConfig.Cmd = config.image.command;
|
image.rawConfig.Cmd = config.image.command;
|
||||||
|
|
||||||
|
image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue