Valentin Gagarin
055b17c01b
make sure things are sane before they hit CI, re-purposing the existing
treefmt configuration.
this adds a custom installer for pre-commit hooks, which is inspired by
pre-commit.nix[0], but is much more minimal than the underlying
pre-commit[1] and builds on a historic idea[2] from this repository.
[0]: https://github.com/cachix/git-hooks.nix
[1]: https://github.com/pre-commit/pre-commit
[2]: 930923512c
51 lines
1.4 KiB
Nix
51 lines
1.4 KiB
Nix
{ inputs, ... }:
|
|
{
|
|
perSystem =
|
|
{
|
|
pkgs,
|
|
self',
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
writers = pkgs.callPackage ./pkgs/builders/script-writers.nix { };
|
|
inherit (pkgs.callPackage inputs.git-hooks { }) lib;
|
|
|
|
ansiEscapes = {
|
|
reset = ''\033[0m'';
|
|
green = ''\033[32m'';
|
|
};
|
|
|
|
# A python program to switch between dev-shells
|
|
# usage: select-shell shell-name
|
|
# the currently enabled dev-shell gets stored in ./.direnv/selected-shell
|
|
select-shell = writers.writePython3Bin "select-shell" {
|
|
flakeIgnore = [ "E501" ];
|
|
} ./pkgs/scripts/select-shell.py;
|
|
|
|
# run treefmt before each commit
|
|
install-pre-commit-hook =
|
|
with lib.git-hooks;
|
|
pre-commit (wrap.abort-on-change config.treefmt.build.wrapper);
|
|
in
|
|
{
|
|
devShells.default = pkgs.mkShell {
|
|
packages = [
|
|
select-shell
|
|
pkgs.tea
|
|
pkgs.nix
|
|
self'.packages.tea-create-pr
|
|
self'.packages.merge-after-ci
|
|
self'.packages.pending-reviews
|
|
# treefmt with config defined in ./flake-parts/formatting.nix
|
|
config.treefmt.build.wrapper
|
|
];
|
|
shellHook = ''
|
|
${install-pre-commit-hook}
|
|
|
|
echo -e "${ansiEscapes.green}switch to another dev-shell using: select-shell${ansiEscapes.reset}"
|
|
'';
|
|
};
|
|
};
|
|
}
|