nixos/create_ap: add module

This commit is contained in:
Jonas Heinrich 2022-04-13 19:20:37 +02:00 committed by Yt
parent 379f69851f
commit 24b53785cc
5 changed files with 71 additions and 5 deletions

View file

@ -375,6 +375,14 @@
<link xlink:href="options.html#opt-services.headscale.enable">services.headscale</link>
</para>
</listitem>
<listitem>
<para>
<link xlink:href="https://github.com/lakinduakash/linux-wifi-hotspot">create_ap</link>,
a module for creating wifi hotspots using the program
linux-wifi-hotspot. Available as
<link xlink:href="options.html#opt-services.create_ap.enable">services.create_ap</link>.
</para>
</listitem>
<listitem>
<para>
<link xlink:href="https://0xerr0r.github.io/blocky/">blocky</link>,

View file

@ -107,6 +107,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- [headscale](https://github.com/juanfont/headscale), an Open Source implementation of the [Tailscale](https://tailscale.io) Control Server. Available as [services.headscale](options.html#opt-services.headscale.enable)
- [create_ap](https://github.com/lakinduakash/linux-wifi-hotspot), a module for creating wifi hotspots using the program linux-wifi-hotspot. Available as [services.create_ap](options.html#opt-services.create_ap.enable).
- [blocky](https://0xerr0r.github.io/blocky/), fast and lightweight DNS proxy as ad-blocker for local network with many features.
- [pacemaker](https://clusterlabs.org/pacemaker/) cluster resource manager

View file

@ -740,6 +740,7 @@
./services/networking/coredns.nix
./services/networking/corerad.nix
./services/networking/coturn.nix
./services/networking/create_ap.nix
./services/networking/croc.nix
./services/networking/dante.nix
./services/networking/ddclient.nix

View file

@ -0,0 +1,50 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.create_ap;
configFile = pkgs.writeText "create_ap.conf" (generators.toKeyValue { } cfg.settings);
in {
options = {
services.create_ap = {
enable = mkEnableOption "setup wifi hotspots using create_ap";
settings = mkOption {
type = with types; attrsOf (oneOf [ int bool str ]);
default = {};
description = ''
Configuration for <package>create_ap</package>.
See <link xlink:href="https://raw.githubusercontent.com/lakinduakash/linux-wifi-hotspot/master/src/scripts/create_ap.conf">upstream example configuration</link>
for supported values.
'';
example = {
INTERNET_IFACE = "eth0";
WIFI_IFACE = "wlan0";
SSID = "My Wifi Hotspot";
PASSPHRASE = "12345678";
};
};
};
};
config = mkIf cfg.enable {
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 ];
}

View file

@ -8,7 +8,13 @@
, iw
, makeWrapper
, qrencode
, hostapd }:
, hostapd
, getopt
, dnsmasq
, iproute2
, flock
, iptables
, gawk }:
stdenv.mkDerivation rec {
pname = "linux-wifi-hotspot";
@ -41,9 +47,6 @@ stdenv.mkDerivation rec {
--replace "etc" "$out/etc"
substituteInPlace ./src/scripts/wihotspot \
--replace "/usr" "$out"
substituteInPlace ./src/scripts/create_ap.service \
--replace "/usr/bin/create_ap" "$out/bin/create_cap" \
--replace "/etc/create_ap.conf" "$out/etc/create_cap.conf"
'';
makeFlags = [
@ -52,7 +55,9 @@ stdenv.mkDerivation rec {
postInstall = ''
wrapProgram $out/bin/create_ap \
--prefix PATH : ${lib.makeBinPath [ hostapd ]}
--prefix PATH : ${lib.makeBinPath [
hostapd getopt iw which dnsmasq iproute2 flock iptables gawk
]}
wrapProgram $out/bin/wihotspot-gui \
--prefix PATH : ${lib.makeBinPath [ iw ]} \