diff --git a/.gitignore b/.gitignore index ff33889..4175c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /.direnv /book /.sops.yaml +/.pre-commit-config.yaml diff --git a/flake.lock b/flake.lock index e80cebb..497da3a 100644 --- a/flake.lock +++ b/flake.lock @@ -191,6 +191,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -266,7 +282,50 @@ "type": "github" } }, + "git-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1740915799, + "narHash": "sha256-JvQvtaphZNmeeV+IpHgNdiNePsIpHD5U/7QN5AeY44A=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "42b1ba089d2034d910566bf6b40830af6b8ec732", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gitignore_2": { "inputs": { "nixpkgs": [ "lanzaboote", @@ -343,7 +402,7 @@ "lanzaboote": { "inputs": { "crane": "crane", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "flake-parts": "flake-parts_3", "nixpkgs": [ "nixpkgs" @@ -462,7 +521,7 @@ "lanzaboote", "flake-compat" ], - "gitignore": "gitignore", + "gitignore": "gitignore_2", "nixpkgs": [ "lanzaboote", "nixpkgs" @@ -505,6 +564,7 @@ "ez-configs": "ez-configs", "fcc-unlock": "fcc-unlock", "flake-parts": "flake-parts_2", + "git-hooks-nix": "git-hooks-nix", "home-manager": "home-manager", "lanzaboote": "lanzaboote", "nixos-facter-modules": "nixos-facter-modules", diff --git a/flake.nix b/flake.nix index 6e4c9f2..693569f 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,10 @@ flake-parts.follows = "flake-parts"; }; }; + git-hooks-nix = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; home-manager = { @@ -60,12 +64,14 @@ imports = map (name: inputs.${name}.flakeModule) [ "treefmt-nix" "ez-configs" + "git-hooks-nix" ]; systems = [ "x86_64-linux" ]; perSystem = { + config, pkgs, lib, self', @@ -82,6 +88,13 @@ }; settings.global.excludes = [ "*.jpg" ]; }; + pre-commit = { + check.enable = false; + settings.hooks.treefmt = { + enable = true; + always_run = true; + }; + }; checks = with lib; @@ -107,6 +120,9 @@ nixd ; }; + shellHook = '' + ${config.pre-commit.installationScript} + ''; }; };