me like nix
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 2.1 kB View raw
1{ ... }: { 2 flake.modules.nixos.pi-wifi = 3 { config, pkgs, lib, ... }: 4 let 5 cfg = config.pi.wifi; 6 in 7 { 8 options.pi.wifi.freqList = lib.mkOption { 9 type = lib.types.listOf lib.types.int; 10 default = [ ]; 11 description = "wpa_supplicant freq_list (MHz). Empty = no constraint. Pi Zero 2W is 2.4 GHz only; Pi 4 is dual-band."; 12 }; 13 14 config = { 15 services.openssh.hostKeys = [ 16 { 17 path = "/etc/ssh/ssh_host_ed25519_key"; 18 type = "ed25519"; 19 } 20 ]; 21 22 age.identityPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; 23 age.secrets.wifi = { 24 file = ../secrets/wifi.age; 25 mode = "0444"; 26 }; 27 28 # Ensure wpa_supplicant starts after agenix decrypts the WiFi PSK 29 systemd.services.wpa_supplicant.after = [ "run-agenix.d.mount" ]; 30 systemd.services.wpa_supplicant.requires = [ "run-agenix.d.mount" ]; 31 32 networking.wireless = { 33 enable = true; 34 secretsFile = config.age.secrets.wifi.path; 35 networks."GL-MT6000-6a6" = { 36 pskRaw = "ext:WIFI_PSK"; 37 extraConfig = lib.optionalString (cfg.freqList != [ ]) 38 "freq_list=${lib.concatStringsSep " " (map toString cfg.freqList)}\n"; 39 }; 40 }; 41 42 systemd.services.wifi-powersave-off = { 43 description = "Disable WiFi power save"; 44 after = [ "wpa_supplicant.service" "network.target" ]; 45 wants = [ "wpa_supplicant.service" ]; 46 wantedBy = [ "multi-user.target" ]; 47 serviceConfig = { 48 Type = "oneshot"; 49 ExecStart = pkgs.writeShellScript "wifi-powersave-off" '' 50 set -eu 51 52 for _ in $(seq 1 60); do 53 if ${pkgs.iw}/bin/iw dev wlan0 set power_save off; then 54 exit 0 55 fi 56 sleep 1 57 done 58 59 echo "failed to disable WiFi power save: wlan0 did not become ready" >&2 60 exit 1 61 ''; 62 RemainAfterExit = true; 63 }; 64 }; 65 }; 66 }; 67}