diff --git a/modules/home/gotify.nix b/modules/home/gotify.nix index d85179b..9cd0101 100644 --- a/modules/home/gotify.nix +++ b/modules/home/gotify.nix @@ -21,6 +21,39 @@ on_msg_command = cfg.daemon.onMsgCommand; }; }; + + valueToString = val: + if (builtins.typeOf val == "string") + then "\"${val}\"" + else + ( + if (builtins.typeOf val == "int") + then "${toString val}" + else + ( + if (builtins.typeOf val == "bool") + then + ( + if val + then "true" + else "false" + ) + else (abort "Expected string int or bool, got ${builtins.typeOf val} with value ${toString val}") + ) + ); + + toTOML = attrs: + lib.concatStrings ( + lib.attrValues ( + lib.mapAttrs ( + name: config: '' + [${name}] + ${lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs (k: v: "${k} = ${valueToString v}") config))} + '' + ) + attrs + ) + ); in { options.hive.gotify = { cli = { @@ -107,10 +140,7 @@ in { }; }; sops.templates."gotify-daemon-toml" = { - content = '' - [gotify] - ${lib.generators.toKeyValue {} daemon-config.gotify} - ''; + content = toTOML daemon-config; path = "${config.xdg.configHome}/gotify-desktop/config.toml"; }; };