From 03e1f4c1c4ebe0c02a8190790b84749c1eab4a40 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Tue, 5 Mar 2019 21:26:00 +0100 Subject: [PATCH] feat: initial docker image module --- modules/default.nix | 1 + modules/docker/default.nix | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 modules/docker/default.nix diff --git a/modules/default.nix b/modules/default.nix index 85d18f5..72750db 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -5,4 +5,5 @@ istio = ./istio; testing = ./testing; helm = ./helm; + docker = ./docker; } diff --git a/modules/docker/default.nix b/modules/docker/default.nix new file mode 100644 index 0000000..dba8382 --- /dev/null +++ b/modules/docker/default.nix @@ -0,0 +1,51 @@ +{ config, lib, ... }: + +with lib; + +{ + options.docker.registry.url = mkOption { + description = "Default registry url where images are published"; + type = types.str; + }; + + 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; + default = config.docker.registry.url; + }; + }; + })); + default = {}; + }; + + options.docker.push = mkOption { + description = "List of images to push"; + type = types.listOf (types.package); + default = []; + }; + + config.docker.push = mapAttrsToList (_: i: i.image) + (filterAttrs (_: i: i.registry != null)config.docker.images); +}