Skip to content

Commit

Permalink
Added nix check and pre commit hook for formatting (nix-community#220)
Browse files Browse the repository at this point in the history
* Added nix check and pre commit hook for formatting

* Removed nix fmt check from CI
  • Loading branch information
Alexnortung authored Mar 6, 2023
1 parent c5f31f5 commit 2c333c8
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use_flake() {
watch_file flake.nix
watch_file flake.lock
eval "$(nix print-dev-env --profile "$(direnv_layout_dir)/flake-profile")"
}

use flake
1 change: 0 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ jobs:
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix flake check
- run: nix fmt -- -c .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.tmp
result
.pre-commit-config.yaml
95 changes: 94 additions & 1 deletion flake.lock

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

24 changes: 21 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
inputs.beautysh.url = "github:lovesegfault/beautysh";
inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs";

inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";

outputs = {
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
...
} @ inputs:
with nixpkgs.lib;
Expand Down Expand Up @@ -62,9 +66,23 @@
};
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {};
in {
checks = import ./tests/checks.nix {
inherit pkgs;
makeNixvim = self.legacyPackages."${system}".makeNixvim;
checks =
(import ./tests/checks.nix {
inherit pkgs;
makeNixvim = self.legacyPackages."${system}".makeNixvim;
})
// {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
};
};
};
devShells = {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
};
packages = {
docs = pkgs.callPackage (import ./docs.nix) {
Expand Down

0 comments on commit 2c333c8

Please sign in to comment.