mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-03 09:36:10 +02:00
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.
62 lines
1.5 KiB
Nix
62 lines
1.5 KiB
Nix
default_pkgs: self:
|
|
{
|
|
pkgs ? default_pkgs,
|
|
extraSpecialArgs ? { },
|
|
_nixvimTests ? false,
|
|
module,
|
|
}:
|
|
let
|
|
inherit (pkgs) lib;
|
|
|
|
helpers = import ../lib/helpers.nix { inherit pkgs lib _nixvimTests; };
|
|
|
|
handleAssertions =
|
|
config:
|
|
let
|
|
failedAssertions = map (x: x.message) (lib.filter (x: !x.assertion) config.assertions);
|
|
in
|
|
if failedAssertions != [ ] then
|
|
throw "\nFailed assertions:\n${builtins.concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"
|
|
else
|
|
lib.showWarnings config.warnings config;
|
|
|
|
mkNvim =
|
|
mod:
|
|
let
|
|
evaledModule = lib.evalModules {
|
|
modules = [
|
|
mod
|
|
./modules/standalone.nix
|
|
../modules/top-level
|
|
];
|
|
specialArgs = {
|
|
inherit helpers;
|
|
lib = helpers.extendedLib;
|
|
defaultPkgs = pkgs;
|
|
} // extraSpecialArgs;
|
|
};
|
|
config = handleAssertions evaledModule.config;
|
|
in
|
|
(pkgs.symlinkJoin {
|
|
name = "nixvim";
|
|
paths = [
|
|
config.finalPackage
|
|
config.printInitPackage
|
|
] ++ pkgs.lib.optional config.enableMan self.packages.${pkgs.stdenv.hostPlatform.system}.man-docs;
|
|
meta.mainProgram = "nvim";
|
|
})
|
|
// rec {
|
|
inherit config;
|
|
inherit (evaledModule) options;
|
|
extend =
|
|
extension:
|
|
mkNvim {
|
|
imports = [
|
|
mod
|
|
extension
|
|
];
|
|
};
|
|
nixvimExtend = lib.warn "<nixvim>.nixvimExtend has been renamed to <nixvim>.extend" extend;
|
|
};
|
|
in
|
|
mkNvim module
|