-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathruff.nix
49 lines (46 loc) · 1.25 KB
/
ruff.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ lib, pkgs, config, ... }:
let
cfg = config.programs.ruff;
in
{
imports = [
(lib.mkRenamedOptionModule [ "programs" "ruff" "enable" ] [ "programs" "ruff" "check" ])
];
meta.maintainers = [ ];
options.programs.ruff = {
package = lib.mkPackageOption pkgs "ruff" { };
check = lib.mkEnableOption "ruff linter" // {
description = ''
Whether to enable the Ruff linter, an extremely fast Python linter
designed as a drop-in replacement for Flake8 (plus dozens of plugins),
isort, pydocstyle, pyupgrade, autoflake, and more.
'';
};
format = lib.mkEnableOption "ruff formatter" // {
description = ''
Whether to enable the Ruff formatter, an extremely fast Python code formatter
designed as a drop-in replacement for Black.
'';
};
};
config = {
settings.formatter = {
ruff-check = lib.mkIf cfg.check {
command = cfg.package;
options = lib.mkBefore [ "check" "--fix" ];
includes = [
"*.py"
"*.pyi"
];
};
ruff-format = lib.mkIf cfg.format {
command = cfg.package;
options = lib.mkBefore [ "format" ];
includes = [
"*.py"
"*.pyi"
];
};
};
};
}