first pass at a hostapd service, rough around the edges

This commit is contained in:
Daniel Barlow 2022-10-01 18:53:20 +01:00
parent 8cff11d0a3
commit da8866a01a
5 changed files with 129 additions and 0 deletions

View file

@ -28,6 +28,7 @@ in {
};
pppoe = callPackage ./pppoe.nix {};
dnsmasq = callPackage ./dnsmasq.nix {};
hostapd = callPackage ./hostapd.nix {};
route = { name, target, via, dependencies }:
oneshot {
inherit name;

View file

@ -0,0 +1,39 @@
# 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
{
liminix
, hostapd
, lib
, writeText
}:
interface:
{
params ? {}
}:
let
inherit (liminix.services) longrun;
inherit (lib) concatStringsSep mapAttrsToList;
inherit (builtins) toString;
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;
run = "${hostapd}/bin/hostapd -d -i ${interface.device} -P /run/hostapd.pid -S ${conf}";
}