From fc0396591536cab970f7114caeb30c883e9d83d4 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Wed, 14 Aug 2024 22:56:01 +0100 Subject: [PATCH] hostapd literal_or_output use an attrset for dispatch --- modules/hostapd/service.nix | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/hostapd/service.nix b/modules/hostapd/service.nix index 1fea256..9969cfc 100644 --- a/modules/hostapd/service.nix +++ b/modules/hostapd/service.nix @@ -25,13 +25,11 @@ let ctrl_interface_group = 0; }; attrs = defaults // params ; - literal_or_output = o: - let typ = builtins.typeOf o; - in if typ == "string" - then builtins.toJSON o - else if typ == "int" - then builtins.toJSON o - else "output(${builtins.toJSON o.service}, ${builtins.toJSON o.path})"; + literal_or_output = o: ({ + string = builtins.toJSON; + int = builtins.toJSON; + set = (o: "output(${builtins.toJSON o.service}, ${builtins.toJSON o.path})"); + }.${builtins.typeOf o}) o; format_value = n : v: "${n}={{ ${literal_or_output v} }}"; conf =