lua.lib: support arbitrary settings in generateLuarocksConfig

I wanted to improve the generated luarocks config.
The current system appends a string to it, this commit allows to pass
arbitrary nix code and have it autoconverted to lua along with the
default settings in the luarocks config.
This commit is contained in:
Matthieu Coudron 2023-12-14 22:43:05 +01:00
parent 4ea6c0c58b
commit 2191b7662d

View File

@ -76,18 +76,23 @@ rec {
/* generate luarocks config
generateLuarocksConfig {
externalDeps = [ { name = "CRYPTO"; dep = pkgs.openssl; } ];
rocksSubdir = "subdir";
};
Example:
generateLuarocksConfig {
externalDeps = [ { name = "CRYPTO"; dep = pkgs.openssl; } ];
rocksSubdir = "subdir";
};
Type:
generateLuarocksConfig :: AttrSet -> String
*/
generateLuarocksConfig = {
externalDeps ? []
externalDeps ? []
# a list of lua derivations
, requiredLuaRocks ? []
, extraVariables ? {}
, rocksSubdir ? "rocks-subdir"
}: let
, ...
}@args: let
rocksTrees = lib.imap0
(i: dep: {
name = "dep-${toString i}";
@ -140,5 +145,7 @@ rec {
# Some needed machinery to handle multiple-output external dependencies,
# as per https://github.com/luarocks/luarocks/issues/766
variables = (depVariables // extraVariables);
});
}
// removeAttrs args [ "rocksSubdir" "extraVariables" "requiredLuaRocks" "externalDeps" ]
);
}