feat: add pre-commit-hooks

This commit is contained in:
Julien Malka 2024-04-07 14:33:13 +02:00
parent b7f553f3ec
commit ec1fa9b3b8
Signed by: Luj
GPG key ID: 6FC74C847011FD83
3 changed files with 56 additions and 5 deletions

26
deps/sources.json vendored
View file

@ -62,6 +62,18 @@
"url": "https://api.github.com/repos/nix-community/disko/tarball/v1.5.0",
"hash": "1d03a0wb710by1m2c3rx758vy67f8r71gnv2h3qn4jj1bx10sdg4"
},
"git-hooks": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "cachix",
"repo": "git-hooks.nix"
},
"branch": "master",
"revision": "e35aed5fda3cc79f88ed7f1795021e559582093a",
"url": "https://github.com/cachix/git-hooks.nix/archive/e35aed5fda3cc79f88ed7f1795021e559582093a.tar.gz",
"hash": "1bq0yrjmkddj964s2q6393nwp4mqrlmc2i5wsy992r034awyywp1"
},
"home-manager": {
"type": "Git",
"repository": {
@ -98,6 +110,18 @@
"url": "https://github.com/JulienMalka/homepage/archive/29e779d8600b1c1e6235570a3614a54f8ec8126e.tar.gz",
"hash": "0prma1rg6glf3xy1dkd6gbzb26z1sxkgzd8wr623pbqvf44hgv32"
},
"impermanence": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "impermanence"
},
"branch": "master",
"revision": "a33ef102a02ce77d3e39c25197664b7a636f9c30",
"url": "https://github.com/nix-community/impermanence/archive/a33ef102a02ce77d3e39c25197664b7a636f9c30.tar.gz",
"hash": "1mig6ns8l5iynsm6pfbnx2b9hmr592s1kqbw6gq1n25czdlcniam"
},
"lanzaboote": {
"type": "Git",
"repository": {
@ -209,4 +233,4 @@
}
},
"version": 3
}
}

View file

@ -1,12 +1,35 @@
let
inputs = import ./deps;
pkgs = import inputs.nixpkgs { };
pkgs = import inputs.unstable { };
nixos-anywhere = pkgs.callPackage "${inputs.nixos-anywhere}/src/default.nix" { };
agenix = pkgs.callPackage "${inputs.agenix}/pkgs/agenix.nix" { };
bootstrap = import scripts/bootstrap-machine.nix;
pre-commit-hook = (import inputs.git-hooks).run {
src = ./.;
hooks = {
statix.enable = true;
deadnix.enable = true;
rfc101 = {
enable = true;
name = "RFC-101 formatting";
entry = "${pkgs.lib.getExe pkgs.nixfmt-rfc-style}";
files = "\\.nix$";
};
commitizen.enable = true;
};
};
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [ colmena npins nixos-anywhere agenix bootstrap ];
nativeBuildInputs = with pkgs; [
colmena
npins
nixos-anywhere
agenix
bootstrap
statix
];
shellHook = ''
${pre-commit-hook.shellHook}
'';
}

4
statix.toml Normal file
View file

@ -0,0 +1,4 @@
disabled = [
"repeated_keys"
]