feat: port Docker configuration to new modular structure
This commit is contained in:
parent
cbd6725b2a
commit
db884c9e86
@ -103,6 +103,16 @@ in
|
|||||||
|
|
||||||
pepe = {
|
pepe = {
|
||||||
core = {
|
core = {
|
||||||
|
docker = {
|
||||||
|
enable = true;
|
||||||
|
nvidia = true;
|
||||||
|
dataRoot = "/docker";
|
||||||
|
extraOptions = "--dns 127.0.0.1 --dns ${config.pepe.core.network.interfaces.lan.devices.architect.address}";
|
||||||
|
enableOnBoot = false;
|
||||||
|
iptables = false;
|
||||||
|
users = [ "giulio" ];
|
||||||
|
};
|
||||||
|
|
||||||
media = {
|
media = {
|
||||||
enable = true;
|
enable = true;
|
||||||
path = "/media";
|
path = "/media";
|
||||||
|
@ -17,4 +17,9 @@
|
|||||||
default = config.pepe.core.vhost.hosts;
|
default = config.pepe.core.vhost.hosts;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config.architect.networks.docker = {
|
||||||
|
interface = "docker0";
|
||||||
|
net = "172.17.0.0/16";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
./vhost.nix
|
./vhost.nix
|
||||||
./firewall.nix
|
./firewall.nix
|
||||||
./dns.nix
|
./dns.nix
|
||||||
|
./docker.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
60
modules/core/docker.nix
Normal file
60
modules/core/docker.nix
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
|
cfg = config.pepe.core.docker;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.pepe.core.docker = with lib; {
|
||||||
|
enable = mkEnableOption "Enable Docker";
|
||||||
|
nvidia = mkEnableOption "Enable NVIDIA Container Toolkit";
|
||||||
|
dataRoot = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "/var/lib/docker";
|
||||||
|
description = "Docker data root directory";
|
||||||
|
};
|
||||||
|
extraOptions = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
description = "Extra options for Docker daemon";
|
||||||
|
};
|
||||||
|
enableOnBoot = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Start Docker on boot";
|
||||||
|
};
|
||||||
|
iptables = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Whether Docker should manipulate iptables";
|
||||||
|
};
|
||||||
|
users = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
description = "Users to add to the docker group";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
hardware.nvidia-container-toolkit.enable = cfg.nvidia;
|
||||||
|
|
||||||
|
virtualisation = {
|
||||||
|
oci-containers.backend = "docker";
|
||||||
|
|
||||||
|
docker = {
|
||||||
|
enable = true;
|
||||||
|
extraOptions = cfg.extraOptions;
|
||||||
|
enableOnBoot = cfg.enableOnBoot;
|
||||||
|
daemon.settings = {
|
||||||
|
iptables = cfg.iptables;
|
||||||
|
data-root = cfg.dataRoot;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
users.users = lib.genAttrs cfg.users (user: {
|
||||||
|
extraGroups = [ "docker" ];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user