This commit is contained in:
2026-01-09 01:41:57 +08:00
parent c1d1b12a26
commit edb0343046
7 changed files with 232 additions and 8 deletions
+18 -1
View File
@@ -51,6 +51,23 @@
# Set primary user for system defaults
system.primaryUser = "df";
# Allow darwin-rebuild switch without sudo password
environment.etc = {
"sudoers.d/10-nix-commands".text = let
commands = [
"/usr/bin/chsh"
"/run/current-system/sw/bin/darwin-rebuild"
"/run/current-system/sw/bin/nix*"
"/run/current-system/sw/bin/ln"
"/nix/store/*/activate"
"/bin/launchctl"
];
commandsString = builtins.concatStringsSep ", " commands;
in ''
%admin ALL=(ALL:ALL) NOPASSWD: ${commandsString}
'';
};
# System-wide packages
environment.systemPackages = with pkgs; [
vim
@@ -59,7 +76,7 @@
# macOS system defaults
system.defaults = {
dock = {
autohide = true;
autohide = false;
orientation = "bottom";
showhidden = true;
mru-spaces = false;
+2 -2
View File
@@ -41,7 +41,7 @@
path = "${config.home.homeDirectory}/.zsh_history";
};
initExtra = ''
initContent = ''
# Custom prompt or additional configuration
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
@@ -102,7 +102,7 @@
enableZshIntegration = true;
enableFishIntegration = true;
git = true;
icons = true;
icons = "auto";
};
# Bat (better cat)
+1 -4
View File
@@ -102,10 +102,7 @@
ctrl + lalt - b : yabai -m config window_border off
shift + ctrl + lalt - b : yabai -m config window_border on
## Misc
# Open new Alacritty window
cmd - return : kitty
cmd - o : yabai -m window $(yabai -m query --windows | jq '.[] | select(.app==".kitty-wrapped") | .id') --space $(yabai -m query --spaces | jq '.[] | select(.has-focus==1) .id')
lalt - return : kitty
'';
}
+1 -1
View File
@@ -33,7 +33,7 @@
# Zsh configuration for macOS
programs.zsh = lib.mkIf config.programs.zsh.enable {
initExtra = ''
initContent = ''
# Add Homebrew to PATH if it exists
if [[ -d /opt/homebrew/bin ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
+45
View File
@@ -0,0 +1,45 @@
{
config,
pkgs,
lib,
...
}: {
nix = {
enable = false;
settings = {
substituters = [
"https://cache.nixos.org/"
"https://cache.iog.io"
"https://haskell-language-server.cachix.org"
"https://nix-community.cachix.org"
];
trusted-users = ["@admin"];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"haskell-language-server.cachix.org-1:juFfHrwkOxqIOZShtC4YC1uT1bBcq2RSvC7OMKx0Nz8="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
experimental-features = ["ca-derivations" "nix-command" "flakes"];
keep-outputs = true;
keep-derivations = true;
max-jobs = 32;
cores = 0;
http-connections = 64;
download-buffer-size = 134217728; # 128 MB
};
# optimise.automatic = true;
package = pkgs.nixVersions.latest;
};
nix.extraOptions =
''
accept-flake-config = true
''
+ lib.optionalString (pkgs.system == "aarch64-darwin") ''
extra-platforms = x86_64-darwin aarch64-darwin
'';
}
+111
View File
@@ -0,0 +1,111 @@
{
config,
lib,
pkgs,
...
}: let
super = "lalt";
in {
services.skhd = {
enable = true;
package = pkgs.skhd;
skhdConfig = ''
## Navigation (${super} - ...)
# Space Navigation (four spaces per display): ${super} - {1, 2, 3, 4}
${super} - 1 : yabai -m space --focus 1
${super} - 2 : yabai -m space --focus 2
${super} - 3 : yabai -m space --focus 3
${super} - 4 : yabai -m space --focus 4
${super} - 5 : yabai -m space --focus 5
${super} - 6 : yabai -m space --focus 6
${super} - 7 : yabai -m space --focus 7
${super} - 8 : yabai -m space --focus 8
${super} - 9 : yabai -m space --focus 9
${super} - 0 : yabai -m space --focus 0
# Window Navigation (through display borders): ${super} - {h, j, k, l}
${super} - h : yabai -m window --focus west || yabai -m display --focus west
${super} - j : yabai -m window --focus south || yabai -m display --focus south
${super} - k : yabai -m window --focus north || yabai -m display --focus north
${super} - l : yabai -m window --focus east || yabai -m display --focus east
# Float / Unfloat window: ${super} - space
# ${super} - space : yabai -m window --toggle float; sketchybar --trigger window_focus
# Make window zoom to fullscreen: shift + ${super} - f
shift + ${super} - f : yabai -m window --toggle zoom-fullscreen; sketchybar --trigger window_focus
# Make window zoom to parent node: ${super} - f
${super} - f : yabai -m window --toggle zoom-parent; sketchybar --trigger window_focus
## Window Movement (shift + ${super} - ...)
# Moving windows in spaces: shift + ${super} - {h, j, k, l}
shift + ${super} - h : yabai -m window --warp west || $(yabai -m window --display west && sketchybar --trigger windows_on_spaces && yabai -m display --focus west && yabai -m window --warp last) || yabai -m window --move rel:-10:0
shift + ${super} - j : yabai -m window --warp south || $(yabai -m window --display south && sketchybar --trigger windows_on_spaces && yabai -m display --focus south) || yabai -m window --move rel:0:10
shift + ${super} - k : yabai -m window --warp north || $(yabai -m window --display north && sketchybar --trigger windows_on_spaces && yabai -m display --focus north) || yabai -m window --move rel:0:-10
shift + ${super} - l : yabai -m window --warp east || $(yabai -m window --display east && sketchybar --trigger windows_on_spaces && yabai -m display --focus east && yabai -m window --warp first) || yabai -m window --move rel:10:0
# Toggle split orientation of the selected windows node: shift + ${super} - s
shift + ${super} - s : yabai -m window --toggle split
# Moving windows between spaces: shift + ${super} - {1, 2, 3, 4, p, n } (Assumes 4 Spaces Max per Display)
shift + ${super} - 1 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\
yabai -m window --space $((1+4*($DISPLAY - 1)));\
sketchybar --trigger windows_on_spaces
shift + ${super} - 2 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\
yabai -m window --space $((2+4*($DISPLAY - 1)));\
sketchybar --trigger windows_on_spaces
shift + ${super} - 3 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\
yabai -m window --space $((3+4*($DISPLAY - 1)));\
sketchybar --trigger windows_on_spaces
shift + ${super} - 4 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\
yabai -m window --space $((4+4*($DISPLAY - 1)));\
sketchybar --trigger windows_on_spaces
shift + ${super} - p : yabai -m window --space prev; yabai -m space --focus prev; sketchybar --trigger windows_on_spaces
shift + ${super} - n : yabai -m window --space next; yabai -m space --focus next; sketchybar --trigger windows_on_spaces
# Mirror Space on X and Y Axis: shift + ${super} - {x, y}
shift + ${super} - x : yabai -m space --mirror x-axis
shift + ${super} - y : yabai -m space --mirror y-axis
## Stacks (shift + ctrl - ...)
# Add the active window to the window or stack to the {direction}: shift + ctrl - {h, j, k, l}
shift + ctrl - h : yabai -m window west --stack $(yabai -m query --windows --window | jq -r '.id'); sketchybar --trigger window_focus
shift + ctrl - j : yabai -m window south --stack $(yabai -m query --windows --window | jq -r '.id'); sketchybar --trigger window_focus
shift + ctrl - k : yabai -m window north --stack $(yabai -m query --windows --window | jq -r '.id'); sketchybar --trigger window_focus
shift + ctrl - l : yabai -m window east --stack $(yabai -m query --windows --window | jq -r '.id'); sketchybar --trigger window_focus
# Stack Navigation: shift + ctrl - {n, p}
shift + ctrl - n : yabai -m window --focus stack.next
shift + ctrl - p : yabai -m window --focus stack.prev
## Resize (ctrl + ${super} - ...)
# Resize windows: ctrl + ${super} - {h, j, k, l}
ctrl + ${super} - h : yabai -m window --resize right:-100:0 || yabai -m window --resize left:-100:0
ctrl + ${super} - j : yabai -m window --resize bottom:0:100 || yabai -m window --resize top:0:100
ctrl + ${super} - k : yabai -m window --resize bottom:0:-100 || yabai -m window --resize top:0:-100
ctrl + ${super} - l : yabai -m window --resize right:100:0 || yabai -m window --resize left:100:0
# Equalize size of windows: ctrl + ${super} - e
ctrl + ${super} - e : yabai -m space --balance
# Enable / Disable gaps in current workspace: ctrl + ${super} - g
ctrl + ${super} - g : yabai -m space --toggle padding; yabai -m space --toggle gap
# Enable / Disable window borders in current workspace: ctrl + ${super} - b
ctrl + ${super} - b : yabai -m config window_border off
shift + ctrl + ${super} - b : yabai -m config window_border on
## Misc
# Open new Alacritty window
${super} - return : kitty
${super} - o : yabai -m window $(yabai -m query --windows | jq '.[] | select(.app==".kitty-wrapped") | .id') --space $(yabai -m query --spaces | jq '.[] | select(.has-focus==1) .id')
'';
};
}
+54
View File
@@ -0,0 +1,54 @@
{
config,
lib,
pkgs,
...
}: {
services.yabai = {
enable = true;
# enableScriptingAddition = true;
package = pkgs.yabai;
config = {
# layout
layout = "bsp";
auto_balance = "off";
split_ratio = "0.50";
window_placement = "second_child";
# Gaps
window_gap = 18;
top_padding = 18;
bottom_padding = 52;
left_padding = 18;
right_padding = 18;
# shadows and borders
window_shadow = "float";
# mouse
mouse_follows_focus = "off";
focus_follows_mouse = "off";
mouse_modifier = "cmd";
mouse_action1 = "move";
mouse_action2 = "resize";
mouse_drop_action = "swap";
};
# # Unload the macOS WindowManager process
# launchctl unload -F /System/Library/LaunchAgents/com.apple.WindowManager.plist > /dev/null 2>&1 &
# # bar
# yabai -m signal --add event=window_focused action="sketchybar --trigger window_focus"
# yabai -m signal --add event=display_added action="sleep 1 && ${scripts}/create_spaces.sh"
# yabai -m signal --add event=display_removed action="sleep 1 && ${scripts}/create_spaces.sh"
# yabai -m signal --add event=window_created action="sketchybar --trigger windows_on_spaces"
# yabai -m signal --add event=window_destroyed action="sketchybar --trigger windows_on_spaces"
# ${scripts}/create_spaces.sh
extraConfig = ''
# rules
yabai -m rule --add app="^(Genshin Impact|LuLu|Vimac|Calculator|Software Update|Dictionary|VLC|System Preferences|zoom.us|Photo Booth|Archive Utility|Python|LibreOffice|App Store|Steam|Alfred|Activity Monitor)$" manage=off
yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off
yabai -m rule --add label="Safari" app="^Safari$" title="^(General|(Tab|Password|Website|Extension)s|AutoFill|Se(arch|curity)|Privacy|Advance)$" manage=off
yabai -m rule --add label="About This Mac" app="System Information" title="About This Mac" manage=off
yabai -m rule --add label="Select file to save to" app="^Inkscape$" title="Select file to save to" manage=off
'';
};
}