feat: can give dependencies to new package

LeMarsu 2024-05-22 03:25:06 +02:00
parent 2ea188c185
commit 7b26400707
2 changed files with 50 additions and 5 deletions

View File

@ -17,11 +17,10 @@
utils,
alejandra,
...
} @ inputs: let
in
} @ inputs:
utils.lib.mkFlake {
inherit self inputs;
outputsBuilder = channel: let
outputsBuilder = channel: let
system = channel.nixpkgs.system;
in {
formatter = alejandra.defaultPackage.${channel.nixpkgs.system};
@ -31,6 +30,6 @@
};
};
lib = import ./lib.nix { inherit nixpkgs; };
lib = import ./lib.nix;
};
}

48
lib.nix
View File

@ -1,4 +1,50 @@
{...}: {
{
mkNeovimPkg = {
pkgs,
package ? pkgs.neovim-unwrapped,
namePrefix ? "",
nameSuffix ? "",
dependencies ? [],
dependenciesExtraArgs ? {},
customRC ? "",
...
}: let
inherit (builtins) isPath;
inherit (pkgs) lib;
callPackage = lib.callPackageWith (pkgs // dependenciesExtraArgs);
inherit (lib.lists) concatMap;
inherit (lib.attrsets) attrNames;
# inherit (lib.debug) traceIf traceSeq traceVal traceValSeq traceValFn;
remotePluginToNeovimPlugin = p:
pkgs.vimUtils.buildVimPlugin rec {
inherit (p) src name;
pname = name;
};
mkDep = dep:
if isPath dep
then mkDependencies (callPackage dep {})
else if dep ? plugin
then let
inherit (dep) plugin;
in
if attrNames plugin == ["name" "src"]
then [(remotePluginToNeovimPlugin plugin)]
else [plugin]
else [dep];
mkDependencies = concatMap mkDep;
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
inherit customRC;
plugins = mkDependencies dependencies;
};
pkg = pkgs.wrapNeovimUnstable package neovimConfig;
# TODO nameSuffix is buggy :'(
name = "${namePrefix}${pkg.name}${nameSuffix}";
in
pkg // {inherit name;};
mkNeovimModule = {
pluginsDir ? null,
attrName ? "neoflake",