mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
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:
parent
f47e8f8f79
commit
4e5bd1d79b
12 changed files with 165 additions and 84 deletions
|
@ -6,6 +6,8 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
builders = lib.nixvim.builders.withPkgs pkgs;
|
||||
|
||||
fileTypeModule =
|
||||
{
|
||||
name,
|
||||
|
@ -73,10 +75,10 @@ let
|
|||
then
|
||||
if lib.isDerivation config.source then
|
||||
# Source is a derivation
|
||||
helpers.byteCompileLuaDrv config.source
|
||||
builders.byteCompileLuaDrv config.source
|
||||
else
|
||||
# Source is a path or string
|
||||
helpers.byteCompileLuaFile derivationName config.source
|
||||
builders.byteCompileLuaFile derivationName config.source
|
||||
else
|
||||
config.source;
|
||||
};
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
@ -18,7 +17,8 @@
|
|||
config =
|
||||
let
|
||||
derivationName = "nvim-" + lib.replaceStrings [ "/" ] [ "-" ] name;
|
||||
writeContent = if config.type == "lua" then helpers.writeLua else pkgs.writeText;
|
||||
writeContent =
|
||||
if config.type == "lua" then lib.nixvim.builders.writeLuaWith pkgs else pkgs.writeText;
|
||||
in
|
||||
{
|
||||
path = lib.mkDefault name;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
let
|
||||
inherit (lib) types mkOption mkPackageOption;
|
||||
inherit (lib) optional optionalString optionalAttrs;
|
||||
builders = lib.nixvim.builders.withPkgs pkgs;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
@ -91,7 +92,7 @@ in
|
|||
let
|
||||
byteCompile =
|
||||
p:
|
||||
(helpers.byteCompileLuaDrv p).overrideAttrs (
|
||||
(builders.byteCompileLuaDrv p).overrideAttrs (
|
||||
prev: lib.optionalAttrs (prev ? dependencies) { dependencies = map byteCompile prev.dependencies; }
|
||||
);
|
||||
in
|
||||
|
@ -223,8 +224,8 @@ in
|
|||
config.content
|
||||
];
|
||||
|
||||
textInit = helpers.writeLua "init.lua" customRC;
|
||||
byteCompiledInit = helpers.writeByteCompiledLua "init.lua" customRC;
|
||||
textInit = builders.writeLua "init.lua" customRC;
|
||||
byteCompiledInit = builders.writeByteCompiledLua "init.lua" customRC;
|
||||
init =
|
||||
if
|
||||
config.type == "lua"
|
||||
|
@ -250,7 +251,7 @@ in
|
|||
paths = [ config.package ];
|
||||
# Required attributes from original neovim package
|
||||
inherit (config.package) lua meta;
|
||||
nativeBuildInputs = [ helpers.byteCompileLuaHook ];
|
||||
nativeBuildInputs = [ builders.byteCompileLuaHook ];
|
||||
postBuild = ''
|
||||
# Replace Nvim's binary symlink with a regular file,
|
||||
# or Nvim will use original runtime directory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue