diff options
Diffstat (limited to 'modules/services/options.nix')
| -rw-r--r-- | modules/services/options.nix | 167 |
1 files changed, 69 insertions, 98 deletions
diff --git a/modules/services/options.nix b/modules/services/options.nix index 9a1f662..880206f 100644 --- a/modules/services/options.nix +++ b/modules/services/options.nix @@ -1,122 +1,93 @@ { lib, - config, + my-lib, ... }: let inherit (lib) mkOption mkEnableOption; + inherit ((my-lib {inherit lib;}).netTypes) ipAddr; - ip_addr = lib.types.strMatching "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$"; - ip_addr_cidr = lib.types.strMatching "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])/(3[0-2]|[12]?[0-9])$"; + selfhostOptions = { + service_name, + default_port ? null, + }: { + enable = mkEnableOption "${service_name} selfhosted service"; + + service_name = mkOption { + type = lib.types.str; + internal = true; + }; + + bind_host = mkOption { + description = "The IP address on which ${service_name} will listen for incoming connections. The default, `0.0.0.0`, means 'all interfaces'"; + type = ipAddr; + default = "0.0.0.0"; + }; + port = mkOption { + description = "The port on which ${service_name} will listen for incomming connections"; + type = lib.types.port; + default = default_port; + }; + + root_url = mkOption { + description = "The final url that this service will be hosted on. Required for caddy, otherwise optional"; + type = lib.types.nullOr lib.types.str; + }; + + caddy = { + enable = mkEnableOption "Automatically create caddy configurations for this service"; + bind_tailscale = mkEnableOption "Bind the service to ${service_name}.{tailnet}"; + }; + }; in { options = { collinux.services = { - networking = { - enable = mkEnableOption "wifi"; + sshd = { + enable = mkEnableOption "OpenSSH server"; - iwd.enable = mkEnableOption "lightweight wifi daemon"; - networkmanager.enable = mkEnableOption "heavier wifi daemon"; - - networkd = { - enable = mkEnableOption "use systemd-networkd"; - ssid = mkOption { - description = "SSID for this network"; - type = lib.types.str; - }; - pskFile = mkOption { - description = "Absolute path to a file containing the pre-shared key for this network"; - type = lib.types.str; - example = "/run/secrets.d/wifi-psk"; - }; - - static = lib.mkOption { - description = "Set a static IP address for this device on this network. Set to null to use DHCP"; - type = lib.types.nullOr (lib.types.submodule { - options = { - ip = mkOption { - description = "IP address"; - type = ip_addr_cidr; - }; - gateway = mkOption { - description = "default gateway"; - type = ip_addr; - }; + portConfig = mkOption { + description = "List of ssh bind hosts. see submodule options for details"; + type = lib.types.listOf (lib.types.submodule { + options = { + port = mkOption { + description = "Port to run on"; + type = lib.types.port; }; - }); - default = null; - }; - }; - tailscale.enable = mkEnableOption "tailscale"; - sshd = { - enable = mkEnableOption "OpenSSH server"; - bind_host = mkOption { - description = "The IP address on which OpenSSH will listen for incomming connections. The default, `0.0.0.0`, means 'all interfaces'"; - type = ip_addr; - default = "0.0.0.0"; - }; + otp = mkEnableOption "Whether to require TOTP (Google Authenticator) 2fa codes for this port"; + rootLogin = mkEnableOption "Whether to allow root login for this port"; + }; + }); }; }; - audio.enable = mkEnableOption "pipewire and wireplumber"; - - bluetooth.enable = mkEnableOption "bluetooth"; - - selfhost = let - selfhostOptions = { - service_name, - default_port ? null, - }: { - enable = mkEnableOption "${service_name} selfhosted service"; - - service_name = mkOption { - type = lib.types.str; - internal = true; - }; - - bind_host = mkOption { - description = "The IP address on which ${service_name} will listen for incoming connections. The default, `0.0.0.0`, means 'all interfaces'"; - type = ip_addr; - default = "0.0.0.0"; - }; - port = mkOption { - description = "The port on which ${service_name} will listen for incomming connections"; - type = lib.types.port; - default = default_port; - }; - - root_url = mkOption { - description = "The final url that this service will be hosted on. Required for caddy, otherwise optional"; - type = lib.types.nullOr lib.types.str; - }; - - caddy = { - enable = mkEnableOption "Automatically create caddy configurations for this service"; - bind_tailscale = mkEnableOption "Bind the service to ${service_name}.{tailnet}"; - }; - }; - in { - adguard = selfhostOptions { - service_name = "adguard"; - default_port = 8001; - }; + adguard = selfhostOptions { + service_name = "adguard"; + default_port = 8001; + }; - forgejo = selfhostOptions { + forgejo = + (selfhostOptions { service_name = "forgejo"; default_port = 8010; + }) + // { + git_ssh_port = mkOption { + type = lib.types.port; + default = 2225; + }; }; - headscale = selfhostOptions { - service_name = "headscale"; - default_port = 8080; - }; + headscale = selfhostOptions { + service_name = "headscale"; + default_port = 8080; + }; - caddy = { - enable = mkEnableOption "caddy https server"; - envFile = mkOption { - description = "Absolute path to file that contains environment variables for caddy operations"; - type = lib.types.str; - example = "/run/secrets.d/caddy-env"; - }; + caddy = { + enable = mkEnableOption "caddy https server"; + envFile = mkOption { + description = "Absolute path to file that contains environment variables for caddy operations"; + type = lib.types.str; + example = "/run/secrets.d/caddy-env"; }; }; }; |
