Skip to content

Commit

Permalink
Merge branch 'master' into cabal2nix
Browse files Browse the repository at this point in the history
  • Loading branch information
rsrohitsingh682 committed Dec 14, 2024
2 parents be16516 + c2b3567 commit 3e13b67
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
21 changes: 20 additions & 1 deletion modules/hook.nix
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,31 @@ in
'';
default = [ ];
};

before = mkOption {
type = types.listOf types.str;
description =
''
List of hooks that should run after this hook.
'';
default = [ ];
};

after = mkOption {
type = types.listOf types.str;
description =
''
List of hooks that should run before this hook.
'';
default = [ ];
};

};

config = {
raw =
{
inherit (config) name entry language files types types_or exclude_types pass_filenames fail_fast require_serial stages verbose always_run args;
inherit (config) name entry language files types types_or exclude_types pass_filenames fail_fast require_serial stages verbose always_run args before after;
id = config.name;
exclude = mergeExcludes config.excludes;
};
Expand Down
16 changes: 15 additions & 1 deletion modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ let
enabledHooks = filterAttrs (id: value: value.enable) cfg.hooks;
enabledExtraPackages = builtins.concatLists (mapAttrsToList (_: value: value.extraPackages) enabledHooks);
processedHooks =
mapAttrsToList (id: value: value.raw // { inherit id; }) enabledHooks;
let
sortedHooks = lib.toposort
(a: b: builtins.elem b.id a.before || builtins.elem a.id b.after)
(mapAttrsToList
(id: value:
value.raw // {
inherit id;
before = value.raw.before;
after = value.raw.after;
}
)
enabledHooks
);
in
sortedHooks.result;

configFile =
performAssertions (
Expand Down

0 comments on commit 3e13b67

Please sign in to comment.