aboutsummaryrefslogtreecommitdiff
path: root/machines.nix
diff options
context:
space:
mode:
Diffstat (limited to 'machines.nix')
-rw-r--r--machines.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/machines.nix b/machines.nix
index 8f29ef0..1e7deab 100644
--- a/machines.nix
+++ b/machines.nix
@@ -102,6 +102,32 @@ in
type = types.ints.positive;
default = 10000;
};
+ virtualisation.exposedPorts = mkOption {
+ description = ''
+ In der virtuellen Maschine verwendete Ports
+
+ Diese werden mit dem entsprechend angepassten Wert and den Host exponiert.
+ '';
+ type =
+ with types;
+ attrsOf (submodule {
+ options = {
+ port = mkOption {
+ type = types.ints.positive;
+ };
+ protocol = mkOption {
+ type = types.enum [
+ "tcp"
+ "udp"
+ ];
+ default = "tcp";
+ };
+ };
+ });
+ default = {
+ http.port = 800;
+ };
+ };
};
config = {
@@ -113,6 +139,19 @@ in
}) config.networking.firewall.allowedTCPPorts;
services.getty.autologinUser = lib.mkDefault "root";
+ networking.firewall =
+ let
+ ports =
+ protocol:
+ lib.foldlAttrs (
+ acc: _name: cfg:
+ if cfg.protocol == protocol then acc ++ [ cfg.port ] else acc
+ ) [ ] config.virtualisation.exposedPorts;
+ in
+ {
+ allowedTCPPorts = ports "tcp";
+ allowedUDPPorts = ports "udp";
+ };
};
};
};