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.
This commit is contained in:
Matt Sturgeon 2024-09-12 14:56:36 +01:00
parent f47e8f8f79
commit 4e5bd1d79b
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
12 changed files with 165 additions and 84 deletions

View file

@ -1,19 +1,17 @@
{
pkgs,
lib,
helpers,
self,
}:
rec {
# Minimal specialArgs required to evaluate nixvim modules
specialArgs = specialArgsWith { };
# Build specialArgs for evaluating nixvim modules
specialArgsWith =
extraSpecialArgs:
# TODO: switch defaultPkgs -> pkgsPath (i.e. pkgs.path or inputs.nixvim)
# FIXME: Ideally, we should not require callers to pass in _anything_ specific
{ defaultPkgs, ... }@extraSpecialArgs:
{
inherit lib defaultPkgs;
# TODO: deprecate `helpers`
inherit lib helpers;
defaultPkgs = pkgs;
helpers = self;
}
// extraSpecialArgs;