alacritty: don't create file if settings is empty

Also add a few test cases for the alacritty module.

(cherry picked from commit d2ed39f103)
This commit is contained in:
Tadeo Kondrak 2019-05-12 20:08:23 -06:00 committed by Robert Helgesson
parent de9fc235d0
commit 24b734500f
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 {
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);
};
})
];
}

View file

@ -35,6 +35,7 @@ import nmt {
// import ./modules/systemd
)
// import ./modules/home-environment
// 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}
'';
};
}