Signed-off-by: Lander Van den Bulcke <landervandenbulcke@gmail.com>
33 lines
776 B
Nix
33 lines
776 B
Nix
{ lib, ... }:
|
|
let
|
|
mapAttrsMaybe =
|
|
f: attrs:
|
|
lib.pipe attrs [
|
|
(lib.mapAttrsToList f)
|
|
(builtins.filter (x: x != null))
|
|
builtins.listToAtts
|
|
];
|
|
forAllNixFiles =
|
|
dir: f:
|
|
if builtins.pathExists dir then
|
|
lib.pipe dir [
|
|
builtins.readDir
|
|
(mapAttrsMaybe (
|
|
fn: type:
|
|
if type == "regular" then
|
|
let
|
|
name = lib.removeSuffix ".nix" fn;
|
|
in
|
|
lib.nameValuePair name (f "${dir}/${fn}")
|
|
else if type == "directory" && builtins.pathExists "${dir}/${fn}/default.nix" then
|
|
lib.nameValuePair fn (f "${dir}/${fn}")
|
|
else
|
|
null
|
|
))
|
|
]
|
|
else
|
|
{ };
|
|
in
|
|
{
|
|
flake.nixvimPlugins = forAllNixFiles ./. (fn: fn);
|
|
}
|