mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
This change converts redundant attribute assignments of the form `a = a;` or `a = someSet.a;` into cleaner `inherit` statements. This reduces verbosity and follows common Nix style for bringing attributes into scope. Statix Codes: W03 (manual_inherit), W04 (manual_inherit_from) Also include statix and the rule in our configuration.
57 lines
1.2 KiB
Nix
57 lines
1.2 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (lib)
|
|
mkEnableOption
|
|
mkPackageOption
|
|
mkOption
|
|
literalExpression
|
|
;
|
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
cfg = config.programs.uv;
|
|
|
|
in
|
|
{
|
|
meta.maintainers = with lib.maintainers; [ mirkolenz ];
|
|
|
|
options.programs.uv = {
|
|
enable = mkEnableOption "uv";
|
|
|
|
package = mkPackageOption pkgs "uv" { nullable = true; };
|
|
|
|
settings = mkOption {
|
|
inherit (tomlFormat) type;
|
|
default = { };
|
|
example = literalExpression ''
|
|
{
|
|
python-downloads = "never";
|
|
python-preference = "only-system";
|
|
pip.index-url = "https://test.pypi.org/simple";
|
|
}
|
|
'';
|
|
description = ''
|
|
Configuration written to
|
|
{file}`$XDG_CONFIG_HOME/uv/uv.toml`.
|
|
See <https://docs.astral.sh/uv/configuration/files/>
|
|
and <https://docs.astral.sh/uv/reference/settings/>
|
|
for more information.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
|
|
xdg.configFile."uv/uv.toml" = lib.mkIf (cfg.settings != { }) {
|
|
source = tomlFormat.generate "uv-config" cfg.settings;
|
|
};
|
|
};
|
|
}
|