liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

nwa50ax-ap.nix (3273B)


      1 { config, pkgs, ... }:
      2 let
      3   inherit (pkgs.liminix.services) target;
      4   svc = config.system.service;
      5   secrets-1 = {
      6     ssid = "Zyxel 2G (N)";
      7     wpa_passphrase = "diamond dogs";
      8   };
      9   secrets-2 = {
     10     ssid = "Zyxel 5G (AX)";
     11     wpa_passphrase = "diamond dogs";
     12   };
     13   baseParams = {
     14     country_code = "FR";
     15     hw_mode = "g";
     16     channel = 6;
     17     wmm_enabled = 1;
     18     ieee80211n = 1;
     19     ht_capab = "[LDPC][GF][HT40-][HT40+][SHORT-GI-40][MAX-AMSDU-7935][TX-STBC]";
     20     auth_algs = 1;
     21     wpa = 2;
     22     wpa_key_mgmt = "WPA-PSK";
     23     wpa_pairwise = "TKIP CCMP";
     24     rsn_pairwise = "CCMP";
     25   };
     26 
     27   modernParams = {
     28     hw_mode = "a";
     29     he_su_beamformer = 1;
     30     he_su_beamformee = 1;
     31     he_mu_beamformer = 1;
     32     preamble = 1;
     33     # Allow radar detection.
     34     ieee80211d = 1;
     35     ieee80211h = 1;
     36     ieee80211ac = 1;
     37     ieee80211ax = 1;
     38     vht_capab = "[MAX-MPDU-7991][SU-BEAMFORMEE][SU-BEAMFORMER][RXLDPC][SHORT-GI-80][MAX-A-MPDU-LEN-EXP3][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][TX-STBC-2BY1][RX-STBC-1][MU-BEAMFORMER]";
     39     vht_oper_chwidth = 1;
     40     he_oper_chwidth = 1;
     41     channel = 36;
     42     vht_oper_centr_freq_seg0_idx = 42;
     43     he_oper_centr_freq_seg0_idx = 42;
     44     require_vht = 1;
     45   };
     46   mkWifiSta =
     47     params: interface: secrets:
     48     svc.hostapd.build {
     49       inherit interface;
     50       params = params // {
     51         inherit (secrets) ssid wpa_passphrase;
     52       };
     53     };
     54 in
     55 rec {
     56   imports = [
     57     ../modules/wlan.nix
     58     ../modules/network
     59     ../modules/hostapd
     60     ../modules/ssh
     61     ../modules/ntp
     62     ../modules/vlan
     63     ../modules/bridge
     64     ../modules/dhcp4c
     65   ];
     66 
     67   hostname = "zyxel";
     68 
     69   users.root = {
     70     # EDIT: choose a root password and then use
     71     # "mkpasswd -m sha512crypt" to determine the hash.
     72     # It should start wirh $6$.
     73     passwd = "$y$j9T$f8GhLiqYmr3lc58eKhgyD0$z7P/7S9u.kq/cANZExxhS98bze/6i7aBxU6tbl7RMi.";
     74     openssh.authorizedKeys.keys = [
     75       # EDIT: you can add your ssh pubkey here
     76       # "ssh-rsa AAAAB3NzaC1....H6hKd user@example.com";
     77     ];
     78   };
     79 
     80   services.int = svc.bridge.primary.build {
     81     ifname = "int";
     82   };
     83 
     84   services.bridge = svc.bridge.members.build {
     85     primary = services.int;
     86     members = with config.hardware.networkInterfaces; [
     87       lan
     88       wlan0
     89       wlan1
     90     ];
     91   };
     92 
     93   services.dhcpv4 =
     94     let
     95       iface = services.int;
     96     in
     97     svc.dhcp4c.client.build { interface = iface; };
     98 
     99   services.defaultroute4 = svc.network.route.build {
    100     via = "$(output ${services.dhcpv4} address)";
    101     target = "default";
    102     dependencies = [ services.dhcpv4 ];
    103   };
    104 
    105   services.packet_forwarding = svc.network.forward.build { };
    106   services.sshd = svc.ssh.build {
    107     allowRoot = true;
    108   };
    109 
    110   services.ntp = config.system.service.ntp.build {
    111     pools = {
    112       "pool.ntp.org" = [ "iburst" ];
    113     };
    114   };
    115 
    116   boot.tftp = {
    117     serverip = "192.0.2.10";
    118     ipaddr = "192.0.2.12";
    119   };
    120 
    121   # wlan0 is the 2.4GHz interface.
    122   services.hostap-1 = mkWifiSta baseParams config.hardware.networkInterfaces.wlan0 secrets-1;
    123   # wlan1 is the 5GHz interface, e.g. AX capable.
    124   services.hostap-2 = mkWifiSta (
    125     baseParams // modernParams
    126   ) config.hardware.networkInterfaces.wlan1 secrets-2;
    127 
    128   defaultProfile.packages = with pkgs; [
    129     zyxel-bootconfig
    130     iw
    131     min-collect-garbage
    132     mtdutils
    133   ];
    134 }