2022-04-13 19:20:37 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.services.create_ap;
|
2024-08-28 21:19:04 +02:00
|
|
|
configFile = pkgs.writeText "create_ap.conf" (lib.generators.toKeyValue { } cfg.settings);
|
2022-04-13 19:20:37 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.create_ap = {
|
2024-08-28 21:19:04 +02:00
|
|
|
enable = lib.mkEnableOption "setting up wifi hotspots using create_ap";
|
|
|
|
settings = lib.mkOption {
|
|
|
|
type =
|
|
|
|
with lib.types;
|
|
|
|
attrsOf (oneOf [
|
|
|
|
int
|
|
|
|
bool
|
|
|
|
str
|
|
|
|
]);
|
2022-04-13 19:20:37 +02:00
|
|
|
default = { };
|
|
|
|
description = ''
|
2022-08-13 05:15:06 +02:00
|
|
|
Configuration for `create_ap`.
|
2022-04-13 19:20:37 +02:00
|
|
|
See [upstream example configuration](https://raw.githubusercontent.com/lakinduakash/linux-wifi-hotspot/master/src/scripts/create_ap.conf)
|
|
|
|
for supported values.
|
|
|
|
'';
|
|
|
|
example = {
|
|
|
|
INTERNET_IFACE = "eth0";
|
|
|
|
WIFI_IFACE = "wlan0";
|
|
|
|
SSID = "My Wifi Hotspot";
|
|
|
|
PASSPHRASE = "12345678";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-28 21:19:04 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2022-04-13 19:20:37 +02:00
|
|
|
|
|
|
|
systemd = {
|
|
|
|
services.create_ap = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
description = "Create AP Service";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
restartTriggers = [ configFile ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.linux-wifi-hotspot}/bin/create_ap --config ${configFile}";
|
|
|
|
KillSignal = "SIGINT";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ onny ];
|
|
|
|
|
|
|
|
}
|