1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-11 05:39:44 +01:00
home-manager/modules/programs/ruff.nix
Gaetan Lepage d94b28d6ff
ruff: add module
ruff is Python linter and code formatter, written in Rust.
See <https://docs.astral.sh/ruff/>.
2024-04-10 21:26:42 +02:00

45 lines
1,016 B
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.ruff;
settingsFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ hm.maintainers.GaetanLepage ];
options.programs.ruff = {
enable = mkEnableOption
"ruff, an extremely fast Python linter and code formatter, written in Rust";
package = mkPackageOption pkgs "ruff" { };
settings = mkOption {
type = settingsFormat.type;
example = lib.literalExpression ''
{
line-length = 100;
per-file-ignores = { "__init__.py" = [ "F401" ]; };
lint = {
select = [ "E4" "E7" "E9" "F" ];
ignore = [ ];
};
}
'';
description = ''
Ruff configuration.
For available settings see <https://docs.astral.sh/ruff/settings>.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."ruff/ruff.toml".source =
settingsFormat.generate "ruff.toml" cfg.settings;
};
}