1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-09-11 12:49:18 +03:00
nix-darwin/tests/services-yabai.nix
Shardul Baral 97729d1e79
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.
2020-05-15 15:38:57 -04:00

29 lines
1022 B
Nix

{ config, lib, pkgs, ... }:
with lib;
let
yabai = pkgs.runCommand "yabai-0.0.0" {} "mkdir $out";
in
{
services.yabai.enable = true;
services.yabai.package = yabai;
services.yabai.config = { focus_follows_mouse = "autoraise"; };
services.yabai.extraConfig = "yabai -m rule --add app='System Preferences' manage=off";
test = ''
echo >&2 "checking yabai service in ~/Library/LaunchAgents"
grep "org.nixos.yabai" ${config.out}/user/Library/LaunchAgents/org.nixos.yabai.plist
grep "${yabai}/bin/yabai" ${config.out}/user/Library/LaunchAgents/org.nixos.yabai.plist
conf=`sed -En '/<string>-c<\/string>/{n; s/\s+?<\/?string>//g; p;}' \
${config.out}/user/Library/LaunchAgents/org.nixos.yabai.plist`
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
'';
}