summary refs log tree commit diff
path: root/nixos/modules/service-managers/docker.nix
blob: 8e9c763b18afc2722e668a2ea603a30ea56a2c4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.docker-containers;

  containerModule = {
    script = mkOption {
      type = types.lines;
      description = "Shell commands executed as the service's main process.";
    };
  };

  toContainer = name: value: pkgs.dockerTools.buildImage {
    inherit name;
    config = {
      Cmd = [ value.script ];
    };
  };
in {
  options.docker-containers = mkOption {
    default = {};
    type = with types; attrsOf (types.submodule containerModule);
    description = "Definition of docker containers";
  };

  config.system.build.toplevel-docker = lib.mapAttrs toContainer cfg;
}