"The option `flake.wrappers.neovim.addFlag' does not exist" error when using .install with flake-parts #502
-
I receive the above error when using {
config,
lib,
self,
inputs,
...
}:
let
inherit (inputs) nixpkgs wrappers;
module = nixpkgs.lib.modules.importApply ./module.nix {
inherit inputs;
flake-path = "${self}";
};
wrapper = wrappers.lib.evalModule module;
in
{
imports = [ wrappers.flakeModules.wrappers ];
flake = {
wrappers.neovim = wrapper.config;
overlays.neovim = final: prev: { neovim = wrapper.config.wrap { pkgs = final; }; };
homeModules.neovim =
{ config, lib, ... }:
let
inherit (config.home) dotfilesDir;
inherit (config.lib.file) mkOutOfStoreSymlink;
cfg = config.wrappers.neovim;
in
{
imports = [ self.wrappers.neovim.install ];
wrappers.neovim = {
enable = true;
settings.config_directory = lib.mkForce (mkOutOfStoreSymlink "${dotfilesDir}/terminal/neovim");
};
home.sessionVariables = lib.mkIf cfg.enable {
EDITOR = "${cfg.wrapper}/bin/nvim";
VISUAL = "${cfg.wrapper}/bin/nvim";
};
programs.zsh.shellAliases = {
vi = cfg.binName;
};
};
};
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
wrappers.neovim = wrapper.config;^ the problem is that line You are importing just the config set of a module as a module So, it is missing the import statements and stuff, such as the one that imports the base neovim module from this repo. I would think, with what you have, that building the package directly via What you are looking for is: wrappers.neovim = module;i.e. {
config,
lib,
self,
inputs,
...
}:
let
inherit (inputs) nixpkgs wrappers;
# if you set _file and key in the module you dont need importApply you can just import and call it
# but I left it here for now anyway
module = nixpkgs.lib.modules.importApply ./module.nix {
inherit inputs;
flake-path = "${self}";
};
in
{
imports = [ wrappers.flakeModules.wrappers ];
flake = {
# this is a submodule option. It accepts modules. (it was created with wlib.types.subWrapperModule)
wrappers.neovim = module; # <- this was where your bug was from.
# you should use self.wrappers.neovim here probably, since we got rid of the thing we were getting this from before
overlays.neovim = final: prev: { neovim = self.wrappers.neovim.wrap { pkgs = final; }; };
# same thing you had (although improvements for this are below)
homeModules.neovim =
{ config, lib, ... }:
let
inherit (config.home) dotfilesDir;
inherit (config.lib.file) mkOutOfStoreSymlink;
cfg = config.wrappers.neovim;
in
{
imports = [ self.wrappers.neovim.install ];
wrappers.neovim = {
enable = true;
settings.config_directory = lib.mkForce (mkOutOfStoreSymlink "${dotfilesDir}/terminal/neovim");
};
home.sessionVariables = lib.mkIf cfg.enable {
EDITOR = "${cfg.wrapper}/bin/nvim";
VISUAL = "${cfg.wrapper}/bin/nvim";
};
programs.zsh.shellAliases = {
vi = cfg.binName;
};
};
};
}However some things that may be of interest for you 3 things I notice about your config
In my config I have this config.install.modules.homeManager = { config, lib, ... }: let
cfg = top.config.install.getWrapperConfig config;
in {
home.sessionVariables = lib.mkIf cfg.enable (let
nvimpath = lib.getExe cfg.wrapper;
in {
EDITOR = nvimpath;
MANPAGER = "${nvimpath} +Man!";
});
};You could do all of it like { config, lib, wlib, ... }@top: { # <- this is a wrapper module to import inside your neovim wrapper module
config.settings.aliases = [ "vi" ]; # <- add the vi alias
config.install.modules.homeManager = { config, lib, ... }: let # <- add instructions to the install module for home manager
# get the wrapper config from top.config.install.optionLocation
cfg = top.config.install.getWrapperConfig config;
in {
config = lib.mkMerge [ # <- mkMerge is fancy // (which would work here too, but this is technically better)
# creates an extra wrapper module at the correct top.config.install.optionLocation
(top.config.install.mkWrapperExtension "this name just has to be unique for this nvim wrapper module" {
# It accepts an impure path, no need to wlib.mkOutOfStoreSymlink
settings.config_directory = lib.mkForce "${config.home.dotfilesDir}/terminal/neovim";
})
# the rest of the regular home manager config set
{
home.sessionVariables = lib.mkIf cfg.enable (let
nvimpath = lib.getExe cfg.wrapper;
in {
EDITOR = nvimpath;
MANPAGER = "${nvimpath} +Man!";
});
}
];
};
}And then the install module you have will include all the instructions and you wouldn't need to declare it as a separate home manager module. So, then your flake-parts module with all the neovim stuff would look something like {
config,
lib,
self,
inputs,
...
}:
let
inherit (inputs) nixpkgs wrappers;
module = nixpkgs.lib.modules.importApply ./module.nix {
inherit inputs;
flake-path = "${self}";
};
in
{
imports = [ wrappers.flakeModules.wrappers ];
flake = {
wrappers.neovim = { imports = [ module ./thatfileIputabovewiththeinstallmoduleadditions.nix ]; }; # <- or you could import the file inside the ./module.nix idk, I just wanted to have it in the example
overlays.neovim = final: prev: { neovim = self.wrappers.neovim.wrap { pkgs = final; }; };
# homeModules.neovim = self.wrappers.neovim.install; # or, more exactly what you had
homeModules.neovim = { imports = [ self.wrappers.neovim.install; ]; wrappers.neovim.enable = true; };
};
}Also you might find this flake parts module useful { inputs, ... }: # <- idk, however you want to get inputs, this one was called with importApply
{ config, ... }:
{
_file = ./thisfile.nix;
key = ./thisfile.nix;
imports = [
inputs.flake-parts.flakeModules.modules
inputs.wrappers.flakeModules.wrappers
];
config.flake.modules.generic = builtins.mapAttrs (_: v: v.install) config.flake.wrappers;
}And probably also eventually this discussion #493 Also, whenever you see that particular error message, it almost certainly means you did not import |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, I got my config working in the ideal way now! Fyi, some of my confusion stemmed from initially following https://github.com/BirdeeHub/nix-wrapper-modules/blob/main/templates/neovim/flake.nix (which is why I had And thank you for the additional suggestions! I opted not to do 1. because I needed the process path suffix to stay as |
Beta Was this translation helpful? Give feedback.
^ the problem is that line
You are importing just the config set of a module as a module
So, it is missing the import statements and stuff, such as the one that imports the base neovim module from this repo.
I would think, with what you have, that building the package directly via
nix build .#neovimalso does not work, correct?What you are looking for is:
i.e.