alacritty: don't create file if settings is empty
Also add a few test cases for the alacritty module.
This commit is contained in:
parent
8b15f18993
commit
d2ed39f103
|
@ -41,10 +41,13 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ pkgs.alacritty ];
|
||||
config = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
home.packages = [ pkgs.alacritty ];
|
||||
|
||||
xdg.configFile."alacritty/alacritty.yml".text =
|
||||
replaceStrings ["\\\\"] ["\\"] (builtins.toJSON cfg.settings);
|
||||
};
|
||||
xdg.configFile."alacritty/alacritty.yml" = mkIf (cfg.settings != {}) {
|
||||
text = replaceStrings ["\\\\"] ["\\"] (builtins.toJSON cfg.settings);
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import nmt {
|
|||
)
|
||||
// import ./modules/home-environment
|
||||
// import ./modules/misc/fontconfig
|
||||
// import ./modules/programs/alacritty
|
||||
// import ./modules/programs/bash
|
||||
// import ./modules/programs/ssh
|
||||
// import ./modules/programs/tmux
|
||||
|
|
4
tests/modules/programs/alacritty/default.nix
Normal file
4
tests/modules/programs/alacritty/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
alacritty-example-settings = ./example-settings.nix;
|
||||
alacritty-empty-settings = ./empty-settings.nix;
|
||||
}
|
13
tests/modules/programs/alacritty/empty-settings.nix
Normal file
13
tests/modules/programs/alacritty/empty-settings.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.alacritty.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/alacritty
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{"key_bindings":[{"chars":"\x0c","key":"K","mods":"Control"}],"window":{"dimensions":{"columns":200,"lines":3}}}
|
32
tests/modules/programs/alacritty/example-settings.nix
Normal file
32
tests/modules/programs/alacritty/example-settings.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.alacritty = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
window.dimensions = {
|
||||
lines = 3;
|
||||
columns = 200;
|
||||
};
|
||||
|
||||
key_bindings = [
|
||||
{
|
||||
key = "K";
|
||||
mods = "Control";
|
||||
chars = "\\x0c";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/alacritty/alacritty.yml \
|
||||
${./example-settings-expected.yml}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue