liminix

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

nwa50ax-ap.nix (3257B)


      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   ];
     65 
     66   hostname = "zyxel";
     67 
     68   users.root = {
     69     # EDIT: choose a root password and then use
     70     # "mkpasswd -m sha512crypt" to determine the hash.
     71     # It should start wirh $6$.
     72     passwd = "$y$j9T$f8GhLiqYmr3lc58eKhgyD0$z7P/7S9u.kq/cANZExxhS98bze/6i7aBxU6tbl7RMi.";
     73     openssh.authorizedKeys.keys = [
     74       # EDIT: you can add your ssh pubkey here
     75       # "ssh-rsa AAAAB3NzaC1....H6hKd user@example.com";
     76     ];
     77   };
     78 
     79   services.int = svc.bridge.primary.build {
     80     ifname = "int";
     81   };
     82 
     83   services.bridge = svc.bridge.members.build {
     84     primary = services.int;
     85     members = with config.hardware.networkInterfaces; [
     86       lan
     87       wlan0
     88       wlan1
     89     ];
     90   };
     91 
     92   services.dhcpv4 =
     93     let
     94       iface = services.int;
     95     in
     96     svc.network.dhcp.client.build { interface = iface; };
     97 
     98   services.defaultroute4 = svc.network.route.build {
     99     via = "$(output ${services.dhcpv4} address)";
    100     target = "default";
    101     dependencies = [ services.dhcpv4 ];
    102   };
    103 
    104   services.packet_forwarding = svc.network.forward.build { };
    105   services.sshd = svc.ssh.build {
    106     allowRoot = true;
    107   };
    108 
    109   services.ntp = config.system.service.ntp.build {
    110     pools = {
    111       "pool.ntp.org" = [ "iburst" ];
    112     };
    113   };
    114 
    115   boot.tftp = {
    116     serverip = "192.0.2.10";
    117     ipaddr = "192.0.2.12";
    118   };
    119 
    120   # wlan0 is the 2.4GHz interface.
    121   services.hostap-1 = mkWifiSta baseParams config.hardware.networkInterfaces.wlan0 secrets-1;
    122   # wlan1 is the 5GHz interface, e.g. AX capable.
    123   services.hostap-2 = mkWifiSta (
    124     baseParams // modernParams
    125   ) config.hardware.networkInterfaces.wlan1 secrets-2;
    126 
    127   defaultProfile.packages = with pkgs; [
    128     zyxel-bootconfig
    129     iw
    130     min-collect-garbage
    131     mtdutils
    132   ];
    133 }