mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 06:59:45 +01:00
translate-shell: add module (#3659)
This commit is contained in:
parent
b365342adb
commit
fa720861b5
6 changed files with 85 additions and 0 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -350,6 +350,9 @@ Makefile @thiagokokada
|
||||||
/modules/programs/topgrade.nix @msfjarvis
|
/modules/programs/topgrade.nix @msfjarvis
|
||||||
/tests/modules/programs/topgrade @msfjarvis
|
/tests/modules/programs/topgrade @msfjarvis
|
||||||
|
|
||||||
|
/modules/programs/translate-shell.nix @marsam
|
||||||
|
/tests/modules/programs/translate-shell @marsam
|
||||||
|
|
||||||
/modules/programs/vim-vint.nix @tomodachi94
|
/modules/programs/vim-vint.nix @tomodachi94
|
||||||
/tests/modules/programs/vim-vint @tomodachi94
|
/tests/modules/programs/vim-vint @tomodachi94
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ let
|
||||||
./programs/tmate.nix
|
./programs/tmate.nix
|
||||||
./programs/tmux.nix
|
./programs/tmux.nix
|
||||||
./programs/topgrade.nix
|
./programs/topgrade.nix
|
||||||
|
./programs/translate-shell.nix
|
||||||
./programs/urxvt.nix
|
./programs/urxvt.nix
|
||||||
./programs/vim.nix
|
./programs/vim.nix
|
||||||
./programs/vim-vint.nix
|
./programs/vim-vint.nix
|
||||||
|
|
52
modules/programs/translate-shell.nix
Normal file
52
modules/programs/translate-shell.nix
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
cfg = config.programs.translate-shell;
|
||||||
|
|
||||||
|
mkKeyValue = key: value:
|
||||||
|
let
|
||||||
|
formatValue = v:
|
||||||
|
if isBool v then
|
||||||
|
(if v then "true" else "false")
|
||||||
|
else if isString v then
|
||||||
|
''"${v}"''
|
||||||
|
else if isList v then
|
||||||
|
"[ ${concatStringsSep " " (map formatValue v)} ]"
|
||||||
|
else
|
||||||
|
toString v;
|
||||||
|
in ":${key} ${formatValue value}";
|
||||||
|
|
||||||
|
toKeyValue = generators.toKeyValue { inherit mkKeyValue; };
|
||||||
|
|
||||||
|
in {
|
||||||
|
meta.maintainers = [ maintainers.marsam ];
|
||||||
|
|
||||||
|
options.programs.translate-shell = {
|
||||||
|
enable = mkEnableOption "translate-shell";
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
type = with types; attrsOf (oneOf [ bool str (listOf str) ]);
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
verbose = true;
|
||||||
|
hl = "en";
|
||||||
|
tl = [ "es" "fr" ];
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Options to add to <filename>$XDG_CONFIG_HOME/translate-shell/init.trans</filename> file.
|
||||||
|
See <link xlink:href="https://github.com/soimort/translate-shell/wiki/Configuration"/>
|
||||||
|
for options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = [ pkgs.translate-shell ];
|
||||||
|
|
||||||
|
xdg.configFile."translate-shell/init.trans" =
|
||||||
|
mkIf (cfg.settings != { }) { text = "{${toKeyValue cfg.settings}}"; };
|
||||||
|
};
|
||||||
|
}
|
|
@ -128,6 +128,7 @@ import nmt {
|
||||||
./modules/programs/tmate
|
./modules/programs/tmate
|
||||||
./modules/programs/tmux
|
./modules/programs/tmux
|
||||||
./modules/programs/topgrade
|
./modules/programs/topgrade
|
||||||
|
./modules/programs/translate-shell
|
||||||
./modules/programs/vim-vint
|
./modules/programs/vim-vint
|
||||||
./modules/programs/vscode
|
./modules/programs/vscode
|
||||||
./modules/programs/watson
|
./modules/programs/watson
|
||||||
|
|
1
tests/modules/programs/translate-shell/default.nix
Normal file
1
tests/modules/programs/translate-shell/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ translate-shell = ./translate-shell.nix; }
|
27
tests/modules/programs/translate-shell/translate-shell.nix
Normal file
27
tests/modules/programs/translate-shell/translate-shell.nix
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.translate-shell = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
verbose = true;
|
||||||
|
engine = "bing";
|
||||||
|
play = true;
|
||||||
|
hl = "en";
|
||||||
|
tl = [ "de" "fr" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.translate-shell = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileContent home-files/.config/translate-shell/init.trans \
|
||||||
|
${builtins.toFile "translate-shell-expected-settings.trans" ''
|
||||||
|
{:engine "bing"
|
||||||
|
:hl "en"
|
||||||
|
:play true
|
||||||
|
:tl [ "de" "fr" ]
|
||||||
|
:verbose true
|
||||||
|
}''}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue