Skip to content

alugha/lefthook.nix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using lefthook with Nix

Easily manage git hooks with Nix, internally using lefthook.

Usages

Nix Flakes

{
  description = "An example nix flake project";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

    lefthook = {
      url = "github:sudosubin/lefthook.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, lefthook }:
    let
      inherit (nixpkgs.lib) genAttrs platforms;
      forAllSystems = f: genAttrs platforms.unix (system: f (import nixpkgs { inherit system; }));

    in
    {
      checks = forAllSystems (pkgs: {
        lefthook-check = lefthook.lib.${pkgs.system}.run {
          src = ./.;
          config = {
            pre-commit.commands = {
              nixfmt = {
                run = "${pkgs.lib.getExe pkgs.nixfmt-rfc-style} {staged_files}";
                glob = "*.nix";
              };
            };
          };
        };
      });

      devShells = forAllSystems (pkgs: {
        default = pkgs.mkShell {
          inherit (self.checks.${pkgs.system}.lefthook-check) shellHook;
        };
      });
    };
}

Credits

This project was written with a lot of influence from pre-commit-hooks.nix.

About

Using lefthook with Nix

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Nix 100.0%