summaryrefslogtreecommitdiffstats
path: root/nixos/modules/virtualisation/podman.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/virtualisation/podman.nix')
-rw-r--r--nixos/modules/virtualisation/podman.nix39
1 files changed, 38 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/podman.nix b/nixos/modules/virtualisation/podman.nix
index d6421d488b8b..01ff84bc6293 100644
--- a/nixos/modules/virtualisation/podman.nix
+++ b/nixos/modules/virtualisation/podman.nix
@@ -25,6 +25,7 @@ let
in
{
imports = [
+ ./podman-network-socket.nix
(lib.mkRenamedOptionModule [ "virtualisation" "podman" "libpod" ] [ "virtualisation" "containers" "containersConf" ])
];
@@ -46,6 +47,20 @@ in
'';
};
+ dockerSocket.enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Make the Podman socket available in place of the Docker socket, so
+ Docker tools can find the Podman socket.
+
+ Podman implements the Docker API.
+
+ Users must be in the <code>podman</code> group in order to connect. As
+ with Docker, members of this group can gain root access.
+ '';
+ };
+
dockerCompat = mkOption {
type = types.bool;
default = false;
@@ -111,14 +126,36 @@ in
};
systemd.sockets.podman.wantedBy = [ "sockets.target" ];
+ systemd.sockets.podman.socketConfig.SocketGroup = "podman";
+
+ systemd.tmpfiles.packages = [
+ # The /run/podman rule interferes with our podman group, so we remove
+ # it and let the systemd socket logic take care of it.
+ (pkgs.runCommand "podman-tmpfiles-nixos" { package = cfg.package; } ''
+ mkdir -p $out/lib/tmpfiles.d/
+ grep -v 'D! /run/podman 0700 root root' \
+ <$package/lib/tmpfiles.d/podman.conf \
+ >$out/lib/tmpfiles.d/podman.conf
+ '') ];
- systemd.tmpfiles.packages = [ cfg.package ];
+ systemd.tmpfiles.rules =
+ lib.optionals cfg.dockerSocket.enable [
+ "L! /run/docker.sock - - - - /run/podman/podman.sock"
+ ];
+
+ users.groups.podman = {};
assertions = [
{
assertion = cfg.dockerCompat -> !config.virtualisation.docker.enable;
message = "Option dockerCompat conflicts with docker";
}
+ {
+ assertion = cfg.dockerSocket.enable -> !config.virtualisation.docker.enable;
+ message = ''
+ The options virtualisation.podman.dockerSocket.enable and virtualisation.docker.enable conflict, because only one can serve the socket.
+ '';
+ }
];
}
]);