diff options
author | Freya Murphy <freya@freyacat.org> | 2025-06-19 15:32:57 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-06-19 15:32:57 -0400 |
commit | d0e672386d7a756e7c7bc2a5530a00801fe203c9 (patch) | |
tree | 1864dfe3a8ec0492e3ef939efb2a10484e76cf4d /lib/lua.nix | |
parent | update astal notifications (diff) | |
download | dotfiles-nix-d0e672386d7a756e7c7bc2a5530a00801fe203c9.tar.gz dotfiles-nix-d0e672386d7a756e7c7bc2a5530a00801fe203c9.tar.bz2 dotfiles-nix-d0e672386d7a756e7c7bc2a5530a00801fe203c9.zip |
add libs to flake
Diffstat (limited to '')
-rw-r--r-- | lib/lua.nix | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/lua.nix b/lib/lua.nix new file mode 100644 index 0000000..704cdfa --- /dev/null +++ b/lib/lua.nix @@ -0,0 +1,32 @@ +{lib, ...}: let + fmt = val: + # nil + if val == null + then "nil" + # boolean + else if builtins.isBool val + then + if val + then "true" + else "false" + # number + else if builtins.isInt val || builtins.isFloat val + then toString val + # string + else if builtins.isString val + then "'${val}'" + # table (array) + else if builtins.isList val + then "{ " + (lib.concatStringsSep ", " (map fmt val)) + " }" + # table (object) + else if builtins.isAttrs val + then + "{ " + + (lib.concatStringsSep ", " + (lib.mapAttrsToList (k: v: "${k} = ${fmt v}") val)) + + " }" + # invalid + else throw "Unsupported value: ${toString val}"; +in { + fmt = fmt; +} |