In this post, I will show you how you can take some JSON and convert it into a Nix attribute set. This was particularly useful when I was creating my waybar configuration. Which is usually in JSON, but defined in my home-manager Nix config it has to be in nixlang.
So given this:
"custom/notification": { "tooltip": false, "format": "{icon}", "format-icons": { "notification": "<span foreground='red'><sup></sup></span>", "none": "", "dnd-notification": "<span foreground='red'><sup></sup></span>", "dnd-none": "", "inhibited-notification": "<span foreground='red'><sup></sup></span>", "inhibited-none": "", "dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>", "dnd-inhibited-none": "" }, "return-type": "json", "exec-if": "which swaync-client", "exec": "swaync-client -swb", "on-click": "swaync-client -t -sw", "on-click-right": "swaync-client -d -sw", "escape": true }, We want it to look something like:
...