Commit graph

41 commits

Author SHA1 Message Date
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
9bf4c9d55b
wrappers/standalone: make pkgs arg optional, allow specifying system 2025-01-17 10:16:10 +00:00
Matt Sturgeon
8938e09db1
modules/output: add manDocsPackage 2024-12-23 12:18:06 +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
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
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
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
5b55858fe3
wrappers: use (evalModules {}).type for nixvim submodule 2024-09-24 19:17:44 +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
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
Matt Sturgeon
27c4c9c210
lib/modules: init with specialArgs helpers 2024-08-02 14:38:38 +01:00
Matt Sturgeon
491ca5cf51
lib: provide an "extended lib" to our modules
lib/extend-lib.nix returns a nixpkg's lib extended with our own
helpers.

This is exposed as `helpers.extendedLib`, but when evaluating our
modules it should be assigned to `specialArgs.lib`.

Outside of our modules you must still access our helpers via
`config.lib.nixvim` or `config.lib.nixvim.extendedLib`.

Within helpers' sub-sections, `lib` is the extended lib.
2024-08-02 14:33:59 +01:00
Matt Sturgeon
1b7efacdf4
wrappers: bootstrap "helpers" directly
We don't need to pass a `getHelpers` function in, since we can just
import `../lib/helpers.nix`.
2024-07-08 16:24:06 +01:00
Matt Sturgeon
517648dac0
wrappers/standalone: move module to wrappers/modules 2024-07-05 18:28:19 +01:00
Matt Sturgeon
2deb61f6a5
modules/top-level: move out of wrappers/modules 2024-07-05 17:20:28 +01:00
Matt Sturgeon
d2afb176ff
modules: refactor module bootstrapping
Let's simplify things by defining all modules in `./plugins`, `./modules`
and `./wrappers/modules`.

Instead of currying `pkgs` into a bootstrapping module, we can require
`defaultPkgs` be provided as a special arg.

This refactor allows us to completely remove `flake-modules/modules.nix`!
2024-07-02 19:58:30 +01:00
Matt Sturgeon
55fee7051f
standalone: rename nixvimExtend to extend
This is our scope, so there's no need to be explicit.

This also follows the precedent set by `lib.extend`, although that takes
an overlay function.
2024-07-01 15:54:29 +01:00
Sandro Jäckel
662a0e1bdb wrappers: use system from stdenv.hostPlatform
`pgs.system` is a flaky alias and it is more reliable to directly use
`pkgs.stdenv.hostPlatform.system`
2024-06-30 09:54:24 +02:00
traxys
e035d22b64 standalone: Expose options
This can be used to teach `nixd` about NixVim options.
2024-05-15 09:41:21 +02:00
traxys
62f32bfc71 treewide: Reformat with nixfmt 2024-05-05 22:00:40 +02:00
Matt Sturgeon
3f7e6ce850
wrappers: expose config in standalone output (#1356) 2024-04-01 17:12:25 +02:00
traxys
9cd3721adf
standalone: Allow to extend a standalone derivation with a new module (#1142)
This adds the `nixvimExtend` attribute to the generated standalone
derivation, this attribute takes a module as an argument and returns a
new standalone derivation with the initial module & the extended module
merged together.
2024-02-22 08:22:21 +01:00
traxys
6d7e429537
tests: Introduce a way to disable options when running in tests (#1095)
In our basic template we used to provide a check based on
`mkTestDerivationFromNvim`. The issue with this check (that is handled
correctly internally) is that some plugins _can't_ be used in the test
environment, for example image.nvim like in #1085.

This commit introduces a new function to generate such checks,
`mkTestDerivationFromNixvimModule`, that wraps a nixvim configuration
instead of a built nvim instance.

Then a configuration can rely on the newly added
`helpers.enableExceptInTests` attribute to disable parts of the
configuration depending if it is evaluated in tests or in a real final
configuration.

Resolves #1085
2024-02-15 14:27:45 +01:00
Gaetan Lepage
5d3ed3a09e misc: refactor helpers propagation
Co-authored-by: Robert Hensing <robert@roberthensing.nl>
2024-02-09 14:20:25 +01:00
Mirko Lenz
46ca452d0b
standalone: pass extraSpecialArgs to lib.evalModules directly (#914) 2024-01-07 20:49:17 +01:00
traxys
1f652b60e5
standalone: Fix extraSpecialArgs (#799)
This commit fixes the usage of `extraSpecialArgs` for standalone nixvim
installations and adds a test to ensure this.

Fixes #779
2023-12-09 15:42:15 +01:00
Gaetan Lepage
45d788bdd9 wrappers: add nixvim-print-init package 2023-12-07 14:38:21 +01:00
traxys
b58b23c799
wrapper: Use symlink join to install man pages for standalone (#736)
Patching the derivation forces a rebuild of neovim, which is
undesirable
2023-11-23 22:11:29 +01:00
Gaetan Lepage
a05b2a9cbf wrappers/standalone: fix 2023-11-21 10:00:48 +01:00
traxys
541b694873
docs: Allow to install man pages (#687) 2023-11-06 16:26:23 +01:00
traxys
0c5dcb56d1
standalone: Allow to pass extraSpecialArgs (#665) 2023-10-23 14:11:29 +02:00
Luc Chabassier
a6eec507cc
Enable creation of other config files than init.lua (#246) 2023-04-20 22:41:37 +02:00
Gaétan Lepage
d6373c62ae
wrappers/standalone: handle assertions (#305) 2023-03-31 15:10:27 +02:00
Gaétan Lepage
264de8cefb
added formatter + reformat existing codebase (#175) 2023-02-20 10:42:13 +00:00
traxys
660c9319e1
wrappers: Extend and document the makeNixvim function (#86)
* wrappers: Allow to customize the nixpkgs used for nixvim

This allows to pass overlays and other such modifications of nixpkgs.

* wrappers: Allow to pass a custom module to nixvim

This is useful to be able to take full advantage of the Nix module
system, with `imports` and `options`.

* README: Update the documentation on the standalone usage

The following information were out of date or incomplete:

- The `build` function has be changed to the `makeNixvim` function.
- `makeNixvimWithModule` has been introduced in order to allow more
customization.
- Added a full example using nixvim in a standalone flake
2022-12-29 17:51:57 +00:00
Luc Chabassier
f2a103da30
Allow using global config with hm and nixos (#48)
* remove useless nixvim file

* reorganize flake outputs

* use global config file with home-manager and nixos
2022-10-17 14:08:17 +01:00