diff --git a/hosts/pi/default.nix b/hosts/pi/default.nix index d363ef2..29907fb 100644 --- a/hosts/pi/default.nix +++ b/hosts/pi/default.nix @@ -29,21 +29,6 @@ sound.enable = true; - age.secrets."passwords/networks.age" = { - file = "${inputs.secrets}/passwords/networks.age"; - }; - - networking = { - wireless = { - enable = true; - interfaces = [ "wlan0" ]; - environmentFile = config.age.secrets."passwords/networks.age".path; - networks = { - "Apollo 600 Mbps".psk = "@PSK_APOLLO@"; - }; - }; - }; - security.rtkit.enable = true; services.pipewire = { enable = true; @@ -109,6 +94,12 @@ }; modules = { + networking = { + wireless = { + enable = true; + interfaces = [ "wlan0" ]; + }; + }; services = { borgmatic = { enable = true; diff --git a/modules/default.nix b/modules/default.nix index d9ce510..2e6c80a 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -26,6 +26,7 @@ ./editors/neovim ./editors/vscode.nix ./networking/tailscale.nix + ./networking/wireless.nix ./security/gpg.nix ./security/pass.nix ./services/borgmatic diff --git a/modules/networking/wireless.nix b/modules/networking/wireless.nix new file mode 100644 index 0000000..498ac3a --- /dev/null +++ b/modules/networking/wireless.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, inputs, ... }: + +with lib; + +let cfg = config.modules.networking.wireless; +in { + options.modules.networking.wireless = { + enable = mkOption { + default = false; + example = true; + description = mdDoc "Automatically connect to known networks"; + }; + interfaces = mkOption { + default = [ ]; # All interfaces + example = [ "wlan0" ]; + description = mdDoc "Interfaces for `wpa_supplicant` to bind to"; + }; + }; + + config = mkIf cfg.enable { + age.secrets."passwords/networks" = { + file = "${inputs.secrets}/passwords/networks.age"; + }; + + networking = { + wireless = { + enable = true; + interfaces = cfg.interfaces; + environmentFile = config.age.secrets.passwords/networks.path; + networks = { + "Apollo 600 Mbps".psk = "@PSK_APOLLO@"; + }; + }; + }; + }; +}