2.home-manager/modules/programs/topgrade.nix
Austin Horstman 01ea51d706 treewide: use inherit for attribute assignments
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.
2026-04-08 14:47:48 -05:00

58 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.topgrade;
tomlFormat = pkgs.formats.toml { };
in
{
meta.maintainers = [ lib.hm.maintainers.msfjarvis ];
options.programs.topgrade = {
enable = lib.mkEnableOption "topgrade";
package = lib.mkPackageOption pkgs "topgrade" { };
settings = lib.mkOption {
inherit (tomlFormat) type;
default = { };
defaultText = lib.literalExpression "{ }";
example = lib.literalExpression ''
{
misc = {
assume_yes = true;
disable = [
"flutter"
"node"
];
set_title = false;
cleanup = true;
};
commands = {
"Run garbage collection on Nix store" = "nix-collect-garbage";
};
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/topgrade.toml`.
See <https://github.com/r-darwish/topgrade/wiki/Step-list> for the full list
of options.
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."topgrade.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "topgrade-config" cfg.settings;
};
};
}