Integrate pre-commit.

This commit is contained in:
Nolan Darilek 2025-07-18 10:28:34 -04:00
parent acb5021913
commit 6a69e169b5
9 changed files with 235 additions and 86 deletions

View file

@ -9,6 +9,10 @@
};
agenix.url = "github:ryantm/agenix";
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-25.05";
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
@ -19,11 +23,12 @@
nixos-hardware,
agenix,
simple-nixos-mailserver,
git-hooks,
...
}:
let
system = "x86_64-linux";
overlayUnstable = final: prev: {
overlayUnstable = _final: _prev: {
unstable = import nixpkgsUnstable {
inherit system;
config.allowUnfree = true;
@ -37,12 +42,9 @@
{
environment.systemPackages = [ agenix.packages.${system}.default ];
}
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = [ overlayUnstable ];
}
)
{
nixpkgs.overlays = [ overlayUnstable ];
}
];
# Common home-manager modules
@ -71,7 +73,7 @@
++ [ hostPath ];
};
in
{
rec {
nixosConfigurations = {
nixbox = mkHost {
hostPath = ./hosts/nixbox;
@ -94,5 +96,34 @@
specialArgs = { inherit inputs; };
};
};
checks.${system} = {
pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
# Check formatting of flake.nix
nixfmt-rfc-style = {
enable = true;
files = "^flake\\.nix$";
};
# Check for dead code in flake.nix
deadnix = {
enable = true;
files = "^flake\\.nix$";
};
# Flake-specific checks
flake-checker.enable = true;
};
};
};
devShells.${system}.default =
let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.mkShell {
inherit (checks.${system}.pre-commit-check) shellHook;
buildInputs = checks.${system}.pre-commit-check.enabledPackages;
};
};
}