nixos/modules/containers/default.nix

49 lines
1.2 KiB
Nix
Raw Normal View History

2025-03-29 21:03:07 -04:00
{
pkgs,
lib,
config,
...
}: let
cfg = config.lily.containers;
in {
options.lily.containers = {
enable = lib.mkEnableOption "activate containers";
docker = lib.mkEnableOption "activate docker";
podman = lib.mkEnableOption "activate podman";
};
config = lib.mkMerge [
# (lib.mkIf (cfg.enable && cfg.docker && cfg.podman)
# (builtins.throw "You can't enable both docker and podman at the same time"))
{
assertions = [
{
assertion = !(cfg.docker && cfg.podman);
message = "You cannot enable docker and podman at the same time";
}
];
}
(lib.mkIf (cfg.enable && cfg.docker) {
# Enable docker support:
virtualisation.containers.enable = true;
virtualisation.docker.enable = true;
})
(lib.mkIf (cfg.enable && cfg.podman) {
# Enable podman support:
virtualisation.containers.enable = true;
virtualisation.podman = {
enable = true;
dockerCompat = true;
dockerSocket.enable = true;
defaultNetwork.settings = {
dns_enabled = true;
};
};
environment.systemPackages = with pkgs; [
podman
podman-compose
];
})
];
}