lib/to-lua: handle derivations as path strings

Fixes #1888
This commit is contained in:
Matt Sturgeon 2024-07-22 13:11:31 +01:00
parent 34aa3e00e7
commit 6dc0bda459
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 23 additions and 4 deletions

View file

@ -141,6 +141,8 @@ rec {
value
else if allowRawValues && value ? __raw then
value
else if isDerivation value then
value
else if isList value then
let
needsFiltering = removeNullListEntries || removeEmptyListEntries;
@ -205,8 +207,8 @@ rec {
builtins.toJSON v
else if isBool v then
boolToString v
else if isPath v then
go indent (toString v)
else if isPath v || isDerivation v then
go indent "${v}"
else if isString v then
# TODO: support lua's escape sequences, literal string, and content-appropriate quote style
# See https://www.lua.org/pil/2.4.html
@ -217,8 +219,6 @@ rec {
"{ }"
else if isFunction v then
abort "nixvim(toLua): Unexpected function: " + generators.toPretty { } v
else if isDerivation v then
abort "nixvim(toLua): Unexpected derivation: " + generators.toPretty { } v
else if isList v then
"{" + introSpace + concatMapStringsSep ("," + introSpace) (go (indent + " ")) v + outroSpace + "}"
else if isAttrs v then