Update docker/podman config
This commit is contained in:
parent
d703b4dec0
commit
0c1291d3fd
7 changed files with 85 additions and 72 deletions
79
modules/programs/containers.nix
Normal file
79
modules/programs/containers.nix
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
options,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.mods.containers = {
|
||||
variant = lib.mkOption {
|
||||
default = "";
|
||||
example = "podman";
|
||||
type = lib.types.enum [
|
||||
""
|
||||
"podman"
|
||||
"docker"
|
||||
];
|
||||
description = "Enables and configures a containerization solution: podman/docker";
|
||||
};
|
||||
podmanPackages = lib.mkOption {
|
||||
default = with pkgs; [
|
||||
podman-tui
|
||||
podman-compose
|
||||
];
|
||||
example = [ ];
|
||||
type = with lib.types; listOf package;
|
||||
description = "Podman packages";
|
||||
};
|
||||
dockerPackages = lib.mkOption {
|
||||
default = with pkgs; [
|
||||
docker-compose
|
||||
];
|
||||
example = [ ];
|
||||
type = with lib.types; listOf package;
|
||||
description = "Docker packages";
|
||||
};
|
||||
combinedPackages = lib.mkOption {
|
||||
default = with pkgs; [
|
||||
dive
|
||||
];
|
||||
example = [ ];
|
||||
type = with lib.types; listOf package;
|
||||
description = "Container packages";
|
||||
};
|
||||
};
|
||||
config = (
|
||||
lib.optionalAttrs (options ? environment.systemPackages) {
|
||||
environment.systemPackages =
|
||||
(lib.lists.optionals (
|
||||
config.mods.containers.variant == "podman"
|
||||
) config.mods.containers.podmanPackages)
|
||||
++ (lib.lists.optionals (
|
||||
config.mods.containers.variant == "docker"
|
||||
) config.mods.containers.dockerPackages)
|
||||
++ (lib.lists.optionals (
|
||||
config.mods.containers.variant == "podman" || config.mods.containers.variant == "docker"
|
||||
) config.mods.containers.combinedPackages);
|
||||
virtualisation =
|
||||
if (config.mods.containers.variant == "podman") then
|
||||
{
|
||||
containers.enable = true;
|
||||
podman = {
|
||||
enable = true;
|
||||
dockerCompat = true;
|
||||
defaultNetwork.settings.dns_enabled = true;
|
||||
};
|
||||
}
|
||||
else if (config.mods.containers.variant == "docker") then
|
||||
{
|
||||
containers.enable = true;
|
||||
docker = {
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
else
|
||||
{ };
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue