pkgs:
let
inherit (builtins) typeOf elem;
inherit (pkgs.lib) mapAttrsToList concatStringsSep concatMapStringsSep;
luaElem = id: val: "${id} = ${toLUA val}";
luaAttrs = a: "{ ${a |> mapAttrsToList luaElem |> concatStringsSep ", "} }";
luaList = l: "{ ${concatMapStringsSep ", " toLUA l} }";
toLUA = a: let type = typeOf a; in
if elem type ["int" "float" "string" "path"]
then toString a
else if type == "list"
then luaList a
else if type == "set"
then luaAttrs a
else abort "Not implemented type: ${type}";
in toLUA