I’m not sure I understand what you’re asking, but I don’t think configure supports passing an init.lua, let alone a directory.
If you don’t care about python, node and what not, you can do what I do: skip this wrapper (pkgs.neovim) and make your own (simpler) wrapper around pkgs.neovim-unwrapped.
{ config, lib, pkgs, ... }:
let
plugins = with pkgs.vimPlugins;
[ # plugins here
undotree gitsigns-nvim
plenary-nvim
];
pack = pkgs.linkFarm "neovim-plugins"
(map (pkg:
{ name = "pack/${pkg.pname}/start/${pkg.pname}";
path = toString pkg;
}) plugins);
neovim-wrapped = pkgs.runCommand "${pkgs.neovim-unwrapped.name}"
{ nativeBuildInputs = [ pkgs.makeWrapper ]; }
''
mkdir -p "$out"
makeWrapper '${pkgs.neovim-unwrapped}/bin/nvim' "$out/bin/nvim" \
--add-flags "-u ${conf}"
'';
# If you want write the config here, or
# specify a path (will be copied into the nix store), or
# just don't add the -u flag at all.
conf = pkgs.writeText "init.lua"
''
-- load the plugins
opt.packpath = '${pack}'
-- configure neovim here
opt.hidden = true
opt.mouse = 'a'
--- etc.
'';
in
{
nixpkgs.overlays = [(self: super: { neovim = neovim-wrapped; })];
# nix build -f '<nixpkgs/nixos>' config.programs.neovim.package for testing
programs.neovim.package = neovim-wrapped;
}
Isn’t it a bit strange to create its own wrapper when the manual specifies a way to configure neovim using customRC? Also for more complex setups where a single file is not enough, one can just package it as a usual plugin (that basically follows the structure of ./config/nvim as far as I understand, but I’m not sure if you can load the script without calling it from customRC).
Note also that NixOs and home managers provides modules.
# In shell.nix
{ pkgs ? import <nixpkgs> {} }:
let
# List of custom packages
easygrep = pkgs.vimUtils.buildVimPlugin {
name = "vim-easygrep";
src = pkgs.fetchFromGitHub {
owner = "dkprice";
repo = "vim-easygrep";
rev = "d0c36a77cc63c22648e792796b1815b44164653a";
sha256 = "0y2p5mz0d5fhg6n68lhfhl8p4mlwkb82q337c22djs4w5zyzggbc";
};
};
# Use customRC for simple config but if you want your configuration to be in multiple files, you
# can just package them as a plugin as plugins respect the hierarchie of .config/nvim file
# as presented for instance here.
# https://github.com/nanotee/nvim-lua-guide
myConfig = pkgs.vimUtils.buildVimPlugin {
name = "my-config";
# Create in this directory a file like my-neovim-config/lua/init.lua, to load as below in customRC using
# lua require("init")
src = ./my-neovim-config;
};
# The neovim package with your configuration
myNeovim = pkgs.neovim.override {
configure = {
customRC = ''
" your custom configuration (vim format). If you like to have multiple files or lua config,
" you can create a plugin easily as shown above.
:colorscheme evening
lua require("init")
'';
packages.myPlugins = with pkgs.vimPlugins; {
start = [
# vim-go # already packaged plugin
easygrep # custom package not packaged in nixpkgs
myConfig # my own configuration
];
opt = [];
};
};
};
in
with pkgs;
pkgs.mkShell {
buildInputs = [
myNeovim
];
}
Custom a wrapper for neovim is a huge and difficult work to me, since I need python, node and I am not very faimilar with nix, I will take the plugin solution, but thanks anyway.