2024-06-25 04:04:39 +03:00
|
|
|
{ lib, config, ... }: with lib; let
|
|
|
|
cfg = config.container;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
container = {
|
|
|
|
enable = mkEnableOption "Containers!!";
|
|
|
|
|
|
|
|
autoStart = mkOption {
|
2024-08-24 19:55:55 +03:00
|
|
|
default = false;
|
2024-06-25 04:04:39 +03:00
|
|
|
type = types.bool;
|
|
|
|
};
|
2024-06-24 03:32:33 +03:00
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
host = mkOption {
|
|
|
|
default = "0.0.0.0";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2024-06-01 10:37:49 +03:00
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
localAccess = mkOption {
|
|
|
|
default = "0.0.0.0";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2024-06-01 10:37:49 +03:00
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
storage = mkOption {
|
|
|
|
default = "/tmp/container";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2024-06-01 10:37:49 +03:00
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
domain = mkOption {
|
|
|
|
default = "local";
|
|
|
|
type = types.str;
|
2024-06-13 17:00:05 +03:00
|
|
|
};
|
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
interface = mkOption {
|
|
|
|
default = "lo";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2024-06-09 23:35:53 +03:00
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
media = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrs;
|
|
|
|
};
|
2024-06-09 23:35:53 +03:00
|
|
|
};
|
2024-06-25 04:04:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# This is the network for all the containers.
|
|
|
|
# They are not available to the external interface by default,
|
|
|
|
# instead they all expose specific ports in their configuration.
|
2024-06-26 20:27:39 +03:00
|
|
|
networking = {
|
|
|
|
nat = {
|
|
|
|
enable = true;
|
|
|
|
internalInterfaces = [ "ve-+" ];
|
|
|
|
externalInterface = config.container.interface;
|
|
|
|
};
|
|
|
|
networkmanager.unmanaged = [ "interface-name:ve-*" ];
|
2024-06-09 23:35:53 +03:00
|
|
|
};
|
2024-06-01 10:37:49 +03:00
|
|
|
};
|
|
|
|
}
|