115 Commits
Author SHA1 Message Date
Austin Horstman adfa139f94 wrappers: inherit platform config tuples
Nixvim wrapper modules passed the host nixpkgs' fully elaborated stdenv.{host,build}Platform attrsets into Nixvim's own nixpkgs import.

When the host and Nixvim nixpkgs revisions disagreed, those platform attrsets could be re-elaborated by a different lib.systems, causing eval recursion or platform-schema errors.

Pass only { config = ...; } as the inherited platform spec instead. This keeps ABI/libc details while letting Nixvim's selected nixpkgs elaborate the platform itself.
2026-06-29 04:20:49 +00:00
Matt SturgeonandMrQubo 56f95d1655 wrappers: fix _module.check disablement
When passing a string to `disabledModules`, it is appended to
`modulesPath`. To avoid this, explicitly pass a `{key}` module.

Adds an assertion module to the platform-wrapper integration tests:

    Failed assertions:
       - Expected programs.nixvim._module.check to be true. Definitions:
       - In `/nix/store/XXXX-source/flake/wrappers.nix': false

Co-authored-by: MrQubo <jakub.jakub.nowak@gmail.com>
2026-06-13 19:20:02 +00:00
Matt Sturgeon fec49e7376 wrappers/{nixos,hm}: add programs.neovim assertion
`programs.nixvim` and `programs.neovim` are incompatible; both install a
`neovim` package onto the PATH in an arbitrary order.

Home Manager also installs config into `.config/nvim`, which conflicts
with `wrapRc = false` used by default in our Home Manager module.
2026-06-12 18:03:35 +00:00
Matt Sturgeon 01bd278849 modules: drop helpers alias
Deprecated since 25.11.
2026-05-25 00:15:52 +00:00
Matt Sturgeon 909aa0a782 wrappers: pass in existing lib.nixvim
Extracting `specialArgs.lib.nixvim` from the final `programs.nixvim`
configuration is neat, but recursive. In non-lazy scenarios, it can end
up infinitely recursive.

We could extract `specialArgs.lib.nixvim` from another nixvim
configuration, such as one of the earlier `extendModules` evaluations,
however it is better to avoid evaluating multiple configurations
unnecessarily.

Instead, revert back to getting `lib.nixvim` from the same configuration
we get `extendModules` from.
2026-05-24 23:09:56 +00:00
Matt Sturgeon 978a84388e Revert "modules/nixpkgs: don't assign elaborated platforms"
This reverts commit f99264c1fb.

Cherry-picks https://github.com/NixOS/nixpkgs/commit/7c251e2b5fda2b42c3ff2983fdcc9eac82f2ced6
2026-05-24 05:41:42 +00:00
Matt Sturgeon e1ad5c4e92 wrappers: encapsulate access to lib.nixvim and lib-overlay
- Pass only `evalNixvim` into standalone.nix.
- Access Nixvim lib via the submodule configuration in _shared.nix.
2026-05-24 03:05:36 +00:00
Gaetan LepageandAustin Horstman 1d333fc92e treewide: apply linter suggestions 2025-12-28 04:26:49 +00:00
Guilhem SaurelandGaétan Lepage 1e0916836a defaultEditor also sets {env}VISUAL
same as https://github.com/nix-community/home-manager/pull/8322
2025-12-12 09:07:22 +00:00
Matt Sturgeon 53b702b367 wrappers: expose platform wrapper modules via build.*Module options
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`).
2025-12-09 08:01:49 +00:00
saygo-pngandMatt Sturgeon 03a51dbf3d treewide: NixVim/nixvim -> Nixvim
Signed-off-by: saygo-png <saygo.mail@proton.me>
2025-12-04 23:22:21 +00:00
Matt Sturgeon 947cb0aaed wrappers: use importApply to preserve module location
The `import module args` pattern is useful for applying inputs from
outside of the module system, however it discards module location
metadata that is usually associated with file-path modules.

`lib.modules.importApply` solves that problem by wrapping the applied
module using `lib.modules.setDefaultModuleLocation`.

This means documentation, warnings, and errors will show the correct
location.
2025-11-24 11:10:47 +00:00
Matt Sturgeon 3426dd04bb wrappers: use flake-locked lib instead of host's
Previously, we constructed Nixvim's extended lib from the host
configuration's lib.

Naïvely, this potentially allowed fetching fewer Nixpkgs revisions and
instantiating fewer lib instances. However, it also means our `lib`
interface is unstable, especially when the host configuration is using a
different Nixpkgs release to Nixvim.
2025-11-24 01:13:34 +00:00
Matt Sturgeon 8d0ca9abc4 lib: move enableExceptInTests impl to build.test option
Simplify the `enableExceptInTests` attribute, removing the
`_nixvimTests` argument.

