mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-08 09:09:49 +01:00
test
This commit is contained in:
parent
5c69fbd951
commit
73a9cb9473
5 changed files with 151 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
# Home Manager module
|
# Home Manager module
|
||||||
packages: lib: {
|
packages: lib: inputs: {
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
|
@ -8,15 +8,26 @@ packages: lib: {
|
||||||
inherit (lib.modules) mkIf mkAliasOptionModule;
|
inherit (lib.modules) mkIf mkAliasOptionModule;
|
||||||
inherit (lib.lists) optional;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) attrsOf anything bool;
|
inherit (lib.types) attrsOf anything bool submoduleWith;
|
||||||
inherit (lib.nvim) neovimConfiguration;
|
inherit (lib.nvim) neovimConfiguration;
|
||||||
inherit (lib.nvim.types) anythingConcatLists;
|
inherit (lib.nvim.types) anythingConcatLists;
|
||||||
|
|
||||||
cfg = config.programs.nvf;
|
cfg = config.programs.nvf;
|
||||||
|
|
||||||
neovimConfigured = neovimConfiguration {
|
# neovimConfigured = neovimConfiguration {
|
||||||
inherit pkgs;
|
# inherit pkgs;
|
||||||
modules = [cfg.settings];
|
# modules = [cfg.settings];
|
||||||
|
# };
|
||||||
|
|
||||||
|
nvfModule = submoduleWith {
|
||||||
|
description = "Nvf module";
|
||||||
|
class = "nvf";
|
||||||
|
specialArgs = {
|
||||||
|
inherit pkgs lib inputs;
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
{imports = import ../../modules/modules.nix {inherit pkgs lib;};}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -55,7 +66,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = attrsOf anythingConcatLists;
|
type = nvfModule;
|
||||||
default = {};
|
default = {};
|
||||||
description = "Attribute set of nvf preferences.";
|
description = "Attribute set of nvf preferences.";
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
|
@ -78,7 +89,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.nvf.finalPackage = neovimConfigured.neovim;
|
programs.nvf.finalPackage = config.programs.nvf.settings.vim.build.finalPackage;
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
|
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
|
||||||
|
|
12
modules/build/build.nix
Normal file
12
modules/build/build.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib.types) package;
|
||||||
|
inherit (lib.options) mkOption;
|
||||||
|
in {
|
||||||
|
options.vim.build = {
|
||||||
|
finalPackage = mkOption {
|
||||||
|
type = package;
|
||||||
|
readOnly = true;
|
||||||
|
description = "final output package";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
116
modules/build/config.nix
Normal file
116
modules/build/config.nix
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}
|
||||||
|
: let
|
||||||
|
inherit (pkgs) vimPlugins;
|
||||||
|
inherit (lib.strings) isString toString;
|
||||||
|
inherit (lib.lists) filter map concatLists;
|
||||||
|
|
||||||
|
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
||||||
|
# check can be disabled while calling this file is called
|
||||||
|
# to avoid checking in all modules
|
||||||
|
nvimModules = import ./modules.nix {inherit pkgs lib;};
|
||||||
|
|
||||||
|
# alias to the internal configuration
|
||||||
|
vimOptions = config.vim;
|
||||||
|
|
||||||
|
noBuildPlug = {pname, ...} @ attrs: let
|
||||||
|
src = inputs."plugin-${attrs.pname}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
version = src.shortRev or src.shortDirtyRev or "dirty";
|
||||||
|
outPath = src;
|
||||||
|
passthru.vimPlugin = false;
|
||||||
|
}
|
||||||
|
// attrs;
|
||||||
|
|
||||||
|
# build a vim plugin with the given name and arguments
|
||||||
|
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
||||||
|
# instead
|
||||||
|
buildPlug = attrs: let
|
||||||
|
src = inputs."plugin-${attrs.pname}";
|
||||||
|
in
|
||||||
|
pkgs.vimUtils.buildVimPlugin (
|
||||||
|
{
|
||||||
|
version = src.shortRev or src.shortDirtyRev or "dirty";
|
||||||
|
inherit src;
|
||||||
|
}
|
||||||
|
// attrs
|
||||||
|
);
|
||||||
|
|
||||||
|
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
||||||
|
|
||||||
|
pluginBuilders = {
|
||||||
|
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
|
||||||
|
flutter-tools-patched = buildPlug {
|
||||||
|
pname = "flutter-tools";
|
||||||
|
patches = [../patches/flutter-tools.patch];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
buildConfigPlugins = plugins:
|
||||||
|
map (
|
||||||
|
plug:
|
||||||
|
if (isString plug)
|
||||||
|
then pluginBuilders.${plug} or (noBuildPlug {pname = plug;})
|
||||||
|
else plug
|
||||||
|
) (filter (f: f != null) plugins);
|
||||||
|
|
||||||
|
# built (or "normalized") plugins that are modified
|
||||||
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||||
|
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||||
|
|
||||||
|
# additional Lua and Python3 packages, mapped to their respective functions
|
||||||
|
# to conform to the format mnw expects. end user should
|
||||||
|
# only ever need to pass a list of packages, which are modified
|
||||||
|
# here
|
||||||
|
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
||||||
|
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
||||||
|
|
||||||
|
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
|
||||||
|
# generate a wrapped Neovim package.
|
||||||
|
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
||||||
|
neovim = vimOptions.package;
|
||||||
|
plugins = builtStartPlugins ++ builtOptPlugins;
|
||||||
|
appName = "nvf";
|
||||||
|
extraBinPath = vimOptions.extraPackages;
|
||||||
|
initLua = vimOptions.builtLuaConfigRC;
|
||||||
|
luaFiles = vimOptions.extraLuaFiles;
|
||||||
|
|
||||||
|
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||||
|
inherit extraLuaPackages extraPython3Packages;
|
||||||
|
};
|
||||||
|
|
||||||
|
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
|
||||||
|
# Additional helper scripts for printing and displaying nvf configuration
|
||||||
|
# in your commandline.
|
||||||
|
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
|
||||||
|
printConfigPath = pkgs.writers.writeDashBin "nvf-print-config-path" "echo -n ${dummyInit}";
|
||||||
|
|
||||||
|
# Expose wrapped neovim-package for userspace
|
||||||
|
# or module consumption.
|
||||||
|
neovim = pkgs.symlinkJoin {
|
||||||
|
name = "nvf-with-helpers";
|
||||||
|
paths = [neovim-wrapped printConfig printConfigPath];
|
||||||
|
postBuild = "echo Helpers added";
|
||||||
|
|
||||||
|
# Allow evaluating vimOptions, i.e., config.vim from the packages' passthru
|
||||||
|
# attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig
|
||||||
|
# will return the configuration in full.
|
||||||
|
passthru.neovimConfig = vimOptions;
|
||||||
|
|
||||||
|
meta =
|
||||||
|
neovim-wrapped.meta
|
||||||
|
// {
|
||||||
|
description = "Wrapped Neovim package with helper scripts to print the config (path)";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
config.vim.build = {
|
||||||
|
finalPackage = neovim;
|
||||||
|
};
|
||||||
|
}
|
3
modules/build/default.nix
Normal file
3
modules/build/default.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
imports = [./build.nix ./config.nix];
|
||||||
|
}
|
|
@ -60,11 +60,12 @@
|
||||||
"deprecations.nix"
|
"deprecations.nix"
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
concatLists [neovim plugins wrapper extra];
|
concatLists [neovim plugins wrapper extra [./build]];
|
||||||
in
|
in
|
||||||
allModules
|
allModules
|
||||||
++ [
|
++ [
|
||||||
{
|
{
|
||||||
|
_file = ./modules.nix;
|
||||||
_module.args = {
|
_module.args = {
|
||||||
baseModules = allModules;
|
baseModules = allModules;
|
||||||
pkgsPath = mkDefault pkgs.path;
|
pkgsPath = mkDefault pkgs.path;
|
||||||
|
|
Loading…
Reference in a new issue