From e32d5ec84d02fdc5a4f891be768ad8adbef254ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Mon, 11 Nov 2024 17:22:15 +0100 Subject: [PATCH] Add pre-commit hooks for formatting and dead code --- .gitignore | 1 + flake.lock | 121 ++++++++++++++++++++++++++++++++++++++++++++++------- flake.nix | 16 ++++++- 3 files changed, 121 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index bb134c56..d52229cd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tmp/ *.iso result .proxmox +.pre-commit-config.yaml diff --git a/flake.lock b/flake.lock index 6716be5c..b08aa2bc 100644 --- a/flake.lock +++ b/flake.lock @@ -54,7 +54,7 @@ }, "disko_2": { "inputs": { - "nixpkgs": "nixpkgs_5" + "nixpkgs": "nixpkgs_6" }, "locked": { "lastModified": 1727347829, @@ -166,6 +166,22 @@ "type": "github" } }, + "flake-compat_4": { + "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": "nixpkgs-lib" @@ -264,6 +280,48 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1730814269, + "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "d70155fdc00df4628446352fc58adc640cd705c2", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "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" + } + }, "libgit2": { "flake": false, "locked": { @@ -330,7 +388,7 @@ }, "nix": { "inputs": { - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "flake-parts": "flake-parts_3", "libgit2": "libgit2", "nixpkgs": [ @@ -412,7 +470,7 @@ }, "nix_2": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_4", "flake-parts": "flake-parts_5", "libgit2": "libgit2_2", "nixpkgs": [ @@ -443,7 +501,7 @@ "flake-parts": "flake-parts_2", "nix": "nix", "nix-cargo-integration": "nix-cargo-integration", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1729771744, @@ -464,7 +522,7 @@ "flake-parts": "flake-parts_4", "nix": "nix_2", "nix-cargo-integration": "nix-cargo-integration_2", - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_4" }, "locked": { "lastModified": 1727424043, @@ -612,18 +670,34 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs-stable": { "locked": { - "lastModified": 1724819573, - "narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=", + "lastModified": 1730741070, + "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "71e91c409d1e654808b2621f28a327acfdad8dc2", + "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1730958623, + "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "85f7e662eda4fa3a995556527c87b2524b691933", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -645,6 +719,22 @@ } }, "nixpkgs_4": { + "locked": { + "lastModified": 1724819573, + "narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "71e91c409d1e654808b2621f28a327acfdad8dc2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { "locked": { "lastModified": 1727672256, "narHash": "sha256-9/79hjQc9+xyH+QxeMcRsA6hDyw6Z9Eo1/oxjvwirLk=", @@ -660,7 +750,7 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { "lastModified": 1725194671, "narHash": "sha256-tLGCFEFTB5TaOKkpfw3iYT9dnk4awTP/q4w+ROpMfuw=", @@ -676,7 +766,7 @@ "type": "github" } }, - "nixpkgs_6": { + "nixpkgs_7": { "locked": { "lastModified": 1730137230, "narHash": "sha256-0kW6v0alzWIc/Dc/DoVZ7A9qNScv77bj/zYTKI67HZM=", @@ -825,7 +915,7 @@ }, "purescript-overlay": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "nixpkgs": [ "nixops4", "nix-cargo-integration", @@ -910,9 +1000,10 @@ "inputs": { "disko": "disko", "flake-parts": "flake-parts", + "git-hooks": "git-hooks", "nixops4": "nixops4", "nixops4-nixos": "nixops4-nixos", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_5", "snf": "snf" } }, @@ -999,7 +1090,7 @@ "snf": { "inputs": { "disko": "disko_2", - "nixpkgs": "nixpkgs_6", + "nixpkgs": "nixpkgs_7", "nixpkgs-latest": "nixpkgs-latest", "pixelfed": "pixelfed" }, diff --git a/flake.nix b/flake.nix index 2e029e00..77299be5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; flake-parts.url = "github:hercules-ci/flake-parts"; + git-hooks.url = "github:cachix/git-hooks.nix"; # snf.url = "path:/home/niols/git/fediversity/simple-nixos-fediverse"; #dev snf.url = "git+https://git.fediversity.eu/fediversity/simple-nixos-fediverse.git"; @@ -21,7 +22,10 @@ }: flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ inputs.nixops4-nixos.modules.flake.default ]; + imports = [ + inputs.nixops4-nixos.modules.flake.default + inputs.git-hooks.flakeModule + ]; systems = [ "x86_64-linux" @@ -42,7 +46,15 @@ { formatter = pkgs.nixfmt-rfc-style; - devShells.default = pkgs.mkShell { packages = [ inputs'.nixops4.packages.default ]; }; + pre-commit.settings.hooks = { + nixfmt-rfc-style.enable = true; + deadnix.enable = true; + }; + + devShells.default = pkgs.mkShell { + packages = [ inputs'.nixops4.packages.default ]; + shellHook = config.pre-commit.installationScript; + }; }; flake.vmIdTo03d =