1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/programs/translate-shell.nix
Austin Horstman 86402a17b6 treewide: flatten single file modules
Some files don't need nesting and can be root level again to reduce
conflicts with other PRs.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-23 16:20:26 -05: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}}";
};
};
}