about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--flake.nix42
1 files changed, 40 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix
index 76e6369..d10c736 100644
--- a/flake.nix
+++ b/flake.nix
@@ -52,7 +52,37 @@
         let
           pkgs = import inputs.nixpkgs { inherit system; };
           home-manager = inputs.home-manager.defaultPackage."${system}";
-          ci = import ./ops/ci { inherit pkgs; };
+          pre-commit-golang = pkgs.callPackage
+            ({ stdenv, fetchFromGitHub }:
+              stdenv.mkDerivation rec {
+                pname = "pre-commit-golang";
+                version = "0.5.0-96221dc";
+                src = fetchFromGitHub {
+                  owner = "dnephin";
+                  repo = pname;
+                  rev = "96221dc741cb30cc0136999083dc6bd0e2113000";
+                  sha256 = "sha256-lIQBoT+UIlVGnFaaGBgXag0Lm1UhGj/pIGlCCz91L4I=";
+                };
+                dontBuild = true;
+                dontConfigure = true;
+                installPhase = ''
+                  runHook preInstall
+                  install -d $out
+                  find . -type f -name 'run-*.sh' \
+                  | sed -E 's:^\./run-(.*)\.sh:\1:' \
+                  | xargs -I {} install ./run-{}.sh $out/{}
+                  runHook postInstall
+                '';
+              })
+            { };
+          pre-commit-golang-hook = name: {
+            "${name}" = {
+              inherit name;
+              enable = true;
+              entry = "${pre-commit-golang}/${name}";
+              files = "\\.go$";
+            };
+          };
         in
         rec
         {
@@ -85,10 +115,18 @@
                   enable = true;
                 };
 
+                terraform-format = {
+                  enable = true;
+                };
+
                 shellcheck = {
                   enable = true;
+                  files = "\\.sh$";
+                  types_or = [ "file" ];
                 };
-              };
+              }
+              // (pre-commit-golang-hook "go-fmt")
+              // (pre-commit-golang-hook "go-mod-tidy");
             };
           };