Commit graph

34 commits

Author SHA1 Message Date
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
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
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 Lepage
ae78face8d
treewide: format with latest nixfmt 2024-12-06 15:25:27 +00: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
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
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
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
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
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
Stanislav Asunkin
44849233e0 modules/performance: add ability to byte compile lua configuration files
This commit adds support for byte compiling lua configuration files.
It's enabled by default (if byte compiling is enabled at all) and can be
disabled with `performance.byteCompileLua.configs` toggle.

To implement this feature `extraFiles.<name>.finalSource` internal
read-only option is introduced. `source` option cannot be used because
it's user configurable. In order to access the values of the
`performance.byteCompileLua` options, parent config is added to
specialArgs of extraFiles submodule. Then the usages of `source` option
changed to `finalSource` in all relevant places (filesPlugin and
wrappers).

Added more helpers for various cases of byte compiling:

* `byteCompileLuaFile` byte compiles lua file
* `byteCompileLuaHook` is a setup hook that byte compiles all lua files
* `byteCompileLuaDrv` overrides derivation by adding byteCompileLuaHook
  to it

Added tests to validate that extraFiles specified by various methods are
handled correctly. Added a separate home-manager test, that is intended
to validate that extraFiles propagated to wrapper modules are correctly
byte compiled.
2024-07-31 11:31:40 +00:00
Matt Sturgeon
216d64c158
wrappers: make helpers available via lib option
NixOS, HM, & Darwin provide a `lib` option, not to be confused with the
`lib` module arg.

This option is intended for modules to define custom functions without
having to extend nixpkgs lib.

The old option is renamed, if it is accessed it will print:

    trace: Obsolete option `nixvim.helpers' is used. It was renamed to `lib.nixvim'.
2024-07-24 22:02:56 +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
cfa44bbb66
wrappers: make _shared.nix return a module 2024-07-08 16:24:06 +01:00
Matt Sturgeon
086873bed9
modules: refactor extraFiles
Moved `extraFiles` from `modules/output.nix` into its own file `modules/files.nix`.

Users should now assign text to a `text` attribute, however they could
also assign a file path to a `source` attribute instead.

The old method of directly assigning a string still works, and is
coerced to the new type along with a deprecation warning.
2024-07-07 16:42:47 +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
traxys
62f32bfc71 treewide: Reformat with nixfmt 2024-05-05 22:00:40 +02:00
Gaetan Lepage
5d3ed3a09e misc: refactor helpers propagation
Co-authored-by: Robert Hensing <robert@roberthensing.nl>
2024-02-09 14:20:25 +01:00
traxys
5a498edd14
modules/output: Allow to specify text to add as extra files (#343)
To enable some features (like adding tree-sitter queries) we need to add
files to specific directories in the runtime path (queries/lang/file.scm
for tree-sitter queries for example).

This commit adds support for specifying such files. You must be careful
to not have any collisions between `files` and `extraFiles`.
2023-04-21 20:04:58 +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
264de8cefb
added formatter + reformat existing codebase (#175) 2023-02-20 10:42:13 +00:00
LightQuantum
7ccb2b0608
utils: fix #129
* wrappers: fix missing variable

* bufferline: fix type error if indicator is null
2023-02-14 19:51:56 +00:00
Alexander Nortung
63c256dc3d
core: show warnings for deprecated or changed options (#129)
* moved helpers to lib folder

* Created proxy file for helpers.nix

* wrappers: removed code duplication

* null-ls: fix wrong name of variable

* added warnings module

* Added assertions

* bufferline: deprecated option

* nvim-tree: renamed options

* Fixed mkRenamedOption

* Bufferline: added new options

* Fixed deprecated option

Co-authored-by: Pedro Alves <pta2002@pta2002.com>
2023-01-24 01:28:01 +00:00