liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 97defc2076cafe0cea44fa0a1cc4edd58eecd88f
parent ddaa5476d3b8fadb836f5c13829886e6922c388f
Author: Daniel Barlow <dan@telent.net>
Date:   Sat, 17 Aug 2024 22:22:33 +0100

hostapd: get secrets service/path from attrs

Diffstat:
Mmodules/hostapd/service.nix | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/modules/hostapd/service.nix b/modules/hostapd/service.nix @@ -10,6 +10,7 @@ let inherit (liminix.services) longrun; inherit (lib) concatStringsSep mapAttrsToList; + inherit (builtins) map filter attrValues length head typeOf; # This is not a friendly interface to configuring a wireless AP: it # just passes everything straight through to the hostapd config. @@ -46,14 +47,22 @@ let run = '' mkdir -p /run/${name} chmod 0700 /run/${name} - ${output-template}/bin/output-template '{{' '}}' < ${conf} > /run/${name}/hostapd.conf - exec ${hostapd}/bin/hostapd -i $(output ${interface} ifname) -P /run/${name}/hostapd.pid -S /run/${name}/hostapd.conf + ${output-template}/bin/output-template '{{' '}}' < ${conf} > /run/${name}/hostapd.conf + exec ${hostapd}/bin/hostapd -i $(output ${interface} ifname) -P /run/${name}/hostapd.pid -S /run/${name}/hostapd.conf ''; }; + watched-services = + (filter (f: typeOf f == "set") (attrValues attrs)); + in svc.secrets.subscriber.build { watch = { - service = attrs.wpa_passphrase.service; - paths = ["wpa_passphrase"]; + service = assert (length watched-services == 1); (head watched-services).service; + paths = unique ( + map (s: s.path) + (filter + (f: f.service == (head watched-services).service) + watched-services + )); }; inherit service; action = "restart-all";