Creating a home manager module for swaync with json formatting

Greetings from me :wave:

I’ve been trying to create a home manager module for swaync, a notification daemon for sway and I’m running into some issues. The file in question: swaync.nix
I’ve got almost everything working but I’m stuck trying to get json formatting to work.

I got a lot of inspiration from this module waybar.nix. I used it as an example for json and css config formatting. I followed most of the steps used to format the output config files but I keep getting this error:

error:
       … while evaluating a branch condition

         at /nix/store/9s5qs4hni9fj88x79iw6im7amv7ghb76-source/lib/lists.nix:57:9:

           56|       fold' = n:
           57|         if n == len
             |         ^
           58|         then nul

       … while calling the 'length' builtin

         at /nix/store/9s5qs4hni9fj88x79iw6im7amv7ghb76-source/lib/lists.nix:55:13:

           54|     let
           55|       len = length list;
             |             ^
           56|       fold' = n:

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: value is a function while a set was expected

I’ve checked everything but I don’t see any point where that’s the case, or maybe I just can’t see it.
Could anyone help me understand what’s wrong and maybe give me a little bit of recommendations on how I can improve the module?