We now do a full re-eval of the nixvim configuration before building the
test, giving us a central place to implement `enableExceptInTests` and
its eventual replacement(s).

This extends support for `enableExceptInTests` to all methods of getting
a nixvim test derivation. Previously, it only worked when using `mkTestDerivationFromNixvimModule`.

In `tests/main.nix`, we avoid the re-eval by doing the initial eval with
a "test mode" lib from the start.
2025-11-20 00:22:57 +00:00
Matt Sturgeon f99264c1fb modules/nixpkgs: don't assign elaborated platforms
See https://github.com/NixOS/nixpkgs/pull/376988
2025-02-04 23:57:58 +00:00
Matt Sturgeon 780d3eec72 wrappers/standalone: simplify extend 2025-01-20 14:49:59 +00:00
Matt Sturgeon 00586f8f1b modules/output: move symlinkJoin to build.package 2025-01-20 14:49:59 +00:00
Matt Sturgeon 82415eaa5d modules/nixpkgs: warn about changing defaults
If end-users change the nixpkgs revision to something other than our
default, they can run into issues not picked up by our test suite.
2025-01-19 13:13:15 +00:00
Matt Sturgeon 3a22953bea modules/nixpkgs: useGlobalPackages default to false
Rather than waiting for a technically impossible migration strategy,
let's just bite the bullet and change the default.
2025-01-19 13:13:15 +00:00
Matt Sturgeon 9bf4c9d55b wrappers/standalone: make pkgs arg optional, allow specifying system 2025-01-17 10:16:10 +00:00
Matt Sturgeon 7790746d38 modules/nixpkgs: add useGlobalPackages option 2025-01-17 10:16:09 +00:00
Matt Sturgeon 8dc8fa38b0 modules/nixpkgs: add hostPlatform & buildPlatform options 2025-01-17 09:37:03 +00:00
Matt Sturgeon 8938e09db1 modules/output: add manDocsPackage 2024-12-23 12:18:06 +00:00
Matt Sturgeon 472526d7aa wrappers: extract nixvim-lib from extended lib
Use the overridden nixivim-lib from the overlayed/extended nixpkgs lib.

This ensures consistency between `nixvimLib.nixvim` and `config.lib.nixvim.`
2024-12-23 09:58:55 +00:00
Matt Sturgeon aefab28b3b lib/overlay: init
The overlay allows extending any instance of nixpkgs-lib into a
nixvim-compatible "extended" instance.
2024-12-23 09:58:54 +00:00
Matt Sturgeon 4b3b67fb6f lib: make overrideable & access via flake
Add a non-system specific `<flake>.lib.nixvim` output, which is
equivalent to the existing `<flake>.lib.<system>.helpers` output.

This is now also wrapped with `lib.makeOverridable` to allow overriding
the function args used to construct the nixvim-lib.

Consistently access nixvim-lib via the new flake output, overriding
where necessary.
2024-12-21 15:17:43 +00:00
Matt Sturgeon bef9feb446 lib/modules: pass inputs.nixpkgs into evalNixvim
Expose our locked nixpkgs as the `nixpkgs.source` module options.

This only happens when `evalNixvim` is part of a lib that was provided
`flake` as an argument.

Stubbed the `nixpkgs.source` option for now. Eventually, this will be
used to construct `pkgs` internally. For now, it's purely informational.
2024-12-15 18:41:23 +00:00
Matt Sturgeon 32027965d8 lib: remove dependency on pkgs 2024-12-15 18:24:57 +00:00
Austin Horstman 95361fda3c treewide: apply deadnix suggestions 2024-12-14 11:34:26 -06:00
Gaetan LepageandMatt Sturgeon ae78face8d treewide: format with latest nixfmt 2024-12-06 15:25:27 +00:00
Matt Sturgeon b076f006c6 wrappers: add meta.wrappers options to wrappers
Allows the docs to be a little less hard-coded.

Lays the groundwork for splitting up the platform-specific option docs
on a per-page basis.
2024-10-22 14:15:58 +01:00
Matt Sturgeon 574ae92a43 wrappers/modules: move enable to shared.nix
We may end up having additional "shared" options and/or config.
2024-10-22 12:31:56 +01:00
Matt Sturgeon 5cd8c9cf31 wrappers: define pkgs default within type declaration
This fixes #2378
2024-10-11 00:30:32 +01:00
Matt Sturgeon e1c0b52487 wrappers: move programs.nixvim declaration to _shared.nix 2024-10-11 00:29:42 +01:00
Matt Sturgeon 4b7a41276a modules/nixpkgs: initial pkgs option, drop defaultPkgs specialArg
This minimal implementation allows `nixpkgs.pkgs` to be defined, but
does not implement evaluating an instance from a pkgsPath when _not_
defined.

The `defaultPkgs` specialArg is dropped in favour of `nixpkgs.pkgs`
being defined. If it's not defined, an assertion is thrown.

In the future, a nixpkgs source path can be supplied, defaulting to the
flake's `inputs.nixpkgs`. Along with other `nixpkgs.*` options, this
will allow a `pkgs` instance to be evaluated within the module eval.
2024-09-27 09:30:12 +01:00
Matt Sturgeon cb2b76c1a9 docs/home-manager: eval options without checking config definitions
By default `lib.evalModules` will check all config definitions match
a declared option (or a freeform type), leading to errors like:

    error: The option `wrapRc' does not exist.

Setting `_module.freeformType` or `_module.check` will disable this,
allowing us to evaluate the option declaration without checking the
config definitions.
2024-09-27 02:56:28 +01:00
Matt Sturgeon 6a1bf6bdc3 modules/output: check warnings+assertions on build.package
Add a `build.packageUnchecked` option for use instead of the old `check`
evalNixvim argument.
2024-09-26 18:04:36 +01:00
Matt Sturgeon 692e39311e modules/{output,files,test}: move outputs to build scope
Move the following output options into `build`:
- finalPackage -> package
- printInitPackage
- initPath -> initFile
- filesPlugin -> extraFiles
- test.derivation -> test
2024-09-26 06:31:57 +01:00
Matt Sturgeon 11924e1593 modules/output: add impureRtp option
Instead of assuming `wrapRc` implies we don't want impurities, configure
this separately.
2024-09-25 18:43:32 +01:00
Matt Sturgeon fb7cda2868 modules/output: refactor wrapRc default
Set default to `true`, with a low priority. Home-manager's wrapper sets
its own default using `mkOptionDefault`.

Clarify using `defaultText`.
2024-09-25 18:43:10 +01:00
Matt Sturgeon a8f678da24 wrappers: explicitly set _file for wrapper modules
This won't be detected automatically, since the modules are all returned
from function calls instead of being path references.
2024-09-25 16:22:25 +01:00
Matt Sturgeon 5b55858fe3 wrappers: use (evalModules {}).type for nixvim submodule 2024-09-24 19:17:44 +01:00
Matt Sturgeon 8f991cc8bc wrappers/shared: only propagate files when nixvim is enabled 2024-09-24 14:59:41 +01:00
Matt Sturgeon 87509bac1f wrappers: move assertion propagation to _shared.nix 2024-09-24 14:59:41 +01:00
Matt Sturgeon 191b0a9502 treewide: avoid passing pkgs to our lib
In the two places where our "helpers" lib is exclusively internal
(flake module args and building the docs), we no longer supply `pkgs`.

In the other 4 locations, we now note why we still do in a comment.
2024-09-22 18:18:05 +01:00
Matt Sturgeon 4e5bd1d79b lib: segregate and deprecate functions that need pkgs
Splits everything that depends on a `pkgs` instance into an optional
attrs, allowing `helpers.nix` to be bootstrapped without `pkgs`.

This required some refactoring:
- `modules.specialArgs` is only available when `pkgs` is used
- `modules.specialArgsWith` now requires `defaultPkgs` be provided
- `builders.*` now have `*With` variants that take `pkgs` as an argument
  and a `withPkgs` function that returns the old interface
- Had to define the fixed part of `builders` outside the attrs for now,
  to avoid infinite recursion.
- The old `builders` are now deprecated, and print a warning when
  evaluated
- `withOptoinalFns` was introduced to merge the optional attrs into the
  final lib.
2024-09-13 19:05:26 +01:00
Matt Sturgeon 7a147234f8 lib: rename helpers.nix -> default.nix
The old `default.nix` is inlined into the "lib" flake-module, which is
the only place it was used.

This allows "helpers" to take its rightful place at the root of `./lib` 👑
2024-09-13 17:25:17 +01:00
Austin Horstman c76e5070b9 wrappers: cleanup with lib 2024-09-03 22:12:33 -05:00
Matt Sturgeon 511a328aa3 wrappers: add our lib to the host's _module.args
Make our "extended" lib available to host modules as `_module.args.nixvimLib`.

We didn't do this before because `helpers` was too generic of a name,
but `nixvimLib` should be ok.

    { nixvimLib, ... }: {
        programs.nixvim.someOption = nixvimLib.nixvim.mkRaw "print('Hi')";
    }
2024-08-22 13:19:59 +01:00
Matt Sturgeon 851edc8df1 lib/modules: add evalNixvim
Evaluates a nixvim config, by default also checking warnings and assertions.

This used internally by the standalone wrapper.
2024-08-20 22:22:53 +01:00