alacritty: don't create file if settings is empty

Also add a few test cases for the alacritty module.
This commit is contained in:
Tadeo Kondrak 2019-05-12 20:08:23 -06:00 committed by Robert Helgesson
parent 8b15f18993
commit d2ed39f103
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
6 changed files with 59 additions and 5 deletions

View file

@ -41,10 +41,13 @@ in
};
};
config = mkIf cfg.enable {
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);
};
})
];
}

View file

@ -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

View file

@ -0,0 +1,4 @@
{
alacritty-example-settings = ./example-settings.nix;
alacritty-empty-settings = ./empty-settings.nix;
}

View file

@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.alacritty.enable = true;
nmt.script = ''
assertPathNotExists home-files/.config/alacritty
'';
};
}

View file

@ -0,0 +1 @@
{"key_bindings":[{"chars":"\x0c","key":"K","mods":"Control"}],"window":{"dimensions":{"columns":200,"lines":3}}}

View 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}
'';
};
}