ba4e4fa1fc
Add treefmt-nix configuration with Python (ruff, mypy), Nix (nixfmt, deadnix), and JSON/YAML (prettier) formatters. Configure mypy to check pkgs/clan-llm with proper clan_lib dependencies.
73 lines
1.8 KiB
Nix
73 lines
1.8 KiB
Nix
{ inputs, ... }:
|
|
{
|
|
imports = [ inputs.treefmt-nix.flakeModule ];
|
|
perSystem =
|
|
{ self', pkgs, ... }:
|
|
{
|
|
treefmt.projectRootFile = "LICENSE";
|
|
|
|
# Python formatting and linting
|
|
treefmt.programs.ruff.check = true;
|
|
treefmt.programs.ruff.format = true;
|
|
|
|
# Python type checking
|
|
treefmt.programs.mypy.enable = true;
|
|
|
|
# Nix formatting and linting
|
|
treefmt.programs.nixfmt.enable = true;
|
|
treefmt.programs.nixfmt.package = pkgs.nixfmt-rfc-style;
|
|
treefmt.programs.deadnix.enable = true;
|
|
|
|
# File size linting
|
|
treefmt.programs.sizelint.enable = true;
|
|
treefmt.programs.sizelint.failOnWarn = true;
|
|
|
|
# JSON/YAML formatting
|
|
treefmt.programs.prettier = {
|
|
enable = true;
|
|
includes = [
|
|
"*.json"
|
|
"*.json5"
|
|
"*.yaml"
|
|
"*.yml"
|
|
];
|
|
};
|
|
|
|
# Global excludes
|
|
treefmt.settings.global.excludes = [
|
|
# Build artifacts and caches
|
|
"**/.mypy_cache/*"
|
|
"**/__pycache__/*"
|
|
"**/node_modules/*"
|
|
".pythonpath/*"
|
|
|
|
# IDE and editor files
|
|
".vscode/*"
|
|
"*.code-workspace"
|
|
|
|
# Binary and media files
|
|
"*.png"
|
|
"*.svg"
|
|
"*.jpeg"
|
|
|
|
# Generated files
|
|
"trace.json"
|
|
|
|
# Markdown files (preserve formatting)
|
|
"*.md"
|
|
];
|
|
|
|
# Mypy configuration for clan-llm
|
|
# Note: We check the local pkgs/clan-llm directory, which depends on clan-core
|
|
treefmt.programs.mypy.directories = {
|
|
"clan-llm" = {
|
|
directory = "pkgs/clan-llm";
|
|
extraPythonPackages = (self'.packages.default.devshellPyDeps pkgs.python3Packages) ++ [
|
|
# Add clan-cli as a module so imports from clan_lib work
|
|
(pkgs.python3Packages.toPythonModule self'.packages.default)
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|