nix/module/Docker.nix

41 lines
747 B
Nix
Raw Normal View History

{
2024-11-04 04:37:29 +03:00
lib,
config,
...
}: let
cfg = config.module.docker;
in {
options.module.docker = {
enable = lib.mkEnableOption "the docker.";
rootless = lib.mkOption {
default = false;
type = lib.types.bool;
};
autostart = lib.mkOption {
default = false;
type = lib.types.bool;
};
};
2024-06-25 04:04:39 +03:00
2024-11-04 04:37:29 +03:00
config = lib.mkIf cfg.enable (lib.mkMerge [
{
virtualisation.docker.enable = true;
2024-06-25 04:04:39 +03:00
2024-11-04 04:37:29 +03:00
systemd = if cfg.autostart then { } else {
sockets.docker.wantedBy = lib.mkForce [ ];
services = {
docker-prune.wantedBy = lib.mkForce [ ];
docker.wantedBy = lib.mkForce [ ];
};
};
}
2024-06-25 04:04:39 +03:00
2024-11-04 04:37:29 +03:00
(lib.mkIf cfg.rootless {
virtualisation.docker.rootless = {
enable = true;
setSocketVariable = true;
};
})
]);
}