mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
lib/overlay: init
The overlay allows extending any instance of nixpkgs-lib into a nixvim-compatible "extended" instance.
This commit is contained in:
parent
450cccf472
commit
aefab28b3b
6 changed files with 27 additions and 25 deletions
|
@ -18,6 +18,9 @@
|
||||||
inherit lib;
|
inherit lib;
|
||||||
flake = self;
|
flake = self;
|
||||||
};
|
};
|
||||||
|
overlay = lib.makeOverridable (import ../lib/overlay.nix) {
|
||||||
|
flake = self;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// lib.genAttrs config.systems (
|
// lib.genAttrs config.systems (
|
||||||
lib.flip withSystem (
|
lib.flip withSystem (
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
flake ? null, # Optionally, provide the lib with access to the flake
|
flake,
|
||||||
|
_isExtended ? false,
|
||||||
_nixvimTests ? false,
|
_nixvimTests ? false,
|
||||||
}:
|
}:
|
||||||
lib.makeExtensible (
|
lib.makeExtensible (
|
||||||
|
@ -9,14 +10,15 @@ lib.makeExtensible (
|
||||||
# Used when importing parts of our lib
|
# Used when importing parts of our lib
|
||||||
call = lib.callPackageWith {
|
call = lib.callPackageWith {
|
||||||
inherit call self;
|
inherit call self;
|
||||||
lib = self.extendedLib;
|
# TODO: this would be much simpler if `lib` & `self` were kept explicitly separate
|
||||||
|
# Doing so should also improve overridability and simplify bootstrapping.
|
||||||
|
lib = if _isExtended then lib else lib.extend flake.lib.overlay;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
autocmd = call ./autocmd-helpers.nix { };
|
autocmd = call ./autocmd-helpers.nix { };
|
||||||
builders = call ./builders.nix { };
|
builders = call ./builders.nix { };
|
||||||
deprecation = call ./deprecation.nix { };
|
deprecation = call ./deprecation.nix { };
|
||||||
extendedLib = call ./extend-lib.nix { inherit lib; };
|
|
||||||
keymaps = call ./keymap-helpers.nix { };
|
keymaps = call ./keymap-helpers.nix { };
|
||||||
lua = call ./to-lua.nix { };
|
lua = call ./to-lua.nix { };
|
||||||
modules = call ./modules.nix { inherit flake; };
|
modules = call ./modules.nix { inherit flake; };
|
||||||
|
@ -93,6 +95,9 @@ lib.makeExtensible (
|
||||||
|
|
||||||
toLuaObject = self.lua.toLua;
|
toLuaObject = self.lua.toLua;
|
||||||
mkLuaInline = self.lua.mkInline;
|
mkLuaInline = self.lua.mkInline;
|
||||||
|
|
||||||
|
# TODO: Removed 2024-12-21
|
||||||
|
extendedLib = throw "`extendedLib` has been removed. Use `lib.extend <nixvim>.lib.overlay` instead.";
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
# TODO: Removed 2024-09-27; remove after 24.11
|
# TODO: Removed 2024-09-27; remove after 24.11
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Extends nixpkg's lib with our functions, as expected by our modules
|
|
||||||
{
|
|
||||||
call,
|
|
||||||
lib,
|
|
||||||
self,
|
|
||||||
}:
|
|
||||||
lib.extend (
|
|
||||||
final: prev: {
|
|
||||||
# Include our custom lib
|
|
||||||
nixvim = self;
|
|
||||||
|
|
||||||
# Merge in our maintainers
|
|
||||||
maintainers = prev.maintainers // import ./maintainers.nix;
|
|
||||||
|
|
||||||
# Merge in our custom types
|
|
||||||
types = prev.types // call ./types.nix { };
|
|
||||||
}
|
|
||||||
)
|
|
14
lib/overlay.nix
Normal file
14
lib/overlay.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ flake }:
|
||||||
|
final: prev: {
|
||||||
|
# Include our custom lib
|
||||||
|
nixvim = flake.lib.nixvim.override {
|
||||||
|
lib = final;
|
||||||
|
_isExtended = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Merge in our maintainers
|
||||||
|
maintainers = prev.maintainers // import ./maintainers.nix;
|
||||||
|
|
||||||
|
# Merge in our custom types
|
||||||
|
types = prev.types // import ./types.nix { lib = final; };
|
||||||
|
}
|
|
@ -8,8 +8,6 @@
|
||||||
system ? pkgs.stdenv.hostPlatform.system,
|
system ? pkgs.stdenv.hostPlatform.system,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
nixvimLib = helpers.extendedLib;
|
|
||||||
|
|
||||||
autoArgs = pkgs // {
|
autoArgs = pkgs // {
|
||||||
inherit
|
inherit
|
||||||
helpers
|
helpers
|
||||||
|
@ -18,7 +16,7 @@ let
|
||||||
system
|
system
|
||||||
;
|
;
|
||||||
nixpkgsLib = lib;
|
nixpkgsLib = lib;
|
||||||
lib = nixvimLib;
|
lib = lib.extend self.lib.overlay;
|
||||||
inherit (self.legacyPackages.${system})
|
inherit (self.legacyPackages.${system})
|
||||||
makeNixvimWithModule
|
makeNixvimWithModule
|
||||||
nixvimConfiguration
|
nixvimConfiguration
|
||||||
|
|
|
@ -62,7 +62,7 @@ in
|
||||||
lib.nixvim = lib.mkDefault self.lib.nixvim;
|
lib.nixvim = lib.mkDefault self.lib.nixvim;
|
||||||
|
|
||||||
# Make nixvim's "extended" lib available to the host's module args
|
# Make nixvim's "extended" lib available to the host's module args
|
||||||
_module.args.nixvimLib = lib.mkDefault config.lib.nixvim.extendedLib;
|
_module.args.nixvimLib = lib.mkDefault (lib.extend self.lib.overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Propagate nixvim's assertions to the host modules
|
# Propagate nixvim's assertions to the host modules
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue