plugins: Fetch the plugin sources from flake inputs (#247)

This commit is contained in:
traxys 2023-03-14 23:48:27 +01:00 committed by GitHub
parent b3ca52110f
commit 416c719f47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 310 additions and 72 deletions

View file

@ -75,7 +75,10 @@
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
alejandra = {
enable = true;
excludes = ["plugins/_sources"];
};
};
};
};
@ -114,6 +117,8 @@
'';
})
{};
# Used to updates plugins, launch 'nix run .#nvfetcher' in the 'plugins' directory
nvfetcher = pkgs.nvfetcher;
};
legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
@ -124,7 +129,33 @@
};
};
};
formatter = pkgs.alejandra;
formatter = let
# We need to exclude the plugins/_sources/* files as they are autogenerated
# nix formatter only takes a derivation so we need to make a proxy that passes
# the correct flags
excludeWrapper = {
stdenv,
alejandra,
writeShellScript,
...
}:
stdenv.mkDerivation {
pname = "alejandra-excludes";
version = alejandra.version;
dontUnpack = true;
dontBuild = true;
installPhase = let
script = writeShellScript "alejandra-excludes.sh" ''
${alejandra}/bin/alejandra --exclude ./plugins/_sources "$@"
'';
in ''
mkdir -p $out/bin
cp ${script} $out/bin/alejandra-excludes
'';
};
in
pkgs.callPackage excludeWrapper {};
lib = import ./lib {
inherit pkgs;