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