Skip to content

Commit 235f262

Browse files
avnikbrainrake
authored andcommitted
feat: Add pre-commit-hooks.nix
1 parent e910203 commit 235f262

File tree

4 files changed

+116
-1
lines changed

4 files changed

+116
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.direnv
2+
.pre-commit-config.yaml
23

34
# docs-serve stuff
45
/mkdocs.yml

flake.lock

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

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
url = "github:zhaofengli/attic";
2525
inputs.nixpkgs.follows = "nixpkgs";
2626
};
27+
pre-commit-hooks-nix = {
28+
url = "github:cachix/pre-commit-hooks.nix";
29+
inputs.nixpkgs.follows = "nixpkgs";
30+
inputs.nixpkgs-stable.follows = "nixpkgs"; # prevent unnecessary download
31+
};
2732
};
2833
outputs = inputs @ {flake-parts, ...}:
2934
flake-parts.lib.mkFlake {

shell/default.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
{inputs, ...}: {
1+
{
2+
inputs,
3+
lib,
4+
...
5+
}: {
26
imports = [
37
inputs.devshell.flakeModule
8+
inputs.pre-commit-hooks-nix.flakeModule
49
];
510

611
perSystem = {
@@ -15,12 +20,19 @@
1520
❄️ Welcome to the {14}{bold}cardano.nix{reset} devshell ❄️
1621
$(type -p menu &>/dev/null && menu)
1722
'';
23+
startup = {
24+
pre-commit = lib.noDepEntry "eval ${config.pre-commit.installationScript}";
25+
};
1826
};
1927
packages = with pkgs; [
2028
statix
2129
config.treefmt.build.wrapper
2230
reuse
2331
];
2432
};
33+
pre-commit.settings = {
34+
hooks.treefmt.enable = true;
35+
settings.treefmt.package = config.treefmt.build.wrapper;
36+
};
2537
};
2638
}

0 commit comments

Comments
 (0)