mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
ruff: add module
ruff is Python linter and code formatter, written in Rust. See <https://docs.astral.sh/ruff/>.
This commit is contained in:
parent
1aabb0a31b
commit
1bd1e86464
7 changed files with 86 additions and 0 deletions
|
@ -1302,6 +1302,13 @@ in
|
||||||
A new module is available: 'programs.granted'.
|
A new module is available: 'programs.granted'.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2023-11-22T22:42:16+00:00";
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'programs.ruff'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,7 @@ let
|
||||||
./programs/rofi.nix
|
./programs/rofi.nix
|
||||||
./programs/rtorrent.nix
|
./programs/rtorrent.nix
|
||||||
./programs/rtx.nix
|
./programs/rtx.nix
|
||||||
|
./programs/ruff.nix
|
||||||
./programs/sagemath.nix
|
./programs/sagemath.nix
|
||||||
./programs/sbt.nix
|
./programs/sbt.nix
|
||||||
./programs/scmpuff.nix
|
./programs/scmpuff.nix
|
||||||
|
|
45
modules/programs/ruff.nix
Normal file
45
modules/programs/ruff.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{ 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;
|
||||||
|
};
|
||||||
|
}
|
|
@ -133,6 +133,7 @@ import nmt {
|
||||||
./modules/programs/rio
|
./modules/programs/rio
|
||||||
./modules/programs/ripgrep
|
./modules/programs/ripgrep
|
||||||
./modules/programs/rtx
|
./modules/programs/rtx
|
||||||
|
./modules/programs/ruff
|
||||||
./modules/programs/sagemath
|
./modules/programs/sagemath
|
||||||
./modules/programs/sbt
|
./modules/programs/sbt
|
||||||
./modules/programs/scmpuff
|
./modules/programs/scmpuff
|
||||||
|
|
1
tests/modules/programs/ruff/default.nix
Normal file
1
tests/modules/programs/ruff/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ ruff-program = ./ruff.nix; }
|
8
tests/modules/programs/ruff/expected.toml
Normal file
8
tests/modules/programs/ruff/expected.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
line-length = 100
|
||||||
|
|
||||||
|
[lint]
|
||||||
|
ignore = []
|
||||||
|
select = ["E4", "E7", "E9", "F"]
|
||||||
|
|
||||||
|
[per-file-ignores]
|
||||||
|
"__init__.py" = ["F401"]
|
23
tests/modules/programs/ruff/ruff.nix
Normal file
23
tests/modules/programs/ruff/ruff.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.ruff = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
line-length = 100;
|
||||||
|
per-file-ignores = { "__init__.py" = [ "F401" ]; };
|
||||||
|
lint = {
|
||||||
|
select = [ "E4" "E7" "E9" "F" ];
|
||||||
|
ignore = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.ruff = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/ruff/ruff.toml
|
||||||
|
assertFileContent home-files/.config/ruff/ruff.toml ${./expected.toml}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue