2024-03-17 18:48:49 +00:00
|
|
|
{ lib, inputs, ... }:
|
|
|
|
{
|
|
|
|
imports = [ inputs.treefmt-nix.flakeModule ];
|
|
|
|
perSystem =
|
|
|
|
{ self', pkgs, ... }:
|
|
|
|
{
|
|
|
|
treefmt.projectRootFile = "flake.nix";
|
|
|
|
treefmt.programs.shellcheck.enable = true;
|
2023-08-23 10:32:06 +00:00
|
|
|
|
2024-03-17 18:48:49 +00:00
|
|
|
treefmt.programs.mypy.enable = true;
|
|
|
|
treefmt.programs.mypy.directories = {
|
2024-03-24 22:36:00 +00:00
|
|
|
"pkgs/clan-cli".extraPythonPackages = self'.packages.clan-cli.testDependencies;
|
2024-06-05 09:23:12 +00:00
|
|
|
"pkgs/clan-app".extraPythonPackages =
|
|
|
|
# clan-app currently only exists on linux
|
|
|
|
(self'.packages.clan-app.externalTestDeps or [ ]) ++ self'.packages.clan-cli.testDependencies;
|
2024-03-17 18:48:49 +00:00
|
|
|
};
|
2023-08-23 10:32:06 +00:00
|
|
|
|
2024-03-17 18:48:49 +00:00
|
|
|
treefmt.settings.formatter.nix = {
|
|
|
|
command = "sh";
|
|
|
|
options = [
|
|
|
|
"-eucx"
|
|
|
|
''
|
|
|
|
# First deadnix
|
|
|
|
${lib.getExe pkgs.deadnix} --edit "$@"
|
|
|
|
# Then nixpkgs-fmt
|
|
|
|
${lib.getExe pkgs.nixfmt-rfc-style} "$@"
|
|
|
|
''
|
|
|
|
"--" # this argument is ignored by bash
|
|
|
|
];
|
|
|
|
includes = [ "*.nix" ];
|
|
|
|
excludes = [
|
|
|
|
# Was copied from nixpkgs. Keep diff minimal to simplify upstreaming.
|
|
|
|
"pkgs/builders/script-writers.nix"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
treefmt.settings.formatter.python = {
|
|
|
|
command = "sh";
|
|
|
|
options = [
|
|
|
|
"-eucx"
|
|
|
|
''
|
2024-03-26 11:45:26 +00:00
|
|
|
${lib.getExe pkgs.ruff} check --fix "$@"
|
2024-03-17 18:48:49 +00:00
|
|
|
${lib.getExe pkgs.ruff} format "$@"
|
|
|
|
''
|
|
|
|
"--" # this argument is ignored by bash
|
|
|
|
];
|
|
|
|
includes = [ "*.py" ];
|
|
|
|
};
|
2024-05-15 16:37:05 +00:00
|
|
|
treefmt.settings.formatter.vale =
|
|
|
|
with pkgs;
|
|
|
|
let
|
|
|
|
vocab = "cLAN";
|
|
|
|
style = "Docs";
|
|
|
|
config = writeText "vale.ini" ''
|
|
|
|
StylesPath = ${styles}
|
|
|
|
Vocab = ${vocab}
|
|
|
|
|
|
|
|
[*.md]
|
|
|
|
BasedOnStyles = Vale, ${style}
|
|
|
|
Vale.Terms = No
|
|
|
|
'';
|
|
|
|
styles = symlinkJoin {
|
|
|
|
name = "vale-style";
|
|
|
|
paths = [
|
|
|
|
accept
|
|
|
|
headings
|
|
|
|
];
|
|
|
|
};
|
|
|
|
accept = writeTextDir "config/vocabularies/${vocab}/accept.txt" ''
|
|
|
|
Nix
|
|
|
|
NixOS
|
|
|
|
Nixpkgs
|
|
|
|
clan.lol
|
|
|
|
Clan
|
|
|
|
monorepo
|
|
|
|
'';
|
|
|
|
headings = writeTextDir "${style}/headings.yml" ''
|
|
|
|
extends: capitalization
|
|
|
|
message: "'%s' should be in sentence case"
|
|
|
|
level: error
|
|
|
|
scope: heading
|
|
|
|
# $title, $sentence, $lower, $upper, or a pattern.
|
|
|
|
match: $sentence
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
command = "${vale}/bin/vale";
|
|
|
|
options = [ "--config=${config}" ];
|
|
|
|
includes = [ "*.md" ];
|
|
|
|
# TODO: too much at once, fix piecemeal
|
|
|
|
excludes = [
|
|
|
|
"docs/*"
|
|
|
|
"clanModules/*"
|
|
|
|
"pkgs/*"
|
|
|
|
];
|
|
|
|
};
|
2023-07-21 09:21:09 +00:00
|
|
|
};
|
2023-07-12 17:00:09 +00:00
|
|
|
}
|