From f1e3d3074c6f62b0991af3655ace2c06dabeb9c0 Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 27 Jul 2025 11:11:14 +0200 Subject: a small commit for mankind, nah, a big one! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - moved the oidc client secrets into age secrets (and rotated them) - changed stuff™ --- nix/modules/libvirtnix/xml.nix | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'nix/modules/libvirtnix/xml.nix') diff --git a/nix/modules/libvirtnix/xml.nix b/nix/modules/libvirtnix/xml.nix index 134a878..10eefa3 100644 --- a/nix/modules/libvirtnix/xml.nix +++ b/nix/modules/libvirtnix/xml.nix @@ -32,14 +32,27 @@ closing ? true, # add a closing tag }: let - args_str = - " " + lib.strings.concatStrings (lib.strings.intersperse " " (map (x: "${x.key}='${x.val}'") args)); + + # filter out all values missing a key + # this allows passing empty args such as `{}` which then get discarded + filteredArgs = (builtins.filter (x: x ? key) args); + + # convert the list of attr sets into a list of strings + mappedArgs = (map (x: "${x.key}='${x.val}'") filteredArgs); + + # [ "A" "B" "C" ] => [ "A" " " "B" " " "C" ] + spacedArgs = lib.strings.intersperse "" mappedArgs; + + # [ "A" " " "B" " " "C" ] => "A B C" + joinedArgs = lib.strings.concatStrings spacedArgs; + + # prefix the args with a space when inserting + args_str = lib.optionalString (filteredArgs != [ ]) (" " + joinedArgs); + child_evaled = lib.strings.concatStrings children; cond = condition: value: if condition then value else ""; closingTag = if closing == true then "" else ""; in -"<${name}${ - lib.optionalString (args != [ ]) args_str -}${cond (closing == false) "/"}>${value}${child_evaled}${lib.optionalString (closing) closingTag}" +"<${name}${args_str}${cond (closing == false) "/"}>${value}${child_evaled}${lib.optionalString (closing) closingTag}" -- cgit 1.4.1