nix/container/default.nix

56 lines
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 = true;
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.
networking.nat = {
enable = true;
internalInterfaces = [ "ve-+" ];
externalInterface = config.container.interface;
2024-06-09 23:35:53 +03:00
};
};
}