diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2025-12-27 08:55:26 -0600 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2025-12-27 08:55:26 -0600 |
| commit | b900e797ea557030edb8350bbf732c061f23c7a0 (patch) | |
| tree | e0c393fd20edd826f4276a0b24205e3664739e6b /modules/services/options.nix | |
| parent | 6f9b285bdb935fbab99978307034c7458ddc9d09 (diff) | |
module for setting a static ip with systemd-networkd
Diffstat (limited to 'modules/services/options.nix')
| -rw-r--r-- | modules/services/options.nix | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/modules/services/options.nix b/modules/services/options.nix index 681ed99..78a5a8f 100644 --- a/modules/services/options.nix +++ b/modules/services/options.nix @@ -11,6 +11,18 @@ in { enable = mkEnableOption "wifi"; iwd.enable = mkEnableOption "lightweight wifi daemon"; networkmanager.enable = mkEnableOption "heavier wifi daemon"; + + static = let + 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])$"; + in { + enable = mkEnableOption "set static IP (systemd-networkd)"; + ssid = mkOption {type = lib.types.str;}; + ip = mkOption {type = ip_addr;}; + gateway = mkOption {type = ip_addr;}; + pskFile = mkOption {type = lib.types.str;}; + }; tailscale.enable = mkEnableOption "tailscale"; sshd.enable = mkEnableOption "OpenSSH server"; }; @@ -42,8 +54,8 @@ in { config = { assertions = [ { - assertion = with config.collinux.services.networking; !(iwd.enable && networkmanager.enable); - message = "can not use iwd and networkmanager at the same time"; + assertion = with config.collinux.services.networking; (iwd.enable && !networkmanager.enable && !static.enable) || (!iwd.enable && networkmanager.enable && !static.enable) || (!iwd.enable && !networkmanager.enable && static.enable); + message = "only one networking method (iwd, networkmanager, static) can be active"; } ]; }; |
