liminix

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

nwa50ax-ap.nix (3250B)


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