kubenix/modules/docker/default.nix

64 lines
1.7 KiB
Nix
Raw Normal View History

2019-03-05 21:26:00 +01:00
{ config, lib, ... }:
with lib;
2019-03-05 22:08:26 +01:00
let
globalConfig = config;
in {
2019-03-05 21:26:00 +01:00
options.docker.registry.url = mkOption {
description = "Default registry url where images are published";
type = types.str;
2019-03-05 22:08:26 +01:00
default = "";
2019-03-05 21:26:00 +01:00
};
options.docker.images = mkOption {
description = "Attribute set of docker images that should be published";
type = types.attrsOf (types.submodule ({ name, config, ... }: {
options = {
image = mkOption {
description = "Docker image to publish";
type = types.nullOr types.package;
default = null;
};
name = mkOption {
description = "Desired docker image name";
type = types.str;
default = builtins.unsafeDiscardStringContext config.image.imageName;
};
tag = mkOption {
description = "Desired docker image tag";
type = types.str;
default = builtins.unsafeDiscardStringContext config.image.imageTag;
};
registry = mkOption {
description = "Docker registry url where image is published";
type = types.str;
2019-03-05 22:08:26 +01:00
default = globalConfig.docker.registry.url;
};
path = mkOption {
description = "Full docker image path";
type = types.str;
default =
if config.registry != ""
then "${config.registry}/${config.name}:${config.tag}"
else "${config.name}:${config.tag}";
2019-03-05 21:26:00 +01:00
};
};
}));
default = {};
};
2019-03-05 22:08:26 +01:00
options.docker.export = mkOption {
description = "List of images to export";
2019-03-05 21:26:00 +01:00
type = types.listOf (types.package);
default = [];
};
2019-03-05 22:08:26 +01:00
config.docker.export = mapAttrsToList (_: i: i.image)
2019-03-05 21:26:00 +01:00
(filterAttrs (_: i: i.registry != null)config.docker.images);
}