viminal2/flake.nix

404 lines
13 KiB
Nix
Raw Normal View History

2024-10-09 17:13:16 -07:00
# Copyright (c) 2023 BirdeeHub
# Licensed under the MIT license
# This is an empty nixCats config.
# you may import this template directly into your nvim folder
# and then add plugins to categories here,
# and call the plugins with their default functions
# within your lua, rather than through the nvim package manager's method.
# Use the help, and the example repository https://github.com/BirdeeHub/nixCats-nvim
# It allows for easy adoption of nix,
# while still providing all the extra nix features immediately.
# Configure in lua, check for a few categories, set a few settings,
# output packages with combinations of those categories and settings.
# All the same options you make here will be automatically exported in a form available
# in home manager and in nixosModules, as well as from other flakes.
# each section is tagged with its relevant help section.
{
description = "A Lua-natic's neovim flake, with extra cats! nixCats!";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixCats.url = "github:BirdeeHub/nixCats-nvim?dir=nix";
blink-cmp = {
url = "github:Saghen/blink.cmp";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-10-10 00:21:39 -07:00
plugins-typst-preview = {
url = "github:chomosuke/typst-preview.nvim";
flake = false;
};
plugins-lsp-progress = {
url = "github:linrongbin16/lsp-progress.nvim";
flake = false;
};
2024-10-09 17:13:16 -07:00
# see :help nixCats.flake.inputs
# If you want your plugin to be loaded by the standard overlay,
# i.e. if it wasnt on nixpkgs, but doesnt have an extra build step.
# Then you should name it "plugins-something"
# If you wish to define a custom build step not handled by nixpkgs,
# then you should name it in a different format, and deal with that in the
# overlay defined for custom builds in the overlays directory.
# for specific tags, branches and commits, see:
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#examples
};
# see :help nixCats.flake.outputs
outputs =
{
self,
nixpkgs,
nixCats,
...
}@inputs:
let
inherit (nixCats) utils;
luaPath = "${./.}";
forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all;
# the following extra_pkg_config contains any values
# which you want to pass to the config set of nixpkgs
# import nixpkgs { config = extra_pkg_config; inherit system; }
# will not apply to module imports
# as that will have your system values
extra_pkg_config = {
# allowUnfree = true;
};
# sometimes our overlays require a ${system} to access the overlay.
# management of this variable is one of the harder parts of using flakes.
# so I have done it here in an interesting way to keep it out of the way.
# First, we will define just our overlays per system.
# later we will pass them into the builder, and the resulting pkgs set
# will get passed to the categoryDefinitions and packageDefinitions
# which follow this section.
# this allows you to use ${pkgs.system} whenever you want in those sections
# without fear.
inherit
(forEachSystem (
system:
let
# see :help nixCats.flake.outputs.overlays
dependencyOverlays = # (import ./overlays inputs) ++
[
# This overlay grabs all the inputs named in the format
# `plugins-<pluginName>`
# Once we add this overlay to our nixpkgs, we are able to
# use `pkgs.neovimPlugins`, which is a set of our plugins.
(utils.standardPluginOverlay inputs)
# add any flake overlays here.
];
in
# these overlays will be wrapped with ${system}
# and we will call the same utils.eachSystem function
# later on to access them.
{
inherit dependencyOverlays;
}
))
dependencyOverlays
;
# see :help nixCats.flake.outputs.categories
# and
# :help nixCats.flake.outputs.categoryDefinitions.scheme
categoryDefinitions =
{
pkgs,
settings,
categories,
name,
...
}@packageDef:
{
# to define and use a new category, simply add a new list to a set here,
# and later, you will include categoryname = true; in the set you
# provide when you build the package using this builder function.
# see :help nixCats.flake.outputs.packageDefinitions for info on that section.
# propagatedBuildInputs:
# this section is for dependencies that should be available
# at BUILD TIME for plugins. WILL NOT be available to PATH
# However, they WILL be available to the shell
# and neovim path when using nix develop
propagatedBuildInputs = {
general =
with pkgs;
[
];
};
# lspsAndRuntimeDeps:
# this section is for dependencies that should be available
# at RUN TIME for plugins. Will be available to PATH within neovim terminal
# this includes LSPs
lspsAndRuntimeDeps = {
general = with pkgs; [
2024-10-10 00:21:39 -07:00
# essential
2024-10-09 17:13:16 -07:00
ripgrep
python312Packages.pylatexenc
2024-10-10 00:21:39 -07:00
fd
# lsps / formatters
lua-language-server
nixd
nixfmt-rfc-style
2024-10-10 00:49:25 -07:00
nodePackages_latest.prettier
taplo
typstyle
rustfmt
black
stylua
2024-10-09 17:13:16 -07:00
];
};
2024-10-10 00:21:39 -07:00
# install lz.n and treesitter grammars
2024-10-09 17:13:16 -07:00
startupPlugins = {
gitPlugins = with pkgs.neovimPlugins; [ ];
general = with pkgs.vimPlugins; [
lz-n
(nvim-treesitter.withPlugins (
p:
(with p; [
lua
c
javascript
typescript
rust
haskell
typst
latex
nix
json
toml
yaml
markdown
2024-10-10 00:21:39 -07:00
markdown_inline
2024-10-09 17:13:16 -07:00
svelte
css
html
vim
bash
make
2024-10-10 00:49:25 -07:00
gitcommit
2024-10-09 17:13:16 -07:00
])
))
];
};
2024-10-10 00:21:39 -07:00
# plugins which are installed, but not loaded, and will be handled by
# lz.n (not necessarily lazy loaded)
2024-10-09 17:13:16 -07:00
optionalPlugins = {
gitPlugins = with pkgs.neovimPlugins; [
inputs.blink-cmp.packages.${pkgs.system}.default
2024-10-10 00:21:39 -07:00
typst-preview
lsp-progress
2024-10-09 17:13:16 -07:00
];
general = with pkgs.vimPlugins; [
nvim-autopairs
nvim-lspconfig
intellitab-nvim
sleuth
2024-10-10 00:21:39 -07:00
which-key-nvim
telescope-nvim
markdown-preview-nvim
render-markdown-nvim
rose-pine
nvim-web-devicons
oil-nvim
telescope-ui-select-nvim
harpoon2
toggleterm-nvim
trouble-nvim
lualine-nvim
mini-ai
2024-10-10 00:49:25 -07:00
mini-hipatterns
2024-10-10 00:21:39 -07:00
mini-surround
mini-notify
mini-starter
mini-trailspace
cellular-automaton-nvim
indent-blankline-nvim
mini-bufremove
neogit
gitsigns-nvim
diffview-nvim
barbecue-nvim
2024-10-10 00:49:25 -07:00
undotree
conform-nvim
2024-10-09 17:13:16 -07:00
];
};
# shared libraries to be added to LD_LIBRARY_PATH
# variable available to nvim runtime
sharedLibraries = {
general = with pkgs; [
# libgit2
];
};
# environmentVariables:
# this section is for environmentVariables that should be available
# at RUN TIME for plugins. Will be available to path within neovim terminal
# environmentVariables = {
# test = {
# CATTESTVAR = "It worked!";
# };
# };
# If you know what these are, you can provide custom ones by category here.
# If you dont, check this link out:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh
# extraWrapperArgs = {
# test = [
# ''--set CATTESTVAR2 "It worked again!"''
# ];
# };
# lists of the functions you would have passed to
# python.withPackages or lua.withPackages
# get the path to this python environment
# in your lua config via
# vim.g.python3_host_prog
# or run from nvim terminal via :!<packagename>-python3
2024-10-10 00:21:39 -07:00
# extraPython3Packages = {
# test = (_: [ ]);
# };
# # populates $LUA_PATH and $LUA_CPATH
# extraLuaPackages = {
# test = [ (_: [ ]) ];
# };
2024-10-09 17:13:16 -07:00
};
# And then build a package with specific categories from above here:
# All categories you wish to include must be marked true,
# but false may be omitted.
# This entire set is also passed to nixCats for querying within the lua.
# see :help nixCats.flake.outputs.packageDefinitions
packageDefinitions = {
# These are the names of your packages
# you can include as many as you wish.
nvim =
{ pkgs, ... }:
{
# they contain a settings set defined above
# see :help nixCats.flake.outputs.settings
settings = {
wrapRc = true;
# IMPORTANT:
# your alias may not conflict with your other packages.
aliases = [
"vim"
"vi"
];
# neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim;
};
# and a set of categories that you want
# (and other information to pass to lua)
categories = {
general = true;
gitPlugins = true;
customPlugins = true;
2024-10-10 00:21:39 -07:00
bin = {
websocat = "${pkgs.websocat}/bin/websocat";
tinymist = "${pkgs.tinymist}/bin/tinymist";
2024-10-09 17:13:16 -07:00
};
};
};
};
# In this section, the main thing you will need to do is change the default package name
# to the name of the packageDefinitions entry you wish to use as the default.
defaultPackageName = "nvim";
in
# see :help nixCats.flake.outputs.exports
forEachSystem (
system:
let
nixCatsBuilder = utils.baseBuilder luaPath {
inherit
nixpkgs
system
dependencyOverlays
extra_pkg_config
;
} categoryDefinitions packageDefinitions;
defaultPackage = nixCatsBuilder defaultPackageName;
# this is just for using utils such as pkgs.mkShell
# The one used to build neovim is resolved inside the builder
# and is passed to our categoryDefinitions and packageDefinitions
pkgs = import nixpkgs { inherit system; };
in
{
# these outputs will be wrapped with ${system} by utils.eachSystem
# this will make a package out of each of the packageDefinitions defined above
# and set the default package to the one passed in here.
packages = utils.mkAllWithDefault defaultPackage;
# choose your package for devShell
# and add whatever else you want in it.
devShells = {
default = pkgs.mkShell {
name = defaultPackageName;
packages = [ defaultPackage ];
inputsFrom = with pkgs; [
lua-language-server
stylua
];
shellHook = '''';
};
};
}
)
// {
# these outputs will be NOT wrapped with ${system}
# this will make an overlay out of each of the packageDefinitions defined above
# and set the default overlay to the one named here.
overlays = utils.makeOverlays luaPath {
inherit nixpkgs dependencyOverlays extra_pkg_config;
} categoryDefinitions packageDefinitions defaultPackageName;
# we also export a nixos module to allow reconfiguration from configuration.nix
nixosModules.default = utils.mkNixosModules {
inherit
defaultPackageName
dependencyOverlays
luaPath
categoryDefinitions
packageDefinitions
extra_pkg_config
nixpkgs
;
};
# and the same for home manager
homeModule = utils.mkHomeModules {
inherit
defaultPackageName
dependencyOverlays
luaPath
categoryDefinitions
packageDefinitions
extra_pkg_config
nixpkgs
;
};
inherit utils;
inherit (utils) templates;
};
}