Files
home-manager/modules/programs/rio.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

90 lines
2.1 KiB
Nix

{
lib,
pkgs,
config,
...
}:
let
inherit (lib)
mkEnableOption
mkPackageOption
mkOption
mkIf
mkMerge
types
literalExpression
mapAttrs'
nameValuePair
;
cfg = config.programs.rio;
settingsFormat = pkgs.formats.toml { };
in
{
meta.maintainers = [ lib.maintainers.otavio ];
options.programs.rio = {
enable = mkEnableOption null // {
description = ''
Enable Rio, a terminal built to run everywhere, as a native desktop applications by
Rust/WebGPU or even in the browsers powered by WebAssembly/WebGPU.
'';
};
package = mkPackageOption pkgs "rio" { nullable = true; };
settings = mkOption {
inherit (settingsFormat) type;
default = { };
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/rio/config.toml`. See
<https://raphamorim.io/rio/docs/#configuration-file> for options.
'';
};
themes = mkOption {
type = with types; attrsOf (either settingsFormat.type path);
default = { };
description = ''
Theme files written to {file}`$XDG_CONFIG_HOME/rio/themes/`. See
<https://rioterm.com/docs/config#building-your-own-theme> for
supported values.
'';
example = literalExpression ''
{
foobar.colors = {
background = "#282a36";
green = "#50fa7b";
dim-green = "#06572f";
};
}
'';
};
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = mkIf (cfg.package != null) [ cfg.package ];
}
# Only manage configuration if not empty
(mkIf (cfg.settings != { }) {
xdg.configFile."rio/config.toml".source =
if builtins.isPath cfg.settings then
cfg.settings
else
settingsFormat.generate "rio.toml" cfg.settings;
})
(mkIf (cfg.themes != { }) {
xdg.configFile = mapAttrs' (
name: value:
nameValuePair "rio/themes/${name}.toml" {
source =
if builtins.isPath value then value else settingsFormat.generate "rio-theme-${name}.toml" value;
}
) cfg.themes;
})
]);
}