at 23.11-pre 1.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.create_ap; 7 configFile = pkgs.writeText "create_ap.conf" (generators.toKeyValue { } cfg.settings); 8in { 9 options = { 10 services.create_ap = { 11 enable = mkEnableOption (lib.mdDoc "setup wifi hotspots using create_ap"); 12 settings = mkOption { 13 type = with types; attrsOf (oneOf [ int bool str ]); 14 default = {}; 15 description = lib.mdDoc '' 16 Configuration for `create_ap`. 17 See [upstream example configuration](https://raw.githubusercontent.com/lakinduakash/linux-wifi-hotspot/master/src/scripts/create_ap.conf) 18 for supported values. 19 ''; 20 example = { 21 INTERNET_IFACE = "eth0"; 22 WIFI_IFACE = "wlan0"; 23 SSID = "My Wifi Hotspot"; 24 PASSPHRASE = "12345678"; 25 }; 26 }; 27 }; 28 }; 29 30 config = mkIf cfg.enable { 31 32 systemd = { 33 services.create_ap = { 34 wantedBy = [ "multi-user.target" ]; 35 description = "Create AP Service"; 36 after = [ "network.target" ]; 37 restartTriggers = [ configFile ]; 38 serviceConfig = { 39 ExecStart = "${pkgs.linux-wifi-hotspot}/bin/create_ap --config ${configFile}"; 40 KillSignal = "SIGINT"; 41 Restart = "on-failure"; 42 }; 43 }; 44 }; 45 46 }; 47 48 meta.maintainers = with lib.maintainers; [ onny ]; 49 50}