2024-02-22 13:48:54 -08:00
|
|
|
{
|
|
|
|
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";
|
2024-08-19 10:53:14 -07:00
|
|
|
luvit-meta = {
|
|
|
|
url = "github:Bilal2453/luvit-meta";
|
|
|
|
flake = false;
|
|
|
|
};
|
2024-08-19 13:00:50 -07:00
|
|
|
git-hooks = {
|
|
|
|
url = "github:cachix/git-hooks.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-02-22 13:48:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = inputs @ {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
flake-parts,
|
2024-08-19 10:53:14 -07:00
|
|
|
luvit-meta,
|
2024-08-19 13:00:50 -07:00
|
|
|
git-hooks,
|
2024-02-22 13:48:54 -08:00
|
|
|
}:
|
|
|
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
2024-02-22 14:42:49 -08:00
|
|
|
systems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"aarch64-darwin"
|
|
|
|
"aarch64-linux"
|
|
|
|
];
|
|
|
|
perSystem = {system, ...}: let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [
|
|
|
|
self.overlays.default
|
|
|
|
];
|
|
|
|
};
|
|
|
|
luarc = pkgs.mk-luarc-json {
|
|
|
|
plugins = with pkgs.vimPlugins; [telescope-nvim fidget-nvim];
|
|
|
|
};
|
2024-08-19 13:00:50 -07:00
|
|
|
git-hooks-check = git-hooks.lib.${system}.run {
|
|
|
|
src = self;
|
|
|
|
hooks = {
|
|
|
|
alejandra.enable = true;
|
|
|
|
editorconfig-checker.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2024-02-22 14:42:49 -08:00
|
|
|
in {
|
|
|
|
devShells.default = pkgs.mkShell {
|
2024-08-19 13:00:50 -07:00
|
|
|
name = "gen-luarc devShell";
|
|
|
|
buildInputs = self.checks.${system}.git-hooks-check.enabledPackages;
|
2024-02-22 14:42:49 -08:00
|
|
|
shellHook = ''
|
|
|
|
ln -fs ${pkgs.luarc-to-json luarc} .luarc.json
|
|
|
|
'';
|
|
|
|
};
|
2024-08-19 13:00:50 -07:00
|
|
|
checks = rec {
|
|
|
|
default = git-hooks-check;
|
|
|
|
inherit git-hooks-check;
|
|
|
|
};
|
2024-02-22 14:42:49 -08:00
|
|
|
};
|
2024-02-22 13:48:54 -08:00
|
|
|
flake = {
|
2024-08-19 10:53:14 -07:00
|
|
|
overlays.default = final: prev: let
|
|
|
|
lib = final.lib;
|
|
|
|
in {
|
2024-02-22 14:07:20 -08:00
|
|
|
mk-luarc = {
|
2024-02-22 13:48:54 -08:00
|
|
|
# list of plugins that have a /lua directory
|
|
|
|
nvim ? final.neovim-unwrapped,
|
|
|
|
plugins ? [],
|
2024-08-19 10:53:14 -07:00
|
|
|
meta ? {
|
|
|
|
luvit = true;
|
|
|
|
},
|
2024-02-22 14:27:40 -08:00
|
|
|
lua-version ? "5.1",
|
2024-02-23 03:27:34 -08:00
|
|
|
disabled-diagnostics ? [],
|
2024-02-22 13:48:54 -08:00
|
|
|
}: let
|
2024-03-20 04:24:26 -07:00
|
|
|
pluginPackages =
|
|
|
|
map (
|
|
|
|
x:
|
|
|
|
if x ? plugin
|
|
|
|
then x.plugin
|
|
|
|
else x
|
|
|
|
)
|
|
|
|
plugins;
|
2024-02-22 14:27:40 -08:00
|
|
|
partitions = builtins.partition (plugin:
|
2024-03-20 04:24:26 -07:00
|
|
|
plugin.vimPlugin
|
|
|
|
or false
|
2024-02-23 03:47:35 -08:00
|
|
|
|| plugin.pname or "" == "nvim-treesitter")
|
2024-03-20 04:24:26 -07:00
|
|
|
pluginPackages;
|
2024-02-22 14:42:49 -08:00
|
|
|
nvim-plugins = partitions.right;
|
2024-02-22 14:27:40 -08:00
|
|
|
rocks = partitions.wrong;
|
2024-02-22 14:42:49 -08:00
|
|
|
plugin-luadirs = builtins.map (plugin: "${plugin}/lua") nvim-plugins;
|
2024-02-22 14:27:40 -08:00
|
|
|
pkg-libdirs = builtins.map (pkg: "${pkg}/lib/lua/${lua-version}") rocks;
|
|
|
|
pkg-sharedirs = builtins.map (pkg: "${pkg}/share/lua/${lua-version}") rocks;
|
2024-02-22 14:07:20 -08:00
|
|
|
in {
|
|
|
|
runtime.version = "LuaJIT";
|
|
|
|
Lua = {
|
|
|
|
globals = [
|
|
|
|
"vim"
|
|
|
|
];
|
|
|
|
workspace = {
|
|
|
|
library =
|
|
|
|
[
|
|
|
|
"${nvim}/share/nvim/runtime/lua"
|
|
|
|
"\${3rd}/busted/library"
|
|
|
|
"\${3rd}/luassert/library"
|
|
|
|
]
|
2024-02-22 14:27:40 -08:00
|
|
|
++ plugin-luadirs
|
|
|
|
++ pkg-libdirs
|
2024-08-19 10:53:14 -07:00
|
|
|
++ pkg-sharedirs
|
|
|
|
++ (lib.optional (meta.luvit or false) "${luvit-meta}/library");
|
2024-02-22 14:07:20 -08:00
|
|
|
ignoreDir = [
|
|
|
|
".git"
|
|
|
|
".github"
|
|
|
|
".direnv"
|
|
|
|
"result"
|
|
|
|
"nix"
|
|
|
|
"doc"
|
2024-02-22 13:48:54 -08:00
|
|
|
];
|
2024-02-22 14:07:20 -08:00
|
|
|
};
|
|
|
|
diagnostics = {
|
|
|
|
libraryFiles = "Disable";
|
2024-02-23 03:27:34 -08:00
|
|
|
disable = disabled-diagnostics;
|
2024-02-22 13:48:54 -08:00
|
|
|
};
|
|
|
|
};
|
2024-02-22 14:07:20 -08:00
|
|
|
};
|
2024-02-22 14:42:49 -08:00
|
|
|
luarc-to-json = luarc:
|
|
|
|
final.runCommand ".luarc.json" {
|
2024-02-22 13:48:54 -08:00
|
|
|
buildInputs = [
|
|
|
|
final.jq
|
|
|
|
];
|
|
|
|
passAsFile = ["rawJSON"];
|
|
|
|
rawJSON = builtins.toJSON luarc;
|
|
|
|
} ''
|
|
|
|
{
|
|
|
|
jq . <"$rawJSONPath"
|
|
|
|
} >$out
|
|
|
|
'';
|
2024-02-22 14:07:20 -08:00
|
|
|
mk-luarc-json = attrs: final.luarc-to-json (final.mk-luarc attrs);
|
2024-02-22 13:48:54 -08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|