1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-18 22:33:00 +00:00
home-manager/modules/programs/ruff.nix
Austin Horstman d2c014e1c7
treewide: null package support (#6582)
Can generate the config without installing application through home-manager. Helpful when a package is broken (or not provided) on a specific platform through nixpkgs and needs to be installed through other means but you still can benefit from the declarative configuration.
2025-03-07 18:17:52 -06:00

45 lines
1 KiB
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" { nullable = true; };
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 = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."ruff/ruff.toml".source =
settingsFormat.generate "ruff.toml" cfg.settings;
};
}