diff options
author | Jonas Heinrich <onny@project-insanity.org> | 2022-04-13 19:20:37 +0200 |
---|---|---|
committer | Yt <raphael@megzari.com> | 2022-04-23 07:17:44 -0400 |
commit | 24b53785cce8f81e2171c2e4042bfd4e3d0b2606 (patch) | |
tree | 65e0abe3b44765f7ceaa556d8de1eb6487d095bf | |
parent | 379f69851f070a39ec78a521ecbbca263d75cb8b (diff) | |
download | nixpkgs-24b53785cce8f81e2171c2e4042bfd4e3d0b2606.tar nixpkgs-24b53785cce8f81e2171c2e4042bfd4e3d0b2606.tar.gz nixpkgs-24b53785cce8f81e2171c2e4042bfd4e3d0b2606.tar.bz2 nixpkgs-24b53785cce8f81e2171c2e4042bfd4e3d0b2606.tar.lz nixpkgs-24b53785cce8f81e2171c2e4042bfd4e3d0b2606.tar.xz nixpkgs-24b53785cce8f81e2171c2e4042bfd4e3d0b2606.tar.zst nixpkgs-24b53785cce8f81e2171c2e4042bfd4e3d0b2606.zip |
nixos/create_ap: add module
-rw-r--r-- | nixos/doc/manual/from_md/release-notes/rl-2205.section.xml | 8 | ||||
-rw-r--r-- | nixos/doc/manual/release-notes/rl-2205.section.md | 2 | ||||
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/networking/create_ap.nix | 50 | ||||
-rw-r--r-- | pkgs/os-specific/linux/linux-wifi-hotspot/default.nix | 15 |
5 files changed, 71 insertions, 5 deletions
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index af2aecda0da..05b3822cab7 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -377,6 +377,14 @@ </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>, fast and lightweight DNS proxy as ad-blocker for local network with many features. diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index 6d22973fb9b..16c59ce3ddd 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -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 diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 9aa8817ca51..132416d865f 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/services/networking/create_ap.nix b/nixos/modules/services/networking/create_ap.nix new file mode 100644 index 00000000000..a3c330fab00 --- /dev/null +++ b/nixos/modules/services/networking/create_ap.nix @@ -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 ]; + +} diff --git a/pkgs/os-specific/linux/linux-wifi-hotspot/default.nix b/pkgs/os-specific/linux/linux-wifi-hotspot/default.nix index 2cefc9b0216..a29fe923f60 100644 --- a/pkgs/os-specific/linux/linux-wifi-hotspot/default.nix +++ b/pkgs/os-specific/linux/linux-wifi-hotspot/default.nix @@ -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 ]} \ |