summary refs log tree commit diff
path: root/nixos/modules/service-managers/docker.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/service-managers/docker.nix')
-rw-r--r--nixos/modules/service-managers/docker.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/nixos/modules/service-managers/docker.nix b/nixos/modules/service-managers/docker.nix
new file mode 100644
index 000000000000..8e9c763b18af
--- /dev/null
+++ b/nixos/modules/service-managers/docker.nix
@@ -0,0 +1,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;
+}