From 97defc2076cafe0cea44fa0a1cc4edd58eecd88f Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 17 Aug 2024 22:22:33 +0100 Subject: [PATCH] hostapd: get secrets service/path from attrs --- modules/hostapd/service.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/hostapd/service.nix b/modules/hostapd/service.nix index 9c258c9..8ffe3e0 100644 --- 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";