2024-11-09 06:20:22 +00:00
|
|
|
{ pkgs, lib, self, ... }: {
|
2024-11-05 08:55:25 +00:00
|
|
|
# List packages installed in system profile. To search by name, run:
|
|
|
|
# $ nix-env -qaP | grep wget
|
|
|
|
environment.systemPackages = [ ];
|
|
|
|
|
|
|
|
nix.settings = {
|
|
|
|
experimental-features = [ "nix-command" "flakes" ];
|
|
|
|
auto-optimise-store = true;
|
|
|
|
};
|
|
|
|
|
2024-11-15 16:39:17 +00:00
|
|
|
environment.shells = with pkgs; [ bashInteractive zsh fish ];
|
|
|
|
|
2024-11-05 08:55:25 +00:00
|
|
|
# Auto upgrade nix package and the daemon service.
|
|
|
|
services.nix-daemon.enable = true;
|
|
|
|
|
|
|
|
# Enable alternative shell support in nix-darwin.
|
|
|
|
# programs.fish.enable = true;
|
|
|
|
|
2024-11-09 06:20:22 +00:00
|
|
|
services.yabai =
|
|
|
|
let
|
|
|
|
gap = 10;
|
|
|
|
|
|
|
|
gapListParts = builtins.map
|
|
|
|
(x: lib.attrsets.nameValuePair (x + "_padding") gap)
|
|
|
|
[ "top" "bottom" "left" "right" ];
|
|
|
|
|
|
|
|
gapSettings = (builtins.listToAttrs gapListParts) // { window_gap = gap; };
|
|
|
|
in
|
|
|
|
{
|
|
|
|
enable = true;
|
|
|
|
enableScriptingAddition = true;
|
|
|
|
config = {
|
|
|
|
layout = "bsp";
|
|
|
|
window_shadow = "float";
|
|
|
|
|
|
|
|
mouse_modifier = "fn";
|
|
|
|
mouse_action1 = "move";
|
|
|
|
mouse_action2 = "resize";
|
|
|
|
focus_follows_mouse = "autoraise";
|
|
|
|
mouse_follows_focus = "off";
|
|
|
|
window_topmost = "off";
|
|
|
|
} // gapSettings;
|
|
|
|
extraConfig = ''
|
|
|
|
yabai -m rule --add app="^System Settings$" manage=off
|
|
|
|
yabai -m rule --add app="Python" manage=off
|
|
|
|
yabai -m rule --add app="macroquad_playground" manage=off
|
|
|
|
yabai -m rule --add app="^coreautha$" manage=off
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-11-25 15:48:52 +00:00
|
|
|
services.skhd =
|
|
|
|
let
|
|
|
|
yabaiSwapToFullscreen = pkgs.writeShellApplication {
|
|
|
|
name = "yabai-swap-to-fullscreen";
|
|
|
|
runtimeInputs = [ pkgs.jq pkgs.yabai ];
|
|
|
|
text = ''
|
|
|
|
focus() {
|
|
|
|
yabai -m space --focus "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_fs_displays() {
|
|
|
|
yabai -m query --spaces | jq -c 'map(select(."is-native-fullscreen" == true))'
|
|
|
|
}
|
|
|
|
|
|
|
|
get_visible() {
|
|
|
|
printf '%s' "$1" | jq -c 'map(select(."is-visible" == true))'
|
|
|
|
}
|
|
|
|
|
|
|
|
is_empty() {
|
|
|
|
length="$(printf '%s' "$1" | jq 'length')"
|
|
|
|
[ "$length" -le 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
first() {
|
|
|
|
printf '%s' "$1" | jq 'sort_by(.index) | .[0].index'
|
|
|
|
}
|
|
|
|
|
|
|
|
try_focus_visible() {
|
|
|
|
# This should be at max length 1. Though this may likely break in a multimonitor environment
|
|
|
|
visible_fullscreen_displays=$(get_visible "$1")
|
|
|
|
|
|
|
|
if ! is_empty "$visible_fullscreen_displays"; then
|
|
|
|
visible_index=$(printf '%s' "$visible_fullscreen_displays" | jq -c '.[0].index')
|
|
|
|
next_index=$((visible_index + 1))
|
|
|
|
if [ "$(printf '%s' "$fullscreen_displays" | jq "map(select(.index == $next_index)) | length")" -gt "0" ]; then
|
|
|
|
focus "$next_index"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
fullscreen_displays="$(get_fs_displays)"
|
|
|
|
|
|
|
|
is_empty "$fullscreen_displays" && focus 1 && return 1
|
|
|
|
|
|
|
|
try_focus_visible "$fullscreen_displays" && return 1
|
|
|
|
|
|
|
|
focus "$(first "$fullscreen_displays")"
|
|
|
|
}
|
|
|
|
|
|
|
|
main
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Idk if macos' 'open' is something I can find in nixpkgs lmfao
|
|
|
|
newAlacrityWindow = pkgs.writeShellApplication {
|
|
|
|
name = "new-alacritty-window";
|
|
|
|
runtimeInputs = [ pkgs.alacritty ];
|
|
|
|
text = ''
|
|
|
|
alacritty_output=$(alacritty msg create-window 2>/dev/null)
|
|
|
|
|
|
|
|
if [ -z "$alacritty_output" ]; then
|
|
|
|
open /Applications/Alacritty.app
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
yabai = lib.getExe pkgs.yabai;
|
|
|
|
in
|
|
|
|
{
|
2024-11-25 15:58:20 +00:00
|
|
|
enable = true;
|
2024-11-25 15:48:52 +00:00
|
|
|
skhdConfig = ''
|
|
|
|
# float / unfloat window and center on screen
|
|
|
|
alt - t : ${yabai} -m window --toggle float --grid 4:4:1:1:2:2
|
|
|
|
|
|
|
|
# open terminal window using shell script
|
|
|
|
cmd - return : ${lib.getExe newAlacrityWindow}
|
|
|
|
|
|
|
|
# rebind space switching
|
|
|
|
ctrl - left : ${yabai} -m space --focus prev || ${yabai} -m space --focus last
|
|
|
|
ctrl - right : ${yabai} -m space --focus next || ${yabai} -m space --focus first
|
|
|
|
|
|
|
|
# focusing specific spaces
|
|
|
|
cmd - 1 : ${yabai} -m space --focus 1
|
|
|
|
cmd - 2 : ${yabai} -m space --focus 2
|
|
|
|
cmd - 3 : ${yabai} -m space --focus 3
|
|
|
|
cmd - 4 : ${yabai} -m space --focus 4
|
|
|
|
cmd - 5 : ${yabai} -m space --focus 5
|
|
|
|
cmd - 6 : ${yabai} -m space --focus 6
|
|
|
|
cmd - 7 : ${yabai} -m space --focus 7
|
|
|
|
cmd - 8 : ${yabai} -m space --focus 8
|
|
|
|
cmd - 9 : ${yabai} -m space --focus 9
|
|
|
|
cmd - 0x32 : ${lib.getExe yabaiSwapToFullscreen}
|
|
|
|
|
|
|
|
|
|
|
|
# moving windows
|
|
|
|
cmd + shift - 1 : ${yabai} -m window --space 1
|
|
|
|
cmd + shift - 2 : ${yabai} -m window --space 2
|
|
|
|
cmd + shift - 3 : ${yabai} -m window --space 3
|
|
|
|
# cmd + shift - 4 : ${yabai} -m window --space 4
|
|
|
|
cmd + shift - 5 : ${yabai} -m window --space 5
|
|
|
|
cmd + shift - 6 : ${yabai} -m window --space 6
|
|
|
|
cmd + shift - 7 : ${yabai} -m window --space 7
|
|
|
|
cmd + shift - 8 : ${yabai} -m window --space 8
|
|
|
|
cmd + shift - 9 : ${yabai} -m window --space 9
|
|
|
|
cmd + shift - 0x32 : ${yabai} -m window --toggle native-fullscreen
|
|
|
|
|
|
|
|
# cmd + alt - 4 : "cmd + shift - 4"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-11-09 07:10:21 +00:00
|
|
|
home-manager.sharedModules = [
|
|
|
|
{
|
|
|
|
home.file.".config/yabai/yabaiExe".source = lib.getExe pkgs.yabai;
|
|
|
|
home.packages = with pkgs; [ yabai ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-11-14 01:59:46 +00:00
|
|
|
security.pam.enableSudoTouchIdAuth = true;
|
|
|
|
|
2024-11-05 08:55:25 +00:00
|
|
|
users.users.zynh = {
|
|
|
|
name = "zynh";
|
|
|
|
home = "/Users/zynh";
|
|
|
|
};
|
|
|
|
|
|
|
|
home-manager = {
|
|
|
|
users = { "zynh" = import ./home.nix; };
|
|
|
|
backupFileExtension = "backup";
|
|
|
|
};
|
|
|
|
|
2024-11-13 11:37:06 +00:00
|
|
|
fonts.packages = with pkgs; [
|
|
|
|
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
|
|
|
|
];
|
|
|
|
|
2024-11-05 08:55:25 +00:00
|
|
|
# Set Git commit hash for darwin-version.
|
|
|
|
system.configurationRevision = self.rev or self.dirtyRev or null;
|
|
|
|
# $ darwin-rebuild changelog
|
|
|
|
system.stateVersion = 5;
|
|
|
|
}
|