Correctly handle lua conversion for empty lists.

This commit is contained in:
Kevin Baensch 2024-05-18 11:14:54 +02:00
parent 95e7679c82
commit feaaf56e54
Signed by: derped
GPG key ID: C0F1D326C7626543

View file

@ -70,6 +70,7 @@ let
listToLua = listToLua =
list: list:
assert builtins.isList list; assert builtins.isList list;
if list != [ ] then
let let
wrap = (lib.elemAt list 0) != "__unpack"; wrap = (lib.elemAt list 0) != "__unpack";
strippedList = if wrap then list else (lib.drop 1 list); strippedList = if wrap then list else (lib.drop 1 list);
@ -78,7 +79,9 @@ let
(optionalString wrap "{") (optionalString wrap "{")
(concatStringsSep "," (map toLua strippedList)) (concatStringsSep "," (map toLua strippedList))
(optionalString wrap "}") (optionalString wrap "}")
]; ]
else
"{}";
/** /**
Converts a nix set into its Lua representation. Converts a nix set into its Lua representation.