diff options
author | Emile <git@emile.space> | 2025-07-27 11:11:14 +0200 |
---|---|---|
committer | Emile <git@emile.space> | 2025-07-27 11:11:14 +0200 |
commit | f1e3d3074c6f62b0991af3655ace2c06dabeb9c0 (patch) | |
tree | 2a4e441d7f1065dfaa236d0521c7d46789c406e3 /nix/modules/libvirtnix/xml.nix | |
parent | e1503afe5b1b3c08c0673be5d987accb21cf435f (diff) |
a small commit for mankind, nah, a big one!
- moved the oidc client secrets into age secrets (and rotated them) - changed stuff™
Diffstat (limited to 'nix/modules/libvirtnix/xml.nix')
-rw-r--r-- | nix/modules/libvirtnix/xml.nix | 23 |
1 files changed, 18 insertions, 5 deletions
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 "</${name}>" 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}" |