2024-03-06 19:14:58 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
modulesPath,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
2024-09-01 18:03:18 +02:00
|
|
|
inherit (pkgs.liminix.services) oneshot;
|
|
|
|
inherit (pkgs.pseudofile) symlink dir;
|
|
|
|
inherit (pkgs) serviceFns;
|
2024-03-06 19:14:58 +01:00
|
|
|
svc = config.system.service;
|
2024-09-01 18:03:18 +02:00
|
|
|
# secrets-1 = {
|
|
|
|
# ssid = "DGNum 2G prototype (N)";
|
|
|
|
# # wpa_passphrase = "diamond dogs";
|
|
|
|
# };
|
2024-03-06 19:14:58 +01:00
|
|
|
secrets-2 = {
|
2024-08-22 18:45:40 +02:00
|
|
|
ssid = "DGNum 5G prototype (AX)";
|
2024-09-01 18:03:18 +02:00
|
|
|
# wpa_passphrase = "diamond dogs";
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
baseParams = {
|
|
|
|
country_code = "FR";
|
|
|
|
hw_mode = "g";
|
|
|
|
channel = 6;
|
|
|
|
wmm_enabled = 1;
|
|
|
|
ieee80211n = 1;
|
|
|
|
ht_capab = "[LDPC][GF][HT40-][HT40+][SHORT-GI-40][MAX-AMSDU-7935][TX-STBC]";
|
|
|
|
auth_algs = 1;
|
|
|
|
wpa = 2;
|
|
|
|
wpa_pairwise = "TKIP CCMP";
|
|
|
|
rsn_pairwise = "CCMP";
|
|
|
|
};
|
|
|
|
|
2024-08-31 22:21:35 +02:00
|
|
|
radiusKeyMgmt = {
|
|
|
|
wpa_key_mgmt = "WPA-EAP";
|
|
|
|
};
|
|
|
|
|
2024-03-06 19:14:58 +01:00
|
|
|
modernParams = {
|
|
|
|
hw_mode = "a";
|
|
|
|
he_su_beamformer = 1;
|
|
|
|
he_su_beamformee = 1;
|
|
|
|
he_mu_beamformer = 1;
|
|
|
|
preamble = 1;
|
|
|
|
# Allow radar detection.
|
|
|
|
ieee80211d = 1;
|
|
|
|
ieee80211h = 1;
|
|
|
|
ieee80211ac = 1;
|
|
|
|
ieee80211ax = 1;
|
|
|
|
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]";
|
|
|
|
vht_oper_chwidth = 1;
|
|
|
|
he_oper_chwidth = 1;
|
|
|
|
channel = 36;
|
|
|
|
vht_oper_centr_freq_seg0_idx = 42;
|
|
|
|
he_oper_centr_freq_seg0_idx = 42;
|
|
|
|
require_vht = 1;
|
|
|
|
};
|
2024-08-31 22:21:35 +02:00
|
|
|
|
|
|
|
clientRadius = {
|
|
|
|
ieee8021x = 1;
|
|
|
|
eapol_version = 2;
|
|
|
|
use_pae_group_addr = 1;
|
|
|
|
dynamic_vlan = 0;
|
|
|
|
vlan_tagged_interface = "lan";
|
|
|
|
};
|
|
|
|
|
2024-09-01 18:03:18 +02:00
|
|
|
externalRadius = {
|
|
|
|
# TODO: when we have proper IPAM, set the right value here.
|
|
|
|
own_ip_addr = "127.0.0.1";
|
|
|
|
nas_identifier = "ap01.dgnum.eu";
|
2024-08-31 22:21:35 +02:00
|
|
|
|
2024-09-01 18:03:18 +02:00
|
|
|
# No DNS here, hostapd do not support this mode.
|
|
|
|
auth_server_addr = "129.199.195.129";
|
|
|
|
auth_server_port = 1812;
|
|
|
|
auth_server_shared_secret = "read it online";
|
2024-08-31 22:21:35 +02:00
|
|
|
};
|
|
|
|
|
2024-03-06 19:14:58 +01:00
|
|
|
mkWifiSta =
|
|
|
|
params: interface: secrets:
|
|
|
|
svc.hostapd.build {
|
|
|
|
inherit interface;
|
2024-08-31 22:21:35 +02:00
|
|
|
package = pkgs.hostapd-radius;
|
|
|
|
params = params // secrets;
|
2024-09-01 18:03:18 +02:00
|
|
|
dependencies = [ config.services.jitter ];
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
imports = [
|
|
|
|
"${modulesPath}/wlan.nix"
|
|
|
|
"${modulesPath}/network"
|
2024-09-01 18:03:18 +02:00
|
|
|
"${modulesPath}/dhcp6c"
|
2024-03-06 19:14:58 +01:00
|
|
|
"${modulesPath}/hostapd"
|
|
|
|
"${modulesPath}/ssh"
|
|
|
|
"${modulesPath}/ntp"
|
|
|
|
"${modulesPath}/vlan"
|
|
|
|
"${modulesPath}/bridge"
|
2024-08-31 22:21:35 +02:00
|
|
|
"${modulesPath}/jitter-rng"
|
|
|
|
"${modulesPath}/pki"
|
2024-09-05 14:58:38 +02:00
|
|
|
"${modulesPath}/ubus"
|
2024-08-22 18:45:40 +02:00
|
|
|
../../modules/dgn-access-control.nix
|
|
|
|
# TODO: god that's so a fucking hack.
|
|
|
|
(import "${modulesPath}/../devices/zyxel-nwa50ax").module
|
2024-03-06 19:14:58 +01:00
|
|
|
];
|
|
|
|
|
2024-08-22 18:45:40 +02:00
|
|
|
hostname = "ap01-prototype";
|
2024-03-06 19:14:58 +01:00
|
|
|
|
2024-09-01 18:03:18 +02:00
|
|
|
# Get moar random please
|
|
|
|
services.jitter = svc.jitter-rng.build { };
|
2024-09-05 14:58:38 +02:00
|
|
|
services.ubus = svc.ubus.build { };
|
2024-08-31 22:21:35 +02:00
|
|
|
|
2024-08-22 18:45:40 +02:00
|
|
|
# SSH keys are handled by the access control module.
|
|
|
|
dgn-access-control.enable = true;
|
2024-03-06 19:14:58 +01:00
|
|
|
users.root = {
|
2024-08-22 18:45:40 +02:00
|
|
|
passwd = "$6$jVXFFOp8HBYmgINR$lutB4kvw.W1jlXRby9ZYAgBitQ32RxQdYAGN.s2x4ris8J07vM6tzlRBQoeLELOIEMClDzbciQV0itfHQnTqd1";
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
|
2024-09-01 18:03:18 +02:00
|
|
|
services.int = svc.bridge.primary.build {
|
|
|
|
ifname = "int";
|
|
|
|
macAddressFromInterface = config.hardware.networkInterfaces.lan;
|
|
|
|
};
|
2024-03-06 19:14:58 +01:00
|
|
|
|
|
|
|
services.bridge = svc.bridge.members.build {
|
|
|
|
primary = services.int;
|
2024-09-05 14:59:16 +02:00
|
|
|
members = {
|
|
|
|
lan.member = config.hardware.networkInterfaces.lan;
|
|
|
|
wlan1 = {
|
|
|
|
member = config.hardware.networkInterfaces.wlan1;
|
|
|
|
# Bridge only once hostapd is ready.
|
2024-09-07 21:14:16 +02:00
|
|
|
dependencies = [ config.services.hostap-2-ready ];
|
2024-09-05 14:59:16 +02:00
|
|
|
};
|
|
|
|
};
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
|
2024-09-01 18:03:18 +02:00
|
|
|
services.resolvconf = oneshot rec {
|
|
|
|
name = "resolvconf";
|
|
|
|
up = ''
|
|
|
|
. ${serviceFns}
|
|
|
|
( in_outputs ${name}
|
|
|
|
for i in $(output ${services.dhcpv4} dns); do
|
|
|
|
echo "nameserver $i" >> resolv.conf
|
|
|
|
done
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
config.services.dhcpv4
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
filesystem = dir {
|
|
|
|
etc = dir {
|
|
|
|
"resolv.conf" = symlink "${config.services.resolvconf}/.outputs/resolv.conf";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.dhcpv4 = svc.network.dhcp.client.build {
|
|
|
|
interface = config.services.int;
|
|
|
|
dependencies = [
|
|
|
|
config.services.hostname
|
2024-09-05 14:59:16 +02:00
|
|
|
config.services.bridge.components.lan
|
2024-09-01 18:03:18 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-09-01 18:04:56 +02:00
|
|
|
# TODO(raito): these won't work with RAs
|
|
|
|
# fix them in Liminix directly and re-enable.
|
|
|
|
# services.dhcpv6 = svc.dhcp6c.client.build {
|
|
|
|
# interface = config.services.int;
|
|
|
|
# dependencies = [
|
|
|
|
# config.services.hostname
|
|
|
|
# config.services.bridge
|
|
|
|
# ];
|
|
|
|
# };
|
2024-09-01 18:03:18 +02:00
|
|
|
|
2024-09-01 18:04:56 +02:00
|
|
|
# services.ipv6 = svc.dhcp6c.address.build {
|
|
|
|
# interface = config.services.int;
|
|
|
|
# client = config.services.dhcpv6;
|
|
|
|
# dependencies = [ config.services.hostname ];
|
|
|
|
# };
|
2024-03-06 19:14:58 +01:00
|
|
|
|
|
|
|
services.defaultroute4 = svc.network.route.build {
|
2024-09-01 18:03:18 +02:00
|
|
|
via = "$(output ${services.dhcpv4} router)";
|
2024-03-06 19:14:58 +01:00
|
|
|
target = "default";
|
|
|
|
dependencies = [ services.dhcpv4 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.packet_forwarding = svc.network.forward.build { };
|
|
|
|
services.sshd = svc.ssh.build { allowRoot = true; };
|
|
|
|
|
|
|
|
services.ntp = config.system.service.ntp.build {
|
|
|
|
pools = {
|
|
|
|
"pool.ntp.org" = [ "iburst" ];
|
|
|
|
};
|
2024-09-01 18:03:18 +02:00
|
|
|
|
|
|
|
dependencies = [ config.services.jitter ];
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
boot.tftp = {
|
|
|
|
serverip = "192.0.2.10";
|
|
|
|
ipaddr = "192.0.2.12";
|
|
|
|
};
|
|
|
|
|
|
|
|
# wlan0 is the 2.4GHz interface.
|
2024-09-01 18:03:18 +02:00
|
|
|
# services.hostap-1 = mkWifiSta (
|
|
|
|
# baseParams // radiusKeyMgmt
|
|
|
|
# ) config.hardware.networkInterfaces.wlan0 secrets-1;
|
2024-03-06 19:14:58 +01:00
|
|
|
# wlan1 is the 5GHz interface, e.g. AX capable.
|
2024-05-13 17:04:49 +02:00
|
|
|
services.hostap-2 = mkWifiSta (
|
2024-09-01 18:03:18 +02:00
|
|
|
baseParams // clientRadius // externalRadius // radiusKeyMgmt // modernParams
|
2024-05-13 17:04:49 +02:00
|
|
|
) config.hardware.networkInterfaces.wlan1 secrets-2;
|
2024-09-07 21:14:16 +02:00
|
|
|
# Oneshot that waits until the hostapd has set the interface in operational state.
|
|
|
|
services.hostap-2-ready = svc.hostapd-ready.build {
|
|
|
|
interface = config.hardware.networkInterfaces.wlan1;
|
|
|
|
};
|
2024-03-06 19:14:58 +01:00
|
|
|
|
|
|
|
defaultProfile.packages = with pkgs; [
|
|
|
|
zyxel-bootconfig
|
|
|
|
min-collect-garbage
|
|
|
|
mtdutils
|
|
|
|
];
|
|
|
|
}
|