From cca1f68a4f018f913cbd33f657f84af799cf827b Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 27 Mar 2019 22:03:50 +0100 Subject: [PATCH] By default only build an image if service.image is set --- src/nix/modules/service/image.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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); }; }