nix/container/default.nix

59 lines
1.1 KiB
Nix
Raw Normal View History

2024-06-25 04:04:39 +03:00
{ lib, config, ... }: with lib; let
cfg = config.container;
in {
options = {
container = {
enable = mkEnableOption "Containers!!";
autoStart = mkOption {
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-25 04:04:39 +03:00
localAccess = mkOption {
default = "0.0.0.0";
type = types.str;
};
2024-06-25 04:04:39 +03:00
storage = mkOption {
default = "/tmp/container";
type = types.str;
};
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
};
};
}