Skip to content

Commit

Permalink
chore(docs): Add Usages section (Nix Flakes)
Browse files Browse the repository at this point in the history
  • Loading branch information
sudosubin committed Jan 22, 2023
1 parent fcb7f65 commit 4348333
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,54 @@

Easily manage git hooks with Nix, internally using lefthook.

## Usages

### Nix Flakes

```nix
{
description = "An example nix flake project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
lefthook = {
url = "github:sudosubin/lefthook.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self, nixpkgs, flake-utils, lefthook, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
checks = {
lefthook-check = lefthook.lib.${system}.run {
src = ./.;
config = {
pre-commit.commands = {
nixpkgs-fmt = {
run = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt {staged_files}";
glob = "*.nix";
};
};
};
};
};
devShell = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.lefthook-check) shellHook;
};
}
);
}
```

## Credits

This project was written with a lot of influence from [pre-commit-hooks.nix](https://github.com/cachix/pre-commit-hooks.nix).

0 comments on commit 4348333

Please sign in to comment.