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:
...