Skip to content

Commit 17fc048

Browse files
committed
refactor(nix): remove flakeModule in favour of direct lib usage
Replace git-hooks.flakeModule and treefmt-nix.flakeModule imports with direct usage of treefmt-nix.lib.evalModule and git-hooks.lib.${system}.run. This approach is cleaner and avoids the implicit module system overhead while maintaining the same functionality: - treefmt formatting with nixfmt, ruff, and oxfmt - pre-commit hooks for gitleaks, treefmt, and ty - formatter output for nix fmt
1 parent bf9f3fb commit 17fc048

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,10 @@
2222
"aarch64-darwin"
2323
];
2424

25-
imports = [
26-
git-hooks.flakeModule
27-
treefmt-nix.flakeModule
28-
];
29-
3025
perSystem =
31-
{
32-
config,
33-
pkgs,
34-
...
35-
}:
36-
{
37-
# Treefmt configuration for formatting
38-
treefmt = {
26+
{ pkgs, system, ... }:
27+
let
28+
treefmtEval = treefmt-nix.lib.evalModule pkgs {
3929
projectRootFile = "flake.nix";
4030
programs = {
4131
nixfmt.enable = true;
@@ -62,10 +52,9 @@
6252
};
6353
};
6454

65-
# Git hooks configuration
66-
pre-commit = {
67-
check.enable = false; # Skip check in flake (ty needs Python env)
68-
settings.hooks = {
55+
pre-commit-check = git-hooks.lib.${system}.run {
56+
src = ./.;
57+
hooks = {
6958
gitleaks = {
7059
enable = true;
7160
name = "gitleaks";
@@ -75,7 +64,7 @@
7564
};
7665
treefmt = {
7766
enable = true;
78-
package = config.treefmt.build.wrapper;
67+
package = treefmtEval.config.build.wrapper;
7968
};
8069
ty = {
8170
enable = true;
@@ -87,6 +76,9 @@
8776
};
8877
};
8978
};
79+
in
80+
{
81+
formatter = treefmtEval.config.build.wrapper;
9082

9183
devShells.default = pkgs.mkShellNoCC {
9284
buildInputs = with pkgs; [
@@ -120,7 +112,7 @@
120112
fi
121113
122114
# Install git hooks
123-
${config.pre-commit.installationScript}
115+
${pre-commit-check.shellHook}
124116
'';
125117
};
126118
};

0 commit comments

Comments
 (0)