Commit graph

101 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
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 Lepage
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
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
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
faff876ee6
wrappers: use lib.nixvim option
Update internal usage from the deprecated `nixvim.helpers` option to the
new `lib.nixvim` option name.
2024-07-25 17:10:54 +01: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
traxys
367380bd84 modules/output: Remove the initContent option
This (internal) option introduces IFD, and can be substituted internally
with the `initPath` option easily.
If the content is required somewhere users can use readFile on the
initPath, though it will result in an IFD in their project.
2024-07-05 22:08:25 +02: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
3d96960348 wrappers: simplify modules 2024-07-02 14:15:51 +00: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