Skip to content

Conversation

@MattSturgeon
Copy link
Member

This change exposes the platform wrapper modules (nixosModule, homeModule, and nixDarwinModule) as standard output options under build.*Module within a Nixvim configuration. This allows users to take an existing Nixvim configuration and directly embed it into NixOS, Home Manager, or nix-darwin without re-importing modules into programs.nixvim manually.

To construct these wrapper modules we need to evaluate a minimal Nixvim configuration that contains no pkgs or nixpkgs.hostPlatform. Such a configuration would normally fail to eval, but evaluating it with _module.check = false is lazy enough to read the wrapper options. This base module is marked with a unique key and is later disabled by wrappers/_shared.nix to prevent the no-check setting from leaking into user configurations.

Fixes #4009

@MattSturgeon MattSturgeon changed the title wrappers: move to build.*Module options wrappers: expose platform wrapper modules via build.*Module options Dec 3, 2025
@MattSturgeon MattSturgeon force-pushed the wrapper-module-options branch from 8daacc6 to fb74fbc Compare December 3, 2025 09:33
Expose the platform wrapper modules as the Nixvim configuration options
`build.nixosModule`, `build.homeModule`, and `build.nixDarwinModule`.
This makes it possible to reuse a single Nixvim configuration across
NixOS, Home Manager, and nix-darwin without re-importing modules into
`programs.nixvim` manually.

Evaluating these wrapper modules requires a "bare" Nixvim configuration;
one that does not define `pkgs` or `nixpkgs.hostPlatform`. Such a
configuration would normally fail to evaluate, but disabling
`_module.check` provides a sufficiently lazy evaluation to access the
wrapper options.

To prevent the `_module.check = false` module from leaking into user
configs, it has a unique module key and gets disabled inside the wrapper
modules (`wrappers/_shared.nix`).
@MattSturgeon MattSturgeon force-pushed the wrapper-module-options branch from fb74fbc to 5a5f602 Compare December 3, 2025 09:33
@MattSturgeon
Copy link
Member Author

The edge-case where a user configures nixvim with platform-a, and then uses that configuration's nixosModule on a NixOS configuration using platform-b, may need handling better.

That probably means choosing a higher override priority when propagating the host's system to programs.nixvim.nixpkgs.hostPlatform:

# Inherit platforms
hostPlatform = lib.mkOptionDefault pkgs.stdenv.hostPlatform.system;
buildPlatform = lib.mkOverride buildPlatformPrio pkgs.stdenv.buildPlatform.system;

Not necessarily in-scope for this PR though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrappers: support extraSpecialArgs

1 participant