nix: move all plugins to flake

This commit is contained in:
Dmitriy Pleshevskiy 2022-09-24 17:21:16 +03:00
parent afa9f5caf9
commit 38cf6958e8
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
7 changed files with 460 additions and 49 deletions

View file

@ -3,8 +3,10 @@
, enableTabby ? false
, viAlias ? false
, vimAlias ? false
, theme ? { }
, wrapNeovim
, neovim-unwrapped
, tree-sitter
, vimPlugins
, ...
}:
@ -19,17 +21,24 @@ let
plugins = callPlugins [
./plugins/config
./plugins/syntax
(import ./plugins/syntax {
inherit tree-sitter;
})
./plugins/git
./plugins/explorer
(import ./plugins/theme {
inherit enableDevIcons enableBarBar enableTabby;
inherit enableDevIcons enableTabby;
inherit theme;
})
./plugins/lsp
./plugins/formatter
./plugins/ux
];
basePlugins = [ vimPlugins.plenary-nvim ];
customPlugins = builtins.catAttrs "plugins" plugins;
allPlugins = basePlugins ++ customPlugins;
basicConfigs = builtins.map builtins.readFile [ ./config/basic.lua ];
pluginConfigs = builtins.catAttrs "luaConfig" plugins;
allConfigs = basicConfigs ++ pluginConfigs;
@ -45,6 +54,6 @@ wrapNeovim neovim-unwrapped {
configure = {
customRC = lib.mkLuaRc allConfigs;
packages.myVimPackages = { start = builtins.catAttrs "plugins" plugins; };
packages.myVimPackages = { start = allPlugins; };
};
}

View file

@ -1,5 +1,39 @@
{
"nodes": {
"cmp-luasnip": {
"flake": false,
"locked": {
"lastModified": 1651433493,
"narHash": "sha256-8ocJY5qeAJXFSuTnavXX6NvZyAB0EEn2Y+amrWp8B1Y=",
"owner": "saadparwaiz1",
"repo": "cmp_luasnip",
"rev": "a9de941bcbda508d0a45d28ae366bb3f08db2e36",
"type": "github"
},
"original": {
"owner": "saadparwaiz1",
"repo": "cmp_luasnip",
"rev": "a9de941bcbda508d0a45d28ae366bb3f08db2e36",
"type": "github"
}
},
"cmp-nvim-lsp": {
"flake": false,
"locked": {
"lastModified": 1652705110,
"narHash": "sha256-19Ka4EQhqo//IMjJ/DnXiHsevVWFy2M90oSjmBFfCO0=",
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"rev": "affe808a5c56b71630f17aa7c38e15c59fd648a8",
"type": "github"
},
"original": {
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"rev": "affe808a5c56b71630f17aa7c38e15c59fd648a8",
"type": "github"
}
},
"editorconfig-nvim": {
"flake": false,
"locked": {
@ -17,6 +51,23 @@
"type": "github"
}
},
"gitsigns-nvim": {
"flake": false,
"locked": {
"lastModified": 1663543397,
"narHash": "sha256-FgNSwvW7Bk+eKutMj0zqEorJ3+ijCALtOXs2OYiSX1I=",
"owner": "lewis6991",
"repo": "gitsigns.nvim",
"rev": "f98c85e7c3d65a51f45863a34feb4849c82f240f",
"type": "github"
},
"original": {
"owner": "lewis6991",
"repo": "gitsigns.nvim",
"rev": "f98c85e7c3d65a51f45863a34feb4849c82f240f",
"type": "github"
}
},
"lspsaga-nvim": {
"flake": false,
"locked": {
@ -34,6 +85,74 @@
"type": "github"
}
},
"lualine-lsp-progress": {
"flake": false,
"locked": {
"lastModified": 1634947677,
"narHash": "sha256-8HMtydFDzTxsuKvce+bIra9vZ9zHfEBHyR346W635b8=",
"owner": "arkav",
"repo": "lualine-lsp-progress",
"rev": "56842d097245a08d77912edf5f2a69ba29f275d7",
"type": "github"
},
"original": {
"owner": "arkav",
"repo": "lualine-lsp-progress",
"rev": "56842d097245a08d77912edf5f2a69ba29f275d7",
"type": "github"
}
},
"lualine-nvim": {
"flake": false,
"locked": {
"lastModified": 1662921346,
"narHash": "sha256-bGVozEoffFxjiLACTfnDGX11yIHGhLawQWn80Nbd6TM=",
"owner": "nvim-lualine",
"repo": "lualine.nvim",
"rev": "a52f078026b27694d2290e34efa61a6e4a690621",
"type": "github"
},
"original": {
"owner": "nvim-lualine",
"repo": "lualine.nvim",
"rev": "a52f078026b27694d2290e34efa61a6e4a690621",
"type": "github"
}
},
"luaship": {
"flake": false,
"locked": {
"lastModified": 1663664003,
"narHash": "sha256-56x4Eke/7Cdn4/8T0SM73WpDqBSFq1vFY5VdkNlUBwI=",
"owner": "L3MON4D3",
"repo": "LuaSnip",
"rev": "d36c063b7f6e701852f7880f1314656592a61b4f",
"type": "github"
},
"original": {
"owner": "L3MON4D3",
"repo": "LuaSnip",
"rev": "d36c063b7f6e701852f7880f1314656592a61b4f",
"type": "github"
}
},
"neoformat": {
"flake": false,
"locked": {
"lastModified": 1661997045,
"narHash": "sha256-x+TDVvH0DgmCCjOjhbE2/YaxnjCd4fcPxuQD6bhwVNs=",
"owner": "sbdchd",
"repo": "neoformat",
"rev": "0ae951121da29a157d80db70c32679b428afffdc",
"type": "github"
},
"original": {
"owner": "sbdchd",
"repo": "neoformat",
"rev": "0ae951121da29a157d80db70c32679b428afffdc",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1663146586,
@ -50,6 +169,40 @@
"type": "github"
}
},
"nvim-cmp": {
"flake": false,
"locked": {
"lastModified": 1663990701,
"narHash": "sha256-gpkPMlOUMfTlef5WRFHLkmKEDZ9TRA/yRPqb6UXnKOA=",
"owner": "hrsh7th",
"repo": "nvim-cmp",
"rev": "17a55b3d5498c617855d015bbcad0c872d10c879",
"type": "github"
},
"original": {
"owner": "hrsh7th",
"repo": "nvim-cmp",
"rev": "17a55b3d5498c617855d015bbcad0c872d10c879",
"type": "github"
}
},
"nvim-lspconfig": {
"flake": false,
"locked": {
"lastModified": 1663921594,
"narHash": "sha256-uCFhwcR4oW+4wrSt6rx5G8k75dOLeqmYzW1G1CYlLkM=",
"owner": "neovim",
"repo": "nvim-lspconfig",
"rev": "d4eb971db353ccf78cefb3be1b05483b69ec1e69",
"type": "github"
},
"original": {
"owner": "neovim",
"repo": "nvim-lspconfig",
"rev": "d4eb971db353ccf78cefb3be1b05483b69ec1e69",
"type": "github"
}
},
"nvim-tree-lua": {
"flake": false,
"locked": {
@ -67,14 +220,78 @@
"type": "github"
}
},
"nvim-treesitter": {
"flake": false,
"locked": {
"lastModified": 1664008557,
"narHash": "sha256-hZqZkXrIw9OfXLqioSqagmEPoIz8gcT+WpEhVURdeHw=",
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"rev": "a60aa7b2e1dd9219c6356f65ba48bdbd50090abd",
"type": "github"
},
"original": {
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"rev": "a60aa7b2e1dd9219c6356f65ba48bdbd50090abd",
"type": "github"
}
},
"nvim-web-devicons": {
"flake": false,
"locked": {
"lastModified": 1663532214,
"narHash": "sha256-e8FP68mEmPAEbk+rYEKKGi0ZTJHDCPxrulnivkzInXk=",
"owner": "kyazdani42",
"repo": "nvim-web-devicons",
"rev": "969728506c0175644a1d448f55e311ccdada7eaf",
"type": "github"
},
"original": {
"owner": "kyazdani42",
"repo": "nvim-web-devicons",
"rev": "969728506c0175644a1d448f55e311ccdada7eaf",
"type": "github"
}
},
"plenary-nvim": {
"flake": false,
"locked": {
"lastModified": 1663402373,
"narHash": "sha256-d06QP5JGhpH6UUVF9STYzfJMzvg5HrJfDqlAoVXaLeM=",
"owner": "nvim-lua",
"repo": "plenary.nvim",
"rev": "62dc2a7acd2fb2581871a36c1743b29e26c60390",
"type": "github"
},
"original": {
"owner": "nvim-lua",
"repo": "plenary.nvim",
"type": "github"
}
},
"root": {
"inputs": {
"cmp-luasnip": "cmp-luasnip",
"cmp-nvim-lsp": "cmp-nvim-lsp",
"editorconfig-nvim": "editorconfig-nvim",
"gitsigns-nvim": "gitsigns-nvim",
"lspsaga-nvim": "lspsaga-nvim",
"lualine-lsp-progress": "lualine-lsp-progress",
"lualine-nvim": "lualine-nvim",
"luaship": "luaship",
"neoformat": "neoformat",
"nixpkgs": "nixpkgs",
"nvim-cmp": "nvim-cmp",
"nvim-lspconfig": "nvim-lspconfig",
"nvim-tree-lua": "nvim-tree-lua",
"nvim-treesitter": "nvim-treesitter",
"nvim-web-devicons": "nvim-web-devicons",
"plenary-nvim": "plenary-nvim",
"tabby-nvim": "tabby-nvim",
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",
"telescope-nvim": "telescope-nvim",
"theme": "theme",
"utils": "utils"
}
},
@ -112,6 +329,40 @@
"type": "github"
}
},
"telescope-nvim": {
"flake": false,
"locked": {
"lastModified": 1663402536,
"narHash": "sha256-hIOg0rFAek9p6/k2USBAPQwIoVdSJ+Tw6A0jrup9xto=",
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "30e2dc5232d0dd63709ef8b44a5d6184005e8602",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "30e2dc5232d0dd63709ef8b44a5d6184005e8602",
"type": "github"
}
},
"theme": {
"flake": false,
"locked": {
"lastModified": 1663990749,
"narHash": "sha256-EdmZ5qXY10jkYBgtd/qe23Ccl5qwFm3bwXNQIG8Qn5A=",
"owner": "catppuccin",
"repo": "nvim",
"rev": "9ac18414f0446478024b19018d73b7ea14f6fc96",
"type": "github"
},
"original": {
"owner": "catppuccin",
"repo": "nvim",
"rev": "9ac18414f0446478024b19018d73b7ea14f6fc96",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1659877975,

150
flake.nix
View file

@ -3,51 +3,175 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
nvim-tree-lua = {
url = "github:kyazdani42/nvim-tree.lua?rev=0417d9148b6546bf4883b6e9750f992f980afbfe";
# Plenary (required by crates-nvim)
plenary-nvim = {
url = "github:nvim-lua/plenary.nvim";
flake = false;
};
tabby-nvim = {
url = "github:nanozuki/tabby.nvim?rev=916c9e56d043906a441cd9f905e2ca1f5c4dddb0";
flake = false;
};
# config
# https://github.com/gpanders/editorconfig.nvim
editorconfig-nvim = {
url = "github:gpanders/editorconfig.nvim?rev=7d10fe6bc340fd783c0b61cf627dd235100284db";
flake = false;
};
# explorer
# https://github.com/kyazdani42/nvim-tree.lua
nvim-tree-lua = {
url = "github:kyazdani42/nvim-tree.lua?rev=0417d9148b6546bf4883b6e9750f992f980afbfe";
flake = false;
};
# https://github.com/nvim-telescope/telescope.nvim
telescope-nvim = {
url = "github:nvim-telescope/telescope.nvim?rev=30e2dc5232d0dd63709ef8b44a5d6184005e8602";
flake = false;
};
# https://github.com/nvim-telescope/telescope-live-grep-args.nvim
telescope-live-grep-args-nvim = {
url = "github:nvim-telescope/telescope-live-grep-args.nvim?rev=32b633b062d1168a2d18ad27994e5b4ef97f0a74";
flake = false;
};
# formatter
# https://github.com/sbdchd/neoformat
neoformat = {
url = "github:sbdchd/neoformat?rev=0ae951121da29a157d80db70c32679b428afffdc";
flake = false;
};
# git
# https://github.com/lewis6991/gitsigns.nvim
gitsigns-nvim = {
url = "github:lewis6991/gitsigns.nvim?rev=f98c85e7c3d65a51f45863a34feb4849c82f240f";
flake = false;
};
# lsp
# https://github.com/neovim/nvim-lspconfig
nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig?rev=d4eb971db353ccf78cefb3be1b05483b69ec1e69";
flake = false;
};
# https://github.com/glepnir/lspsaga.nvim
lspsaga-nvim = {
url = "github:glepnir/lspsaga.nvim?rev=c2ef0115fb917460daf5c76fe3ad3a9357213b54";
flake = false;
};
# https://github.com/L3MON4D3/LuaSnip
luaship = {
url = "github:L3MON4D3/LuaSnip?rev=d36c063b7f6e701852f7880f1314656592a61b4f";
flake = false;
};
# https://github.com/hrsh7th/nvim-cmp
nvim-cmp = {
url = "github:hrsh7th/nvim-cmp?rev=17a55b3d5498c617855d015bbcad0c872d10c879";
flake = false;
};
# https://github.com/hrsh7th/cmp-nvim-lsp
cmp-nvim-lsp = {
url = "github:hrsh7th/cmp-nvim-lsp?rev=affe808a5c56b71630f17aa7c38e15c59fd648a8";
flake = false;
};
# https://github.com/saadparwaiz1/cmp_luasnip
cmp-luasnip = {
url = "github:saadparwaiz1/cmp_luasnip?rev=a9de941bcbda508d0a45d28ae366bb3f08db2e36";
flake = false;
};
# syntax
# https://github.com/nvim-treesitter/nvim-treesitter
nvim-treesitter = {
url = "github:nvim-treesitter/nvim-treesitter?rev=a60aa7b2e1dd9219c6356f65ba48bdbd50090abd";
flake = false;
};
# theme
# https://github.com/nanozuki/tabby.nvim
tabby-nvim = {
url = "github:nanozuki/tabby.nvim?rev=916c9e56d043906a441cd9f905e2ca1f5c4dddb0";
flake = false;
};
# https://github.com/nvim-lualine/lualine.nvim
lualine-nvim = {
url = "github:nvim-lualine/lualine.nvim?rev=a52f078026b27694d2290e34efa61a6e4a690621";
flake = false;
};
# https://github.com/arkav/lualine-lsp-progress
lualine-lsp-progress = {
url = "github:/arkav/lualine-lsp-progress?rev=56842d097245a08d77912edf5f2a69ba29f275d7";
flake = false;
};
# https://github.com/kyazdani42/nvim-web-devicons
nvim-web-devicons = {
url = "github:kyazdani42/nvim-web-devicons?rev=969728506c0175644a1d448f55e311ccdada7eaf";
flake = false;
};
# https://github.com/catppuccin/nvim
theme = {
url = "github:catppuccin/nvim?rev=9ac18414f0446478024b19018d73b7ea14f6fc96";
flake = false;
};
};
outputs = inputs @ { self, nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
let
inputPlugins = [
"nvim-tree-lua"
"tabby-nvim"
"plenary-nvim"
# config
"editorconfig-nvim"
# explorer
"nvim-tree-lua"
"telescope-nvim"
"telescope-live-grep-args-nvim"
# formatter
"neoformat"
# git
"gitsigns-nvim"
# lsp
"nvim-lspconfig"
"lspsaga-nvim"
"luaship"
"nvim-cmp"
"cmp-nvim-lsp"
"cmp-luasnip"
# syntax
"nvim-treesitter"
# theme
"tabby-nvim"
"lualine-nvim"
"lualine-lsp-progress"
"nvim-web-devicons"
"theme"
];
pkgs = import nixpkgs {
inherit system;
overlays = [
(f: p:
(final: prev:
let
inherit (p.lib) listToAttrs nameValuePair;
inherit (prev.lib) listToAttrs nameValuePair;
buildPlugin = name: p.vimUtils.buildVimPluginFrom2Nix {
buildPlugin = name: prev.vimUtils.buildVimPluginFrom2Nix {
name = name;
src = builtins.getAttr name inputs;
};
@ -56,7 +180,9 @@
customPlugins = listToAttrs (builtins.map buildPluginValuePair inputPlugins);
in
{ vimPlugins = p.vimPlugins // customPlugins; }
{
vimPlugins = prev.vimPlugins // customPlugins;
}
)
];
};

23
lib.nix
View file

@ -1,15 +1,17 @@
rec {
#############################################################################
let
inherit (builtins) length elemAt isList isString hasAttr getAttr;
###########################################################################
# Helpers
# Source: https://github.com/NixOS/nixpkgs/blob/d61bc96d16ca288c69b798b8e31eca64050098e3/lib/lists.nix
foldr = op: nul: list:
let
len = builtins.length list;
len = length list;
fold' = n:
if n == len
then nul
else op (builtins.elemAt list n) (fold' (n + 1));
else op (elemAt list n) (fold' (n + 1));
in
fold' 0;
@ -25,12 +27,15 @@ rec {
optional = cond: val:
let
def =
if builtins.isList val then [ ]
else if builtins.isString val then ""
if isList val then [ ]
else if isString val then ""
else null;
in
if cond then val else def;
getAttrOpt = a: s:
if hasAttr a s then getAttr a s else null;
#############################################################################
# Lua
@ -41,4 +46,10 @@ rec {
'';
mkLuaRc = contents: concatMap mkLuaHeredoc contents;
in
{
inherit foldr concatMap;
inherit optional getAttrOpt;
inherit mkLuaHeredoc mkLuaRc;
}

View file

@ -1,21 +1,35 @@
{ tree-sitter, ... }:
{ nvim-treesitter, ... }:
let
treesitterGrammars = tree-sitter.withPlugins
(grammars: with grammars; [
tree-sitter-nix
tree-sitter-lua
tree-sitter-ledger
tree-sitter-yaml
tree-sitter-json
tree-sitter-typescript
tree-sitter-javascript
tree-sitter-rust
tree-sitter-haskell
tree-sitter-bash
]);
nvim-treesitter-with-grammars = nvim-treesitter.overrideAttrs (oldAttrs: {
postPatch = ''
rm -r parser
ln -s ${treesitterGrammars} parser
'';
});
in
{
luaConfig = builtins.readFile ./treesitter.lua;
plugins = [
(nvim-treesitter.withPlugins
(ts: with ts; [
tree-sitter-nix
tree-sitter-lua
tree-sitter-ledger
tree-sitter-yaml
tree-sitter-json
tree-sitter-typescript
tree-sitter-javascript
tree-sitter-rust
tree-sitter-haskell
tree-sitter-bash
]))
nvim-treesitter-with-grammars
];
}

View file

@ -1,5 +0,0 @@
vim.g.catppuccin_flavour = "frappe" -- latte, frappe, macchiato, mocha
require("catppuccin").setup()
vim.cmd([[colorscheme catppuccin]])

View file

@ -1,31 +1,36 @@
{ enableDevIcons ? false
, enableBarBar ? false
, enableTabby ? false
, theme ? { }
}:
{ lib
, catppuccin-nvim
, theme
, lualine-nvim
, lualine-lsp-progress
, nvim-web-devicons
, barbar-nvim
, tabby-nvim
, ...
}:
let
lualinePlugins = [ lualine-nvim lualine-lsp-progress ];
inherit (builtins) readFile isString;
themeFlavour = if isString (lib.getAttrOpt "flavour" theme) then theme.flavour else "frappe";
themeConfig = if isString (lib.getAttrOpt "config" theme) then theme.config else ''
vim.g.catppuccin_flavour = "${themeFlavour}"
require("catppuccin").setup()
vim.cmd([[colorscheme catppuccin]])
'';
lualinePlugins = [ lualine-nvim lualine-lsp-progress ];
in
{
luaConfig = (builtins.readFile ./catppuccin-nvim.lua)
+ (builtins.readFile ./lualine.lua)
+ (lib.optional enableBarBar (builtins.readFile ./barbar.lua))
+ (lib.optional enableTabby (builtins.readFile ./tabby-nvim.lua));
luaConfig = themeConfig
+ (readFile ./lualine.lua)
+ (lib.optional enableTabby (readFile ./tabby-nvim.lua));
plugins = [ catppuccin-nvim ]
plugins = [ theme ]
++ lualinePlugins
++ (lib.optional enableDevIcons [ nvim-web-devicons ])
++ (lib.optional enableBarBar [ barbar-nvim ])
++ (lib.optional enableTabby [ tabby-nvim ]);
}