Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: standardizes the plugin interface #10

Merged
merged 14 commits into from
Jun 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: dynamically loads plugins from root directory
  • Loading branch information
jmgilman committed Jun 7, 2022
commit fb23da8bd7da63ddc3740a187074cdc79ce7a4cf
34 changes: 15 additions & 19 deletions plugins/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
{ pkgs, lib }:
{
/* https://github.com/siderolabs/conform
*/
conform = import ./conform { inherit pkgs lib; };
with pkgs.lib;
let
# Build a list of all local directory names (same as plugin name)
plugins = builtins.attrNames
(filterAttrs (n: v: v == "directory") (builtins.readDir ./.));

/* https://github.com/casey/just
*/
just = import ./just { inherit pkgs lib; };
# Create a list of pluginName => import for each plugin
pluginsList = builtins.map
(p: {
"${p}" = import (builtins.toPath ./. + "/${p}") { inherit pkgs lib; };
})
plugins;

/* https://github.com/evilmartians/lefthook
*/
lefthook = import ./lefthook { inherit pkgs lib; };

/* https://github.com/pre-commit/pre-commit
*/
pre-commit = import ./pre-commit { inherit pkgs lib; };

/* https://github.com/prettier/prettier
*/
prettier = import ./prettier { inherit pkgs lib; };
}
# Fold the list back into a single set
pluginsAttrs = fold (x: y: pkgs.lib.recursiveUpdate x y) { } pluginsList;
in
pluginsAttrs