Skip to content

Commit

Permalink
feat: adding pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
huuff committed Sep 14, 2024
1 parent a985b37 commit facc28b
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 2 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.direnv
/.pre-commit-config.yaml
155 changes: 155 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
systems.url = "github:nix-systems/x86_64-linux";
utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
};

outputs = { ... }: {
outputs = { self, nixpkgs, utils, pre-commit-hooks, ... }: {

templates = {
rust = {
Expand All @@ -17,6 +23,22 @@
description = "Rust tools, rust analyzer, sass, wasm and leptos tooling";
};
};
} // utils.lib.eachDefaultSystem (system: {
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
};
};
};

devShells = {
default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
};
};
});

};
}

0 comments on commit facc28b

Please sign in to comment.