-
Notifications
You must be signed in to change notification settings - Fork 17
Install with nix
Matthieu Coudron edited this page Sep 8, 2024
·
1 revision
This is one way to use rocks.nvim with nixpkgs.
We can configure rocks.nvim to use packages installed by nix such as luarocks or luarocks plugins via:
local custom_luarocks_config_filename = vim.fn.stdpath('config') .. '/luarocks-config-generated.lua'
local luarocks_config_fn = assert(loadfile(custom_luarocks_config_filename))
{
luarocks_binary = nix_deps.luarocks_executable,
luarocks_config = luarocks_config_fn(),
_log_level = vim.log.levels.TRACE,
}
where custom_luarocks_config_filename
is generated via nix. This is an example of the file generated by home-manager:
xdg.configFile = {
"nvim/lua/generated-by-nix.lua" =
let
luaInterpreter = config.programs.neovim.package.lua;
in
{
enable = true;
text = ''
local M = {}
M.gcc_path = "${pkgs.gcc}/bin/gcc"
M.lua_interpreter = "${luaInterpreter}"
M.luarocks_executable = "${luaInterpreter.pkgs.luarocks_bootstrap}/bin/luarocks"
return M
'';
};
# TODO use pkgs.lua.pkgs.luaLib.generateLuarocksConfig
"nvim/luarocks-config-generated.lua" =
let
luaInterpreter = config.programs.neovim.package.lua;
luarocksStore = luaInterpreter.pkgs.luarocks;
luacurlPkg = luaInterpreter.pkgs.lua-curl;
luarocksConfigAttr =
pkgs.lua.pkgs.luaLib.generateLuarocksConfig ({ externalDeps = [ pkgs.curl.dev ]; })
// {
lua_version = "5.1";
};
luarocksConfigAttr = lib.recursiveUpdate luarocksConfigAttr {
rocks_trees = [
({
name = "rocks.nvim";
root = "/home/teto/.local/share/nvim/rocks";
})
({
name = "rocks-generated.nvim";
root = "${luarocksStore}";
})
({
name = "lua-curl";
root = "${luacurlPkg}";
})
({
name = "sqlite.lua";
root = "${luaInterpreter.pkgs.sqlite}";
})
];
# to help some package need variables for lib-curl.lua to be installable
variables = {
# MYSQL_INCDIR = "${libmysqlclient.dev}/include/mysql";
# MYSQL_LIBDIR = "${libmysqlclient}/lib/mysql";
};
};
luarocksConfigStr = (lib.generators.toLua { asBindings = false; } luarocksConfigAttr);
in
{
enable = true;
text = "return ${luarocksConfigStr}";
};
};