2022-10-01 19:53:20 +02:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, hostapd
|
|
|
|
, writeText
|
2023-07-16 18:50:06 +02:00
|
|
|
, lib
|
2022-10-01 19:53:20 +02:00
|
|
|
}:
|
2023-08-05 13:21:18 +02:00
|
|
|
{ interface, params} :
|
2022-10-01 19:53:20 +02:00
|
|
|
let
|
|
|
|
inherit (liminix.services) longrun;
|
|
|
|
inherit (lib) concatStringsSep mapAttrsToList;
|
2023-07-16 18:50:06 +02:00
|
|
|
inherit (liminix.lib) typeChecked;
|
|
|
|
inherit (lib) mkOption types;
|
|
|
|
|
|
|
|
# This is not a friendly interface to configuring a wireless AP: it
|
|
|
|
# just passes everything straight through to the hostapd config.
|
|
|
|
# When we've worked out what the sensible options are to expose,
|
|
|
|
# we'll add them as top-level attributes and rename params to
|
|
|
|
# extraParams
|
2022-10-01 19:53:20 +02:00
|
|
|
|
|
|
|
name = "${interface.device}.hostapd";
|
|
|
|
defaults = {
|
|
|
|
driver = "nl80211";
|
|
|
|
logger_syslog = "-1";
|
|
|
|
logger_syslog_level = 1;
|
|
|
|
ctrl_interface = "/run/hostapd";
|
|
|
|
ctrl_interface_group = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
conf = writeText "hostapd.conf"
|
|
|
|
(concatStringsSep
|
|
|
|
"\n"
|
|
|
|
(mapAttrsToList
|
|
|
|
(name: value: "${name}=${toString value}")
|
|
|
|
(defaults // params)));
|
|
|
|
in longrun {
|
|
|
|
inherit name;
|
2023-03-01 19:13:54 +01:00
|
|
|
dependencies = [ interface ];
|
2023-03-07 20:11:25 +01:00
|
|
|
run = "${hostapd}/bin/hostapd -i ${interface.device} -P /run/${name}.pid -S ${conf}";
|
2022-10-01 19:53:20 +02:00
|
|
|
}
|