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

@ -45,6 +45,8 @@ let
];
};
drv = pkgs.writeText "example-derivation" "hello, world!";
results = pkgs.lib.runTests {
testToLuaObject = {
expr = helpers.toLuaObject {
@ -124,6 +126,23 @@ let
expected = ''"foo\\bar\nbaz"'';
};
testToLuaObjectDerivation = {
expr = helpers.toLuaObject drv;
expected = ''"${drv}"'';
};
testToLuaObjectDerivationNested = {
expr = helpers.toLuaObject {
a = drv;
b = {
c = drv;
};
d = [ drv ];
e = [ { f = drv; } ];
};
expected = ''{ a = "${drv}", b = { c = "${drv}" }, d = { "${drv}" }, e = { { f = "${drv}" } } }'';
};
testToLuaObjectFilters = {
expr = helpers.toLuaObject {
a = null;