2.home-manager/modules/programs/ttyper.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

53 lines
1.2 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
literalExpression
mkIf
mkOption
;
cfg = config.programs.ttyper;
tomlFormat = pkgs.formats.toml { };
in
{
meta.maintainers = [ lib.maintainers.philocalyst ];
options.programs.ttyper = {
enable = lib.mkEnableOption "ttyper, a terminal-based typing test";
package = lib.mkPackageOption pkgs "ttyper" { nullable = true; };
settings = mkOption {
inherit (tomlFormat) type;
default = { };
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/ttyper/config.toml`.
See <https://github.com/max-niederman/ttyper> for all available options,
including supported languages and theme keys.
'';
example = literalExpression ''
{
default_language = "english200";
theme = {
border_type = "rounded";
prompt_correct = "green";
prompt_incorrect = "red";
};
}
'';
};
};
config = mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."ttyper/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "ttyper-config.toml" cfg.settings;
};
};
}