2024-07-07 15:21:08 -04:00
|
|
|
{ lib, inputs, ... }:
|
2024-05-05 19:39:35 +02:00
|
|
|
{
|
2024-07-07 15:23:09 -04:00
|
|
|
imports =
|
|
|
|
[ ./devshell.nix ]
|
|
|
|
++ lib.optional (inputs.git-hooks ? flakeModule) inputs.git-hooks.flakeModule
|
|
|
|
++ lib.optional (inputs.treefmt-nix ? flakeModule) inputs.treefmt-nix.flakeModule;
|
2023-12-06 13:09:26 +01:00
|
|
|
|
2024-05-05 19:39:35 +02:00
|
|
|
perSystem =
|
2024-07-07 15:21:08 -04:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
2024-09-07 01:01:17 +01:00
|
|
|
system,
|
2024-07-07 15:21:08 -04:00
|
|
|
...
|
|
|
|
}:
|
2024-06-04 16:57:20 +01:00
|
|
|
let
|
|
|
|
fmt = pkgs.nixfmt-rfc-style;
|
|
|
|
in
|
2024-07-07 15:23:09 -04:00
|
|
|
lib.optionalAttrs (inputs.treefmt-nix ? flakeModule) {
|
2024-05-07 16:45:47 +02:00
|
|
|
treefmt.config = {
|
2024-06-04 17:35:37 +01:00
|
|
|
projectRootFile = "flake.nix";
|
2024-09-07 00:27:24 +01:00
|
|
|
flakeCheck = true;
|
2024-05-07 16:45:47 +02:00
|
|
|
|
|
|
|
programs = {
|
2024-08-23 19:39:13 -05:00
|
|
|
isort.enable = true;
|
2024-06-04 16:57:20 +01:00
|
|
|
nixfmt = {
|
|
|
|
enable = true;
|
|
|
|
package = fmt;
|
|
|
|
};
|
2024-07-08 15:54:16 +01:00
|
|
|
prettier = {
|
|
|
|
enable = true;
|
|
|
|
excludes = [ "**.md" ];
|
|
|
|
};
|
2024-07-08 16:13:12 +01:00
|
|
|
ruff = {
|
|
|
|
check = true;
|
|
|
|
format = true;
|
|
|
|
};
|
2024-05-07 16:45:47 +02:00
|
|
|
statix.enable = true;
|
2024-07-08 16:13:45 +01:00
|
|
|
stylua.enable = true;
|
2024-07-20 00:18:36 +02:00
|
|
|
shfmt.enable = true;
|
2024-09-26 10:55:15 -05:00
|
|
|
# FIXME: re-enable on darwin, currently broken: taplo with options '[format]' failed to apply: exit status 101
|
|
|
|
taplo.enable = pkgs.stdenv.isLinux;
|
2024-05-07 16:45:47 +02:00
|
|
|
};
|
2024-07-08 15:54:16 +01:00
|
|
|
|
|
|
|
settings = {
|
|
|
|
global.excludes = [
|
2024-08-31 16:26:04 -05:00
|
|
|
".editorconfig"
|
2024-07-08 16:14:05 +01:00
|
|
|
".envrc"
|
|
|
|
".git-blame-ignore-revs"
|
|
|
|
".gitignore"
|
2024-07-08 15:54:16 +01:00
|
|
|
"LICENSE"
|
|
|
|
"flake.lock"
|
2024-07-08 16:14:05 +01:00
|
|
|
"**.md"
|
|
|
|
"**.scm"
|
|
|
|
"**.svg"
|
|
|
|
"**/man/*.5"
|
2024-09-11 19:12:19 +02:00
|
|
|
# Those files are generated by pytest-regression, which then `diff`s them.
|
|
|
|
# Formatting them will make the tests fail.
|
|
|
|
"docs/gfm-alerts-to-admonitions/tests/**/*.yml"
|
2024-07-08 15:54:16 +01:00
|
|
|
];
|
2024-07-11 14:44:16 +02:00
|
|
|
formatter.ruff-format.options = [ "--isolated" ];
|
2024-07-08 15:54:16 +01:00
|
|
|
};
|
2024-05-07 16:45:47 +02:00
|
|
|
};
|
2024-07-07 15:21:08 -04:00
|
|
|
}
|
|
|
|
// lib.optionalAttrs (inputs.git-hooks ? flakeModule) {
|
2024-05-05 19:39:35 +02:00
|
|
|
pre-commit = {
|
2024-09-07 00:27:24 +01:00
|
|
|
# We have a treefmt check already, so this is redundant.
|
2024-09-07 01:01:17 +01:00
|
|
|
# We also can't run the test if it includes running `nix build`,
|
|
|
|
# since the nix CLI can't build within a derivation builder.
|
2024-09-07 00:27:24 +01:00
|
|
|
check.enable = false;
|
|
|
|
|
2024-05-05 19:39:35 +02:00
|
|
|
settings.hooks = {
|
2024-07-08 16:03:57 +01:00
|
|
|
treefmt.enable = true;
|
2024-10-10 09:35:51 -05:00
|
|
|
typos = {
|
|
|
|
enable = true;
|
|
|
|
excludes = [ "generated/*" ];
|
|
|
|
};
|
2024-09-07 01:01:17 +01:00
|
|
|
maintainers = {
|
|
|
|
enable = true;
|
|
|
|
name = "maintainers";
|
|
|
|
description = "Check maintainers when it is modified.";
|
|
|
|
files = "^lib/maintainers[.]nix$";
|
|
|
|
package = pkgs.nix;
|
|
|
|
entry = "nix build --no-link --print-build-logs";
|
|
|
|
args = [ ".#checks.${system}.maintainers" ];
|
|
|
|
pass_filenames = false;
|
|
|
|
};
|
2024-09-04 16:22:17 +01:00
|
|
|
plugins-by-name = {
|
|
|
|
enable = true;
|
|
|
|
name = "plugins-by-name";
|
|
|
|
description = "Check `plugins/by-name` when it's modified.";
|
|
|
|
files = "^(?:tests/test-sources/)?plugins/by-name/";
|
|
|
|
package = pkgs.nix;
|
|
|
|
entry = "nix build --no-link --print-build-logs";
|
|
|
|
args = [ ".#checks.${system}.plugins-by-name" ];
|
|
|
|
pass_filenames = false;
|
|
|
|
};
|
2024-05-05 19:34:47 +02:00
|
|
|
};
|
2023-12-06 13:09:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|