1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-21 09:49:39 +01:00
home-manager/modules/programs/translate-shell.nix
Austin Horstman cba2f9ce95 treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
2025-04-08 08:50:05 -07:00

69 lines
1.5 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.translate-shell;
mkKeyValue =
key: value:
let
formatValue =
v:
if lib.isBool v then
(if v then "true" else "false")
else if lib.isString v then
''"${v}"''
else if lib.isList v then
"[ ${lib.concatStringsSep " " (map formatValue v)} ]"
else
toString v;
in
":${key} ${formatValue value}";
toKeyValue = lib.generators.toKeyValue { inherit mkKeyValue; };
in
{
meta.maintainers = [ ];
options.programs.translate-shell = {
enable = lib.mkEnableOption "translate-shell";
package = lib.mkPackageOption pkgs "translate-shell" { nullable = true; };
settings = lib.mkOption {
type =
with lib.types;
attrsOf (oneOf [
bool
str
(listOf str)
]);
default = { };
example = {
verbose = true;
hl = "en";
tl = [
"es"
"fr"
];
};
description = ''
Options to add to {file}`$XDG_CONFIG_HOME/translate-shell/init.trans` file.
See <https://github.com/soimort/translate-shell/wiki/Configuration>
for options.
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."translate-shell/init.trans" = lib.mkIf (cfg.settings != { }) {
text = "{${toKeyValue cfg.settings}}";
};
};
}