1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.docker-containers;
7
8 containerModule = {
9 script = mkOption {
10 type = types.lines;
11 description = "Shell commands executed as the service's main process.";
12 };
13 };
14
15 toContainer = name: value: pkgs.dockerTools.buildImage {
16 inherit name;
17 config = {
18 Cmd = [ value.script ];
19 };
20 };
21in {
22 options.docker-containers = mkOption {
23 default = {};
24 type = with types; attrsOf (types.submodule containerModule);
25 description = "Definition of docker containers";
26 };
27
28 config.system.build.toplevel-docker = lib.mapAttrs toContainer cfg;
29}