feat: add flake.nix
This commit is contained in:
parent
bbf568bc04
commit
0dbe093453
2 changed files with 90 additions and 0 deletions
13
README.md
13
README.md
|
@ -1,6 +1,19 @@
|
||||||
# nix-gen-luarc-json
|
# nix-gen-luarc-json
|
||||||
|
|
||||||
Generate a .luarc.json for Lua/Neovim devShells
|
Generate a .luarc.json for Lua/Neovim devShells
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Apply this flake's overlay.
|
||||||
|
It provides a `mk-luarc-json` function,
|
||||||
|
which takes an attrset with the following arguments:
|
||||||
|
|
||||||
|
- `nvim`: The neovim package. Defaults to `neovim-unwrapped`.
|
||||||
|
- `neodev-types`: neodev.nvim types to add to the `workspace.library`.
|
||||||
|
Defaults to `"stable"`.
|
||||||
|
- Plugins: List of Neovim plugins and/or luarocks packages.
|
||||||
|
Defaults to an empty list.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This flake is [licensed according to GPL version 2](./LICENSE),
|
This flake is [licensed according to GPL version 2](./LICENSE),
|
||||||
|
|
77
flake.nix
Normal file
77
flake.nix
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
description = "Generate a .luarc.json for Lua/Neovim devShells";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = inputs @ {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-parts,
|
||||||
|
}:
|
||||||
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||||
|
flake = {
|
||||||
|
overlays.default = final: prev: {
|
||||||
|
mk-luarc-json = {
|
||||||
|
# list of plugins that have a /lua directory
|
||||||
|
nvim ? final.neovim-unwrapped,
|
||||||
|
neodev-types ? "stable",
|
||||||
|
plugins ? [],
|
||||||
|
}: let
|
||||||
|
lib = final.lib;
|
||||||
|
plugin-lib-dirs = lib.lists.map (plugin:
|
||||||
|
if
|
||||||
|
builtins.hasAttr "vimPlugin" plugin
|
||||||
|
&& plugin.vimPlugin
|
||||||
|
|| plugin.pname == "nvim-treesitter"
|
||||||
|
then "${plugin}/lua"
|
||||||
|
else "${plugin}/lib/lua/5.1")
|
||||||
|
plugins;
|
||||||
|
luarc = {
|
||||||
|
runtime.version = "LuaJIT";
|
||||||
|
Lua = {
|
||||||
|
globals = [
|
||||||
|
"vim"
|
||||||
|
];
|
||||||
|
workspace = {
|
||||||
|
library =
|
||||||
|
[
|
||||||
|
"${nvim}/share/nvim/runtime/lua"
|
||||||
|
"${final.vimPlugins.neodev-nvim}/types/${neodev-types}"
|
||||||
|
"\${3rd}/busted/library"
|
||||||
|
"\${3rd}/luassert/library"
|
||||||
|
]
|
||||||
|
++ plugin-lib-dirs;
|
||||||
|
ignoreDir = [
|
||||||
|
".git"
|
||||||
|
".github"
|
||||||
|
".direnv"
|
||||||
|
"result"
|
||||||
|
"nix"
|
||||||
|
"doc"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
diagnostics = {
|
||||||
|
libraryFiles = "Disable";
|
||||||
|
disable = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
final.runCommand ".luarc.json" {
|
||||||
|
buildInputs = [
|
||||||
|
final.jq
|
||||||
|
];
|
||||||
|
passAsFile = ["rawJSON"];
|
||||||
|
rawJSON = builtins.toJSON luarc;
|
||||||
|
} ''
|
||||||
|
{
|
||||||
|
jq . <"$rawJSONPath"
|
||||||
|
} >$out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue