2019-01-20 12:22:28 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
This service-level module defines the build.service option, using
|
|
|
|
the user-facing options service.image, service.volumes, etc.
|
|
|
|
|
|
|
|
*/
|
2018-12-17 19:08:38 +01:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mkOption types;
|
2019-02-03 21:07:00 +02:00
|
|
|
inherit (types) listOf nullOr attrsOf string either int bool;
|
2018-12-17 19:08:38 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
service.volumes = mkOption {
|
|
|
|
type = listOf types.unspecified;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
service.build.context = mkOption {
|
|
|
|
type = nullOr string;
|
|
|
|
default = null;
|
|
|
|
};
|
2019-02-03 21:07:00 +02:00
|
|
|
service.hostname = mkOption {
|
|
|
|
type = nullOr string;
|
|
|
|
default = null;
|
|
|
|
};
|
2018-12-17 19:08:38 +01:00
|
|
|
service.environment = mkOption {
|
2019-01-13 16:24:56 +02:00
|
|
|
type = attrsOf (either string int);
|
2018-12-17 19:08:38 +01:00
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
service.image = mkOption {
|
|
|
|
type = string;
|
|
|
|
};
|
|
|
|
service.command = mkOption {
|
|
|
|
type = nullOr types.unspecified;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
service.depends_on = mkOption {
|
|
|
|
type = listOf string;
|
|
|
|
default = [];
|
|
|
|
};
|
2019-02-03 22:24:26 +02:00
|
|
|
service.links = mkOption {
|
|
|
|
type = listOf string;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
service.external_links = mkOption {
|
|
|
|
type = listOf string;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
service.extra_hosts = mkOption {
|
|
|
|
type = listOf string;
|
|
|
|
default = [];
|
|
|
|
};
|
2019-01-13 16:24:56 +02:00
|
|
|
service.working_dir = mkOption {
|
|
|
|
type = nullOr string;
|
|
|
|
default = null;
|
|
|
|
};
|
2019-02-03 21:07:00 +02:00
|
|
|
service.privileged = mkOption {
|
|
|
|
type = nullOr bool;
|
|
|
|
default = null;
|
|
|
|
};
|
2019-01-13 16:24:56 +02:00
|
|
|
service.entrypoint = mkOption {
|
|
|
|
type = nullOr string;
|
|
|
|
default = null;
|
|
|
|
};
|
2018-12-17 19:08:38 +01:00
|
|
|
service.restart = mkOption {
|
|
|
|
type = nullOr string;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
service.ports = mkOption {
|
|
|
|
type = listOf types.unspecified;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
Expose ports on host. "host:container" or structured.
|
|
|
|
See https://docs.docker.com/compose/compose-file/#ports
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
service.expose = mkOption {
|
|
|
|
type = listOf string;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
|
|
|
|
build.service = mkOption {
|
|
|
|
type = attrsOf types.unspecified;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config.build.service = {
|
|
|
|
inherit (config.service)
|
|
|
|
volumes
|
|
|
|
environment
|
|
|
|
image
|
|
|
|
;
|
|
|
|
} // lib.optionalAttrs (config.service.build.context != null) {
|
|
|
|
inherit (config.service) build;
|
|
|
|
} // lib.optionalAttrs (config.service.command != null) {
|
|
|
|
inherit (config.service) command;
|
|
|
|
} // lib.optionalAttrs (config.service.depends_on != []) {
|
|
|
|
inherit (config.service) depends_on;
|
|
|
|
} // lib.optionalAttrs (config.service.restart != null) {
|
|
|
|
inherit (config.service) restart;
|
2019-01-13 16:24:56 +02:00
|
|
|
} // lib.optionalAttrs (config.service.working_dir != null) {
|
|
|
|
inherit (config.service) working_dir;
|
|
|
|
} // lib.optionalAttrs (config.service.entrypoint != null) {
|
|
|
|
inherit (config.service) entrypoint;
|
2018-12-17 19:08:38 +01:00
|
|
|
} // lib.optionalAttrs (config.service.ports != []) {
|
|
|
|
inherit (config.service) ports;
|
|
|
|
} // lib.optionalAttrs (config.service.expose != []) {
|
|
|
|
inherit (config.service) expose;
|
|
|
|
};
|
|
|
|
}
|