1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-21 17:59:41 +01:00

lib: simplify bootstrapping

Previously, `lib/top-level.nix` used an `_isExtended` flag to indicate
whether the provided `lib` was already extended. This made bootstrapping
unclear and introduced the possibility of circular construction.

All construction now flows through the lib-overlay, removing
`_isExtended`. As a result, `lib/top-level.nix` always receives the
final extended lib.

The `<flake>.lib.nixvim` output is now defined as:

    (lib.extend <nixvim>.lib.overlay).nixvim

The overlay now imports `top-level.nix` directly, making it the
canonical entrypoint for constructing Nixvim's section of the lib.

A clarifying doccomment was added to `lib/top-level.nix`.
This commit is contained in:
Matt Sturgeon 2025-11-20 02:42:05 +00:00
parent f11c43612f
commit c53e0161c3
3 changed files with 23 additions and 11 deletions

View file

@ -13,9 +13,8 @@
# Public `lib` flake output # Public `lib` flake output
flake.lib = { flake.lib = {
nixvim = lib.makeOverridable (import ../lib/top-level.nix) { nixvim = lib.makeOverridable ({ lib }: (lib.extend self.lib.overlay).nixvim) {
inherit lib; inherit lib;
flake = self;
}; };
overlay = lib.makeOverridable (import ../lib/overlay.nix) { overlay = lib.makeOverridable (import ../lib/overlay.nix) {
flake = self; flake = self;

View file

@ -27,10 +27,7 @@
*/ */
lib: prevLib: { lib: prevLib: {
# Add Nixvim's section to the lib # Add Nixvim's section to the lib
nixvim = flake.lib.nixvim.override { nixvim = import ./top-level.nix { inherit flake lib; };
inherit lib;
_isExtended = true;
};
# Extend the maintainers set with Nixvim-specific maintainers # Extend the maintainers set with Nixvim-specific maintainers
maintainers = prevLib.maintainers // import ./maintainers.nix; maintainers = prevLib.maintainers // import ./maintainers.nix;

View file

@ -1,17 +1,33 @@
/**
Construct Nixvim's section of the lib: `lib.nixvim`.
This function requires the final extended lib (as produced by `./overlay.nix`)
and should not usually be imported directly.
The flake output `<nixvim>.lib.nixvim` provides an instance of Nixvim's lib section.
# Inputs
`flake`
: The nixvim flake.
`lib`
: The final extended lib.
*/
{ {
lib, lib,
flake, flake,
_isExtended ? false,
}: }:
lib.makeExtensible ( lib.makeExtensible (
self: self:
let let
# Used when importing parts of our lib # Used when importing parts of our lib
call = lib.callPackageWith { call = lib.callPackageWith {
inherit call self; inherit
# TODO: this would be much simpler if `lib` & `self` were kept explicitly separate call
# Doing so should also improve overridability and simplify bootstrapping. self
lib = if _isExtended then lib else lib.extend flake.lib.overlay; lib
;
}; };
in in
{ {