mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 20:39:18 -08:00
Using ./home.nix and ./nixos.nix as entrypoints for hosts. Using hardware profiles. Using new entrypoints (profiles/base/profiles.nix + profiles/base/home.nix). New modules (for DNS handling, for themeing, ...). Split up deploy-tf.nix into several modules. Renamed common profile to base profile.
80 lines
2 KiB
Nix
80 lines
2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let cfg = config.kw.fw;
|
|
in
|
|
{
|
|
options.kw.fw = {
|
|
public.tcp.ports = mkOption {
|
|
type = types.listOf types.port;
|
|
default = [ ];
|
|
};
|
|
public.udp.ports = mkOption {
|
|
type = types.listOf types.port;
|
|
default = [ ];
|
|
};
|
|
private.tcp.ports = mkOption {
|
|
type = types.listOf types.port;
|
|
default = [ ];
|
|
};
|
|
private.udp.ports = mkOption {
|
|
type = types.listOf types.port;
|
|
default = [ ];
|
|
};
|
|
|
|
public.tcp.ranges = mkOption {
|
|
type = types.listOf (types.attrsOf types.port);
|
|
default = [ ];
|
|
};
|
|
public.udp.ranges = mkOption {
|
|
type = types.listOf (types.attrsOf types.port);
|
|
default = [ ];
|
|
};
|
|
private.tcp.ranges = mkOption {
|
|
type = types.listOf (types.attrsOf types.port);
|
|
default = [ ];
|
|
};
|
|
private.udp.ranges = mkOption {
|
|
type = types.listOf (types.attrsOf types.port);
|
|
default = [ ];
|
|
};
|
|
|
|
public.interfaces = mkOption {
|
|
type = types.listOf types.str;
|
|
description = "Public firewall interfaces";
|
|
default = [ ];
|
|
};
|
|
private.interfaces = mkOption {
|
|
type = types.listOf types.str;
|
|
description = "Private firewall interfaces";
|
|
default = [ ];
|
|
};
|
|
};
|
|
|
|
config = {
|
|
networking.firewall.interfaces =
|
|
let
|
|
fwTypes = {
|
|
ports = "Ports";
|
|
ranges = "PortRanges";
|
|
};
|
|
|
|
interfaceDef = visibility:
|
|
listToAttrs (flatten (mapAttrsToList
|
|
(type: typeString:
|
|
map
|
|
(proto: {
|
|
name = "allowed${toUpper proto}${typeString}";
|
|
value = cfg.${visibility}.${proto}.${type};
|
|
}) [ "tcp" "udp" ])
|
|
fwTypes));
|
|
|
|
interfaces = visibility:
|
|
listToAttrs
|
|
(map (interface: nameValuePair interface (interfaceDef visibility))
|
|
cfg.${visibility}.interfaces);
|
|
in
|
|
mkMerge (map (visibility: interfaces visibility) [ "public" "private" ]);
|
|
};
|
|
}
|