From 97729d1e79f77706f123dbde25063a2fd1c58795 Mon Sep 17 00:00:00 2001 From: Shardul Baral Date: Fri, 15 May 2020 14:40:50 -0400 Subject: [PATCH] Separate yabai config and extra config by newline If a user passes both `config` and `extraConfig` to the `yabai` serivce, the generated `yabairc` file is invalid. This is because we do not add a newline separator when we concatenate the config string generated by `toYabaiConfig cfg.config` with `cfg.extraConfig`. This PR prepends a newline to `cfg.extraConfig` if it is non-empty so that the resulting `yabairc` config is valid. --- modules/services/yabai/default.nix | 2 +- tests/services-yabai.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/services/yabai/default.nix b/modules/services/yabai/default.nix index 9318ff9e..dd539fc1 100644 --- a/modules/services/yabai/default.nix +++ b/modules/services/yabai/default.nix @@ -14,7 +14,7 @@ let (if (cfg.config != {}) then "${toYabaiConfig cfg.config}" else "") - + optionalString (cfg.extraConfig != "") cfg.extraConfig)}"; + + optionalString (cfg.extraConfig != "") ("\n" + cfg.extraConfig + "\n"))}"; in { diff --git a/tests/services-yabai.nix b/tests/services-yabai.nix index 876ba387..48f369c4 100644 --- a/tests/services-yabai.nix +++ b/tests/services-yabai.nix @@ -23,5 +23,6 @@ in echo >&2 "checking config in $conf" grep "yabai -m config focus_follows_mouse autoraise" $conf grep "yabai -m rule --add app='System Preferences' manage=off" $conf + if [ `cat $conf | wc -l` -eq "2" ]; then echo "yabairc correctly contains 2 lines"; else return 1; fi ''; }