Integrate pre-commit.
This commit is contained in:
parent
acb5021913
commit
6a69e169b5
9 changed files with 235 additions and 86 deletions
47
flake.nix
47
flake.nix
|
@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue