Replies: 1 comment 1 reply
-
There are several ways to approach this, but I'll start by mentioning it is easier to reuse standalone nixvim modules in home-manager than use modules from home-manager in a standalone nixvim. The first thing to undeststand is a high-level concept relating to the module system itself: how submodules work. TL;DR: submodules are not special, they are just a normal module configuration (aka module eval) nested within another module configuration. More specifically, an option of submodule type expects its definition values to be modules, then the submodule type merges those modules (using This means a submodule can contain arbitrary modules; with option declarations, imports, config definitions, default values, etc. This is relevant here, because That's why everything within Ok, enough theory. What does that mean in practice? Well, one approach for reusing nixvim configuration is to reuse the resulting package. I.e. include your standalone nixvim package in your This can be extended using the Another approach is to define your nixvim modules in a shared location, and import them into both your standalone nixvim configuration, and home-manager's # home-manager
{
programs.nixvim = {
imports = [ ../nixvim/modules ];
};
} If you're working with nixvimConfigurations (instead of directly with the resulting packages), as shown in the "experimental" flake-parts templates, then you can also use If you really wanted to define all your nixvim modules in home-manager configuration and then reuse them elsewhere, this is possible, but convoluted. It also isn't very idiomatic. Without NixOS/nixpkgs#391544, it's even more convoluted... Because we don't have NixOS/nixpkgs#391544, we can't access metadata about the submodule's configuration; we only have its final I won't spend time creating an example, because I think it's a bad way to approach the problem. My recommendation would be to write re-usable nixvim modules as much as possible, then import these into all your nixvim configurations (standalone or submodule). As an aside, our documentation on this is probably not aligned very well with what I wrote here. I suspect we're still pushing the "use a nixvim package and Relevant docs are currently Installation -> Standalone usage and Nixvim Platforms -> Standalone. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Basically the title.
I have been using nixvim for some time now, and would like to expose my home-manager based config of it as a standalone package.
I would also consider turning my hm config into a standalone config, and then reusing the result in home-manager. From what I gather, that's the suggested method in the docs.
However, in my case I have the complicating factor that I've defined custom options whose config values affect the nixvim configuration (things like a top-level
palette
option, and a per-language toggle which enables/disables complete lsp/formatting/linting/... setups for individual languages.I'm unable to get either way to work:
programs.nixvim
is undefined, and I have not found a way around this which properly evaluates all of the nixvim config before "lifting"programs.nixvim.*
to*
;programs.nixvim.
I am sorry if this doesn't make too much sense. My config lives here. If someone can point me in the right direction or has done something similar, I'd be very grateful to hear it!
Beta Was this translation helpful? Give feedback.
All reactions