From 9365a8e96827cbf7bc5adad6d29bcd05b4d761b2 Mon Sep 17 00:00:00 2001 From: bee Date: Tue, 5 May 2026 22:37:10 +0530 Subject: Migrate from nixcats to nix-wrapper-modules --- module.nix | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 module.nix (limited to 'module.nix') diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..3f49271 --- /dev/null +++ b/module.nix @@ -0,0 +1,241 @@ +inputs: +{ + config, + wlib, + lib, + pkgs, + ... +}: +{ + imports = [ wlib.wrapperModules.neovim ]; + # NOTE: see the tips and tricks section or the bottom of this file + flake inputs to understand this value + options.nvim-lib.neovimPlugins = lib.mkOption { + readOnly = true; + type = lib.types.attrsOf wlib.types.stringable; + # Makes plugins autobuilt from our inputs available with + # `config.nvim-lib.neovimPlugins.` + default = config.nvim-lib.pluginsFromPrefix "plugins-" inputs; + }; + + # choose a directory for your config. + config.settings.config_directory = ./.; + # you can also use an impure path! + # config.settings.config_directory = lib.generators.mkLuaInline "vim.fn.stdpath('config')"; + # config.settings.config_directory = "/home//.config/nvim"; + # If you do that, it will not be provisioned by nix, but it will have normal reload for quick edits! + + # If you want to install multiple neovim derivations via home.packages or environment.systemPackages + # in order to prevent path collisions: + + # set this to true: + # config.settings.dont_link = true; + + # and make sure these dont share values: + config.binName = "nvim"; + config.settings.aliases = [ + "vim" + "vi" + ]; + + config.hosts.python3.nvim-host.enable = false; + config.hosts.node.nvim-host.enable = false; + config.hosts.ruby.nvim-host.enable = false; + config.hosts.perl.nvim-host.enable = false; + config.hosts.neovide.nvim-host.enable = false; + + # If the defaults are fine, you can just provide the `.data` field + # In this case, a list of specs, instead of a single plugin like above + config.specs.lze = [ + # if defaults is fine, you can just provide the `.data` field + config.nvim-lib.neovimPlugins.lze + # but these can be specs too! + { + # these ones can't take lists though + data = config.nvim-lib.neovimPlugins.lzextras; + # things can target any spec that has a name. + name = "lzextras"; + # now something else can be after = [ "lzextras" ] + # the spec name is not the plugin name. + # to override the plugin name, use `pname` + # You could run something before your main init.lua like this + # before = [ "INIT_MAIN" ]; + # You can include configuration and translated nix values here as well! + # type = "lua"; # | "fnl" | "vim" + # info = { }; + # config = '' + # local info, pname, lazy = ... + # ''; + } + ]; + + # you can name these whatever you want. + config.specs.nix = { + lazy = true; + data = null; + extraPackages = with pkgs; [ + nixd + nixfmt + ]; + }; + config.specs.lua = { + after = [ "general" ]; + lazy = true; + data = with pkgs.vimPlugins; [ + lazydev-nvim + ]; + extraPackages = with pkgs; [ + lua-language-server + stylua + ]; + }; + config.specs.bash = { + lazy = true; + enable = false; + data = null; + extraPackages = with pkgs; [ + bash-language-server + ]; + }; + config.specs.C = { + lazy = true; + data = null; + extraPackages = with pkgs; [ + clang-tools + ]; + }; + config.specs.rust = { + # enable = false; + lazy = true; + data = null; + extraPackages = with pkgs; [ + rust-analyzer + rustfmt + ]; + }; + config.specs.zig = { + enable = false; + lazy = true; + data = null; + extraPackages = with pkgs; [ + zls + ]; + }; + + config.specs.general = { + # this would ensure any config included from nix in here will be ran after any provided by the `lze` spec + # If we provided any from within either spec, anyway + after = [ "lze" ]; + # note we didn't have to specify the `lze` specs name, because it was a top level spec + extraPackages = with pkgs; [ + wl-clipboard + xclip + xsel + tree-sitter + ]; + # this `lazy = true` definition will transfer to specs in the contained DAL, if there is one. + # This is because the definition of lazy in `config.specMods` checks `parentSpec.lazy or false` + # the submodule type for `config.specMods` gets `parentSpec` as a `specialArg`. + # you can define options like this too! + lazy = true; + # here we chose a DAL of plugins, but we can also pass a single plugin, or null + # plugins are of type wlib.types.stringable + data = with pkgs.vimPlugins; [ + vim-sleuth + config.nvim-lib.neovimPlugins.base46 + nvim-lspconfig + oil-nvim + vim-startuptime + blink-cmp + colorful-menu-nvim + luasnip + lualine-nvim + nvim-lint + conform-nvim + nvim-treesitter-textobjects + mini-pick + mini-diff + mini-surround + mini-indentscope + nvim-ts-autotag + vim-fugitive + vim-rhubarb + diffview-nvim + (nvim-treesitter.withPlugins ( + plugins: with plugins; [ + nix + lua + c + cpp + rust + zig + ] + )) + ]; + }; + + # These are from the tips and tricks section of the neovim wrapper docs! + # https://birdeehub.github.io/nix-wrapper-modules/neovim.html#tips-and-tricks + # We could put these in another module and import them here instead! + + # This submodule modifies both levels of your specs + config.specMods = + { + # When this module is ran in an inner list, + # this will contain `config` of the parent spec + parentSpec ? null, + # and this will contain `options` + # otherwise they will be `null` + parentOpts ? null, + parentName ? null, + # and then config from this one, as normal + config, + # and the other module arguments. + ... + }: + { + # you could use this to change defaults for the specs + # config.collateGrammars = lib.mkDefault (parentSpec.collateGrammars or false); + # config.autoconfig = lib.mkDefault (parentSpec.autoconfig or false); + # config.runtimeDeps = lib.mkDefault (parentSpec.runtimeDeps or false); + # config.pluginDeps = lib.mkDefault (parentSpec.pluginDeps or false); + # or something more interesting like: + # add an extraPackages field to the specs themselves + options.extraPackages = lib.mkOption { + type = lib.types.listOf wlib.types.stringable; + default = [ ]; + description = "a extraPackages spec field to put packages to suffix to the PATH"; + }; + # You could do this too + # config.before = lib.mkDefault [ "INIT_MAIN" ]; + }; + config.extraPackages = config.specCollect (acc: v: acc ++ (v.extraPackages or [ ])) [ ]; + + # Inform our lua of which top level specs are enabled + options.settings.cats = lib.mkOption { + readOnly = true; + type = lib.types.attrsOf lib.types.bool; + default = builtins.mapAttrs (_: v: v.enable) config.specs; + }; + # build plugins from inputs set + options.nvim-lib.pluginsFromPrefix = lib.mkOption { + type = lib.types.raw; + readOnly = true; + default = + prefix: inputs: + lib.pipe inputs [ + builtins.attrNames + (builtins.filter (s: lib.hasPrefix prefix s)) + (map ( + input: + let + name = lib.removePrefix prefix input; + in + { + inherit name; + value = config.nvim-lib.mkPlugin name inputs.${input}; + } + )) + builtins.listToAttrs + ]; + }; +} -- cgit v1.3.1