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-03-04 00:12:01 +01:00
|
|
|
inherit (types) listOf nullOr attrsOf str either int bool;
|
2019-03-03 23:42:40 +01:00
|
|
|
|
|
|
|
dockerComposeRef = fragment:
|
|
|
|
''See <link xlink:href="https://docs.docker.com/compose/compose-file/#${fragment}">Docker Compose#${fragment}</link>'';
|
|
|
|
dockerComposeKitchenSink = ''
|
|
|
|
Analogous to the <code>docker run</code> counterpart.
|
|
|
|
|
|
|
|
${dockerComposeRef "domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir"}
|
|
|
|
'';
|
2018-12-17 19:08:38 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2019-03-04 00:13:57 +01:00
|
|
|
build.service = mkOption {
|
|
|
|
type = attrsOf types.unspecified;
|
|
|
|
description = ''
|
|
|
|
Raw input for the service in <code>docker-compose.yaml</code>.
|
|
|
|
|
|
|
|
You should not need to use this option. If anything is
|
|
|
|
missing, please contribute the missing option.
|
|
|
|
|
|
|
|
This option is user accessible because it may serve as an
|
|
|
|
escape hatch for some.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-12-17 19:08:38 +01:00
|
|
|
service.volumes = mkOption {
|
|
|
|
type = listOf types.unspecified;
|
|
|
|
default = [];
|
2019-03-05 19:41:54 +01:00
|
|
|
description = dockerComposeRef "volumes";
|
|
|
|
};
|
|
|
|
service.tmpfs = mkOption {
|
|
|
|
type = listOf types.str;
|
|
|
|
default = [];
|
|
|
|
description = dockerComposeRef "tmpfs";
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
|
|
|
service.build.context = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = nullOr str;
|
2018-12-17 19:08:38 +01:00
|
|
|
default = null;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = ''
|
|
|
|
Locates a Dockerfile to use for creating an image to use in this service.
|
|
|
|
|
|
|
|
${dockerComposeRef "context"}
|
|
|
|
'';
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
2019-02-03 21:07:00 +02:00
|
|
|
service.hostname = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = nullOr str;
|
2019-02-03 21:07:00 +02:00
|
|
|
default = null;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeKitchenSink;
|
2019-02-03 21:07:00 +02:00
|
|
|
};
|
2019-03-05 19:41:54 +01:00
|
|
|
service.tty = mkOption {
|
|
|
|
type = nullOr bool;
|
|
|
|
default = null;
|
|
|
|
description = dockerComposeKitchenSink;
|
|
|
|
};
|
2018-12-17 19:08:38 +01:00
|
|
|
service.environment = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = attrsOf (either str int);
|
2018-12-17 19:08:38 +01:00
|
|
|
default = {};
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "environment";
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
|
|
|
service.image = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = str;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "image";
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
|
|
|
service.command = mkOption {
|
|
|
|
type = nullOr types.unspecified;
|
|
|
|
default = null;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "command";
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
|
|
|
service.depends_on = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = listOf str;
|
2018-12-17 19:08:38 +01:00
|
|
|
default = [];
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "depends_on";
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
2019-02-03 22:24:26 +02:00
|
|
|
service.links = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = listOf str;
|
2019-02-03 22:24:26 +02:00
|
|
|
default = [];
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "links";
|
2019-02-03 22:24:26 +02:00
|
|
|
};
|
|
|
|
service.external_links = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = listOf str;
|
2019-02-03 22:24:26 +02:00
|
|
|
default = [];
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "external_links";
|
2019-02-03 22:24:26 +02:00
|
|
|
};
|
|
|
|
service.extra_hosts = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = listOf str;
|
2019-02-03 22:24:26 +02:00
|
|
|
default = [];
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "extra_hosts";
|
2019-02-03 22:24:26 +02:00
|
|
|
};
|
2019-01-13 16:24:56 +02:00
|
|
|
service.working_dir = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = nullOr str;
|
2019-01-13 16:24:56 +02:00
|
|
|
default = null;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeKitchenSink;
|
2019-01-13 16:24:56 +02:00
|
|
|
};
|
2019-02-03 21:07:00 +02:00
|
|
|
service.privileged = mkOption {
|
|
|
|
type = nullOr bool;
|
|
|
|
default = null;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeKitchenSink;
|
2019-02-03 21:07:00 +02:00
|
|
|
};
|
2019-01-13 16:24:56 +02:00
|
|
|
service.entrypoint = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = nullOr str;
|
2019-01-13 16:24:56 +02:00
|
|
|
default = null;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "entrypoint";
|
2019-01-13 16:24:56 +02:00
|
|
|
};
|
2018-12-17 19:08:38 +01:00
|
|
|
service.restart = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = nullOr str;
|
2018-12-17 19:08:38 +01:00
|
|
|
default = null;
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "restart";
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
|
|
|
service.ports = mkOption {
|
|
|
|
type = listOf types.unspecified;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
Expose ports on host. "host:container" or structured.
|
2019-03-03 23:42:40 +01:00
|
|
|
|
|
|
|
${dockerComposeRef "ports"}
|
2018-12-17 19:08:38 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
service.expose = mkOption {
|
2019-03-04 00:12:01 +01:00
|
|
|
type = listOf str;
|
2018-12-17 19:08:38 +01:00
|
|
|
default = [];
|
2019-03-03 23:42:40 +01:00
|
|
|
description = dockerComposeRef "expose";
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
2019-03-04 00:28:42 +01:00
|
|
|
service.env_file = mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = [];
|
|
|
|
description = dockerComposeRef "env_file";
|
|
|
|
};
|
|
|
|
service.network_mode = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
default = null;
|
|
|
|
description = dockerComposeRef "network_mode";
|
|
|
|
};
|
2019-03-05 19:41:54 +01:00
|
|
|
service.stop_signal = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
default = null;
|
|
|
|
description = dockerComposeRef "stop_signal";
|
|
|
|
};
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2019-01-13 16:24:56 +02:00
|
|
|
} // lib.optionalAttrs (config.service.entrypoint != null) {
|
|
|
|
inherit (config.service) entrypoint;
|
2019-03-04 00:28:42 +01:00
|
|
|
} // lib.optionalAttrs (config.service.env_file != []) {
|
|
|
|
inherit (config.service) env_file;
|
2018-12-17 19:08:38 +01:00
|
|
|
} // lib.optionalAttrs (config.service.expose != []) {
|
|
|
|
inherit (config.service) expose;
|
2019-03-04 00:28:42 +01:00
|
|
|
} // lib.optionalAttrs (config.service.external_links != []) {
|
|
|
|
inherit (config.service) external_links;
|
|
|
|
} // lib.optionalAttrs (config.service.extra_hosts != []) {
|
|
|
|
inherit (config.service) extra_hosts;
|
|
|
|
} // lib.optionalAttrs (config.service.hostname != null) {
|
|
|
|
inherit (config.service) hostname;
|
|
|
|
} // lib.optionalAttrs (config.service.links != []) {
|
|
|
|
inherit (config.service) links;
|
|
|
|
} // lib.optionalAttrs (config.service.ports != []) {
|
|
|
|
inherit (config.service) ports;
|
|
|
|
} // lib.optionalAttrs (config.service.privileged != null) {
|
|
|
|
inherit (config.service) privileged;
|
|
|
|
} // lib.optionalAttrs (config.service.network_mode != null) {
|
|
|
|
inherit (config.service) network_mode;
|
|
|
|
} // lib.optionalAttrs (config.service.restart != null) {
|
|
|
|
inherit (config.service) restart;
|
2019-03-05 19:41:54 +01:00
|
|
|
} // lib.optionalAttrs (config.service.stop_signal != null) {
|
|
|
|
inherit (config.service) stop_signal;
|
|
|
|
} // lib.optionalAttrs (config.service.tmpfs != []) {
|
|
|
|
inherit (config.service) tmpfs;
|
|
|
|
} // lib.optionalAttrs (config.service.tty != null) {
|
|
|
|
inherit (config.service) tty;
|
2019-03-04 00:28:42 +01:00
|
|
|
} // lib.optionalAttrs (config.service.working_dir != null) {
|
|
|
|
inherit (config.service) working_dir;
|
2018-12-17 19:08:38 +01:00
|
|
|
};
|
|
|
|
}
|