mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
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>
69 lines
1.5 KiB
Nix
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}}";
|
|
};
|
|
};
|
|
}
|