1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 02:39:48 +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:
Gaetan Lepage 2023-11-15 18:30:33 +01:00 committed by Robert Helgesson
parent 1aabb0a31b
commit 1bd1e86464
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 86 additions and 0 deletions

View file

@ -1302,6 +1302,13 @@ in
A new module is available: 'programs.granted'.
'';
}
{
time = "2023-11-22T22:42:16+00:00";
message = ''
A new module is available: 'programs.ruff'.
'';
}
];
};
}

View file

@ -190,6 +190,7 @@ let
./programs/rofi.nix
./programs/rtorrent.nix
./programs/rtx.nix
./programs/ruff.nix
./programs/sagemath.nix
./programs/sbt.nix
./programs/scmpuff.nix

45
modules/programs/ruff.nix Normal file
View 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;
};
}

View file

@ -133,6 +133,7 @@ import nmt {
./modules/programs/rio
./modules/programs/ripgrep
./modules/programs/rtx
./modules/programs/ruff
./modules/programs/sagemath
./modules/programs/sbt
./modules/programs/scmpuff

View file

@ -0,0 +1 @@
{ ruff-program = ./ruff.nix; }

View file

@ -0,0 +1,8 @@
line-length = 100
[lint]
ignore = []
select = ["E4", "E7", "E9", "F"]
[per-file-ignores]
"__init__.py" = ["F401"]

View 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}
'';
}