Skip to content

Commit

Permalink
flake: vim plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Colton J. McCurdy <mccurdyc22@gmail.com>
  • Loading branch information
mccurdyc committed Sep 13, 2022
1 parent a7b4736 commit 98bfdc1
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 35 deletions.
29 changes: 23 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions flake.nix
@@ -1,4 +1,7 @@
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references
{
# inputs: An attrset specifying the dependencies of the flake (described below).
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-inputs
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-22.05";
# We use the unstable nixpkgs repo for some packages.
Expand All @@ -9,21 +12,47 @@
# We want home-manager to use the same set of nixpkgs as our system.
inputs.nixpkgs.follows = "nixpkgs";
};

base16-vim-mccurdyc = {
url = "github:mccurdyc/base16-vim";
flake = false;
};
};

# outputs: A function that, given an attribute set containing the outputs of each
# of the input flakes keyed by their identifier, yields the Nix values provided
# by this flake. Thus, in the example above, inputs.nixpkgs contains the result
# of the call to the outputs function of the nixpkgs flake
#
# The value returned by the outputs function must be an attribute set.
# The attributes can have arbitrary values; however, various nix subcommands
# require specific attributes to have a specific value (e.g. packages.x86_64-linux
# must be an attribute set of derivations built for the x86_64-linux platform).
#
# Each input is fetched, evaluated and passed to the outputs function as a set
# of attributes with the same name as the corresponding input.
#
# The special input named self refers to the outputs and source tree of this flake.
outputs = {
self,
nixpkgs,
home-manager,
...
# https://nixos.org/manual/nix/stable/language/constructs.html#functions
# An @-pattern provides a means of referring to the whole value being matched
} @ inputs: let
system = "x86_64-linux"; #current system
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
lib = nixpkgs.lib;

vimPlugins = {
inherit (inputs) base16-vim-mccurdyc;
};

mkSystem = pkgs: system: hostname:
pkgs.lib.nixosSystem {
system = system;
# replaces the older configuration.nix
modules = [
{networking.hostName = hostname;}
# General configuration (users, networking, sound, etc)
Expand All @@ -39,13 +68,16 @@
users.mccurdyc = ./. + "/hosts/${hostname}/user.nix";
};
}
{
nixpkgs.overlays = [
(import ./overlays/vim-plugins.nix nixpkgs vimPlugins system)
];
}
];
specialArgs = {inherit inputs;};
};
in {
nixosConfigurations = {
# Now, defining a new system is can be done in one line
# Architecture Hostname
nuc = mkSystem inputs.nixpkgs "x86_64-linux" "nuc";
};
};
Expand Down
60 changes: 33 additions & 27 deletions modules/nvim/default.nix
Expand Up @@ -16,94 +16,100 @@ in {
luafile ${config.xdg.configHome}/nvim/main.lua
'';
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; [
vim-surround
vim-unimpaired
tcomment_vim
plenary-nvim
telescope-fzf-native-nvim
telescope-dap-nvim
vim-fugitive
vim-gh-line
vim-go
rust-vim
nvim-dap-ui
nvim-web-devicons
coq_nvim
plugins = with pkgs; [
vimPlugins.vim-surround

This comment has been minimized.

Copy link
@mccurdyc

mccurdyc Sep 13, 2022

Author Owner

remove this vimPlugins

vimPlugins.vim-unimpaired
vimPlugins.tcomment_vim
vimPlugins.plenary-nvim
vimPlugins.telescope-fzf-native-nvim
vimPlugins.telescope-dap-nvim
vimPlugins.vim-fugitive
vimPlugins.vim-gh-line
vimPlugins.vim-go
vimPlugins.rust-vim
vimPlugins.nvim-dap-ui
vimPlugins.nvim-web-devicons
vimPlugins.coq_nvim
{
plugin = nvim-bqf;
plugin = vimPlugins.base16-vim-mccurdyc;
config = ''
colorscheme base16-eighties-minimal
'';
}
{
plugin = vimPlugins.nvim-bqf;
config = ''
luafile ${config.xdg.configHome}/nvim/config/quickfix.lua
'';
}
{
plugin = formatter-nvim;
plugin = vimPlugins.formatter-nvim;
config = ''
luafile ${config.xdg.configHome}/nvim/config/formatter.lua
'';
}
{
plugin = telescope-nvim;
plugin = vimPlugins.telescope-nvim;
config = ''
luafile ${config.xdg.configHome}/nvim/config/telescope.lua
'';
}
{
plugin = nvim-tree-lua;
plugin = vimPlugins.nvim-tree-lua;
config = ''
luafile ${config.xdg.configHome}/nvim/config/nvim-tree.lua
'';
}
{
plugin = nvim-lspconfig;
plugin = vimPlugins.nvim-lspconfig;
config = ''
luafile ${config.xdg.configHome}/nvim/config/lsp.lua
'';
}
{
plugin = nvim-ale-diagnostic;
plugin = vimPlugins.nvim-ale-diagnostic;
config = ''
luafile ${config.xdg.configHome}/nvim/config/ale.lua
'';
}
{
plugin = gitsigns-nvim;
plugin = vimPlugins.gitsigns-nvim;
config = ''
luafile ${config.xdg.configHome}/nvim/config/gitsigns.lua
'';
}
{
plugin = neogit;
plugin = vimPlugins.neogit;
config = ''
luafile ${config.xdg.configHome}/nvim/config/neogit.lua
'';
}
{
plugin = vim-terraform;
plugin = vimPlugins.vim-terraform;
config = ''
luafile ${config.xdg.configHome}/nvim/config/terraform.lua
'';
}
{
plugin = nvim-treesitter;
plugin = vimPlugins.nvim-treesitter;
config = ''
luafile ${config.xdg.configHome}/nvim/config/treesitter.lua
'';
}
{
plugin = nvim-ts-rainbow;
plugin = vimPlugins.nvim-ts-rainbow;
config = ''
luafile ${config.xdg.configHome}/nvim/config/rainbow.lua
'';
}
{
plugin = nvim-dap;
plugin = vimPlugins.nvim-dap;
config = ''
luafile ${config.xdg.configHome}/nvim/config/dap.lua
'';
}
{
plugin = lualine-nvim;
plugin = vimPlugins.lualine-nvim;
config = ''
luafile ${config.xdg.configHome}/nvim/config/statusline.lua
'';
Expand Down
19 changes: 19 additions & 0 deletions overlays/vim-plugins.nix
@@ -0,0 +1,19 @@
nixpkgs: plugins: system: final: prev: let

This comment has been minimized.

Copy link
@mccurdyc

mccurdyc Sep 13, 2022

Author Owner

this is an anon function that takes one arg, which returns another funtion that takes one args, and another ....

This is a functional programming concept known as currying.

https://en.wikipedia.org/wiki/Partial_application

This comment has been minimized.

Copy link
@mccurdyc

mccurdyc Sep 13, 2022

Author Owner

or think of this as a function with three args (nixpkgs, plugins, system) that returns a function that takes args (final prev) the interface for an overlay that gets evaluated in the nixosSystem thingy in the flake.

buildVimPlugins = nikpks: system: plugins: let
buildVimPlugin = system: plugin: let
inherit (nixpkgs.legacyPackages.${system}) vimUtils;
in
vimUtils.buildVimPluginFrom2Nix plugin;
in
builtins.mapAttrs
(pluginName: plugin:
buildVimPlugin system {
pname = pluginName;
version = plugin.rev or "dirty";
src = plugin;
})
plugins;
vimPlugins = buildVimPlugins nixpkgs system plugins;
in {
vimPlugins = prev.vimPlugins // vimPlugins;
}

0 comments on commit 98bfdc1

Please sign in to comment.