add flake compat

This commit is contained in:
Dmitriy Pleshevskiy 2022-11-30 22:49:32 +03:00
parent 005ddc0b9e
commit 437e0e05cf
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
4 changed files with 86 additions and 78 deletions

View file

@ -1,76 +1,3 @@
{ enableDevIcons ? false (import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") {
, enableBarBar ? false src = builtins.fetchGit ./.;
, enableTabby ? false }).defaultNix
, enableOrgMode ? false
, viAlias ? false
, vimAlias ? false
, grammarFileTypes ? [ "nix" ]
, theme ? { }
, plugins ? { }
, wrapNeovim
, neovim-unwrapped
, tree-sitter
, neovimPlugins
, lib
, nix2lua
, substituteAll
, ...
}:
let
inherit (builtins) catAttrs isFunction readFile;
myLib = import ./lib.nix { inherit lib; } // {
inherit substituteAll;
inherit (nix2lua.lib) toLua;
};
pluginParams = neovimPlugins // {
inherit plugins;
inherit tree-sitter grammarFileTypes;
inherit enableDevIcons enableTabby enableOrgMode;
themeCfg = theme;
lib = myLib;
};
callPlugin = op:
if isFunction op then op pluginParams else import op pluginParams;
callPlugins = list: map callPlugin list;
pluginsSettings = callPlugins [
./plugins/config
./plugins/syntax
./plugins/git
./plugins/explorer
./plugins/theme
./plugins/lsp
./plugins/formatter
./plugins/ux
];
basePlugins = [ neovimPlugins.plenary-nvim ];
customPlugins = catAttrs "plugins" pluginsSettings;
allPlugins = basePlugins ++ customPlugins;
basicConfigs = map readFile [ ./config/basic.lua ];
pluginConfigs = catAttrs "luaConfig" pluginsSettings;
allConfigs = basicConfigs ++ pluginConfigs;
in
(wrapNeovim neovim-unwrapped {
inherit viAlias;
inherit vimAlias;
withPython3 = false;
withNodeJs = false;
withRuby = false;
configure = {
customRC = myLib.mkLuaRc allConfigs;
packages.myVimPackages = { start = allPlugins; };
};
}).overrideAttrs (oldAttrs: {
passthru = oldAttrs.passthru // {
nix2lua = nix2lua.lib;
inherit plugins;
};
})

View file

@ -212,11 +212,13 @@
inherit neovimPlugins; inherit neovimPlugins;
inherit nix2lua; inherit nix2lua;
}; };
mkNeovim = pkgs: pkgs.callPackage ./neovim.nix (mkNvimPlugins pkgs);
in in
{ {
overlays = { overlays = {
default = final: prev: { default = final: prev: {
myneovim = prev.callPackage self (mkNvimPlugins prev); myneovim = mkNeovim prev;
}; };
}; };
} // } //
@ -225,7 +227,7 @@
inherit (builtins) mapAttrs; inherit (builtins) mapAttrs;
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
minimalNeovim = pkgs.callPackage self (mkNvimPlugins pkgs); minimalNeovim = mkNeovim pkgs;
recommendedNeovim = (minimalNeovim.override { recommendedNeovim = (minimalNeovim.override {
enableDevIcons = true; enableDevIcons = true;

76
neovim.nix Normal file
View file

@ -0,0 +1,76 @@
{ enableDevIcons ? false
, enableBarBar ? false
, enableTabby ? false
, enableOrgMode ? false
, viAlias ? false
, vimAlias ? false
, grammarFileTypes ? [ "nix" ]
, theme ? { }
, plugins ? { }
, wrapNeovim
, neovim-unwrapped
, tree-sitter
, neovimPlugins
, lib
, nix2lua
, substituteAll
, ...
}:
let
inherit (builtins) catAttrs isFunction readFile;
myLib = import ./lib.nix { inherit lib; } // {
inherit substituteAll;
inherit (nix2lua.lib) toLua;
};
pluginParams = neovimPlugins // {
inherit plugins;
inherit tree-sitter grammarFileTypes;
inherit enableDevIcons enableTabby enableOrgMode;
themeCfg = theme;
lib = myLib;
};
callPlugin = op:
if isFunction op then op pluginParams else import op pluginParams;
callPlugins = list: map callPlugin list;
pluginsSettings = callPlugins [
./plugins/config
./plugins/syntax
./plugins/git
./plugins/explorer
./plugins/theme
./plugins/lsp
./plugins/formatter
./plugins/ux
];
basePlugins = [ neovimPlugins.plenary-nvim ];
customPlugins = catAttrs "plugins" pluginsSettings;
allPlugins = basePlugins ++ customPlugins;
basicConfigs = map readFile [ ./config/basic.lua ];
pluginConfigs = catAttrs "luaConfig" pluginsSettings;
allConfigs = basicConfigs ++ pluginConfigs;
in
(wrapNeovim neovim-unwrapped {
inherit viAlias;
inherit vimAlias;
withPython3 = false;
withNodeJs = false;
withRuby = false;
configure = {
customRC = myLib.mkLuaRc allConfigs;
packages.myVimPackages = { start = allPlugins; };
};
}).overrideAttrs (oldAttrs: {
passthru = oldAttrs.passthru // {
nix2lua = nix2lua.lib;
inherit plugins;
};
})

3
shell.nix Normal file
View file

@ -0,0 +1,3 @@
(import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") {
src = builtins.fetchGit ./.;
}).shellNix