From f82501d27821d673cab312b2ed41d0e3a64f0011 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 5 Aug 2023 12:21:18 +0100 Subject: [PATCH] update hostapd to "build" syntax --- examples/rotuer.nix | 4 ++-- modules/hostapd/default.nix | 12 ++++++++++-- modules/hostapd/service.nix | 14 +------------- tests/wlan/configuration.nix | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/examples/rotuer.nix b/examples/rotuer.nix index 716663b..324d518 100644 --- a/examples/rotuer.nix +++ b/examples/rotuer.nix @@ -54,7 +54,7 @@ in rec { rootfsType = "jffs2"; hostname = "rotuer"; - services.hostap = svc.hostapd { + services.hostap = svc.hostapd.build { interface = config.hardware.networkInterfaces.wlan_24; params = { ssid = "liminix"; @@ -64,7 +64,7 @@ in rec { } // wirelessConfig; }; - services.hostap5 = svc.hostapd { + services.hostap5 = svc.hostapd.build { interface = config.hardware.networkInterfaces.wlan_5; params = rec { ssid = "liminix_5"; diff --git a/modules/hostapd/default.nix b/modules/hostapd/default.nix index c02303b..e1b346a 100644 --- a/modules/hostapd/default.nix +++ b/modules/hostapd/default.nix @@ -1,13 +1,21 @@ { lib, pkgs, config, ...}: let inherit (lib) mkOption types; + inherit (pkgs) liminix; in { options = { system.service.hostapd = mkOption { - type = types.functionTo types.package; + type = liminix.lib.types.serviceDefn; }; }; config = { - system.service.hostapd = pkgs.callPackage ./service.nix {}; + system.service.hostapd = liminix.callService ./service.nix { + interface = mkOption { + type = liminix.lib.types.service; + }; + params = mkOption { + type = types.attrs; + }; + }; }; } diff --git a/modules/hostapd/service.nix b/modules/hostapd/service.nix index c371791..6c02daf 100644 --- a/modules/hostapd/service.nix +++ b/modules/hostapd/service.nix @@ -4,6 +4,7 @@ , writeText , lib }: +{ interface, params} : let inherit (liminix.services) longrun; inherit (lib) concatStringsSep mapAttrsToList; @@ -16,19 +17,6 @@ let # we'll add them as top-level attributes and rename params to # extraParams - t = { - interface = mkOption { - type = liminix.lib.types.service; - }; - params = mkOption { - type = types.attrs; - }; - }; -in -args: -let - inherit (typeChecked "hostapd" t args) - interface params; name = "${interface.device}.hostapd"; defaults = { driver = "nl80211"; diff --git a/tests/wlan/configuration.nix b/tests/wlan/configuration.nix index 5776505..d6d321f 100644 --- a/tests/wlan/configuration.nix +++ b/tests/wlan/configuration.nix @@ -10,7 +10,7 @@ in rec { ../../modules/hostapd ]; - services.hostap = config.system.service.hostapd { + services.hostap = config.system.service.hostapd.build { interface = config.hardware.networkInterfaces.wlan_24; params = { ssid = "liminix";