From 88aa4908c5f198cd8b7c81b2b46154eb5610a204 Mon Sep 17 00:00:00 2001 From: Wong Ding Feng Date: Fri, 16 Jan 2026 01:02:34 +0800 Subject: [PATCH] oui --- common.nix | 42 ++++++++++++- darwin/configuration.nix | 3 + home-manager/home.nix | 2 +- home-manager/modules/skhd.nix | 108 ---------------------------------- inbox/nix.nix | 45 -------------- inbox/yabai.nix | 54 ----------------- 6 files changed, 43 insertions(+), 211 deletions(-) delete mode 100644 home-manager/modules/skhd.nix delete mode 100644 inbox/nix.nix delete mode 100644 inbox/yabai.nix diff --git a/common.nix b/common.nix index 521dd96..73b0ccf 100644 --- a/common.nix +++ b/common.nix @@ -14,16 +14,40 @@ in { settings = { # Enable flakes and new 'nix' command - experimental-features = "nix-command flakes"; + experimental-features = "nix-command flakes ca-derivations"; + + # Binary caches + substituters = [ + "https://cache.nixos.org/" + "https://cache.iog.io" + "https://haskell-language-server.cachix.org" + "https://nix-community.cachix.org" + ]; + 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=" + ]; # Opinionated: disable global registry flake-registry = ""; - # Trusted users (useful for remote builds) - # trusted-users = [ "root" "@wheel" ]; + # Trusted users + trusted-users = ["root" "@admin" "@wheel"]; # Workaround for https://github.com/NixOS/nix/issues/9574 nix-path = config.nix.nixPath; + + # Keep build dependencies for development + keep-outputs = true; + keep-derivations = true; + + # Performance tuning + max-jobs = 32; + cores = 0; # Use all cores + http-connections = 64; + download-buffer-size = 134217728; # 128 MB }; # Opinionated: make flake registry and nix path match flake inputs @@ -37,6 +61,18 @@ automatic = true; options = "--delete-older-than 7d"; }; + + # Extra options + extraOptions = + '' + accept-flake-config = true + '' + + lib.optionalString (pkgs.system == "aarch64-darwin") '' + extra-platforms = x86_64-darwin aarch64-darwin + ''; + + # Use latest nix version + package = pkgs.nixVersions.latest; }; # Shared nixpkgs configuration diff --git a/darwin/configuration.nix b/darwin/configuration.nix index 4bbcedd..75f2be8 100644 --- a/darwin/configuration.nix +++ b/darwin/configuration.nix @@ -12,6 +12,9 @@ # Shared configuration between NixOS and nix-darwin ../common.nix + # skhd hotkey daemon (system service) + ./skhd.nix + # If you want to use modules your own flake exports (from modules/darwin): # inputs.self.darwinModules.example diff --git a/home-manager/home.nix b/home-manager/home.nix index 202de47..c0bc3f7 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -24,7 +24,7 @@ ./modules/kitty.nix ./modules/neovim.nix ./modules/tmux.nix - ./modules/skhd.nix + # skhd is a darwin system service, configured in darwin/skhd.nix ./modules/yabai.nix ./modules/inbox.nix diff --git a/home-manager/modules/skhd.nix b/home-manager/modules/skhd.nix deleted file mode 100644 index dab4222..0000000 --- a/home-manager/modules/skhd.nix +++ /dev/null @@ -1,108 +0,0 @@ -# Simple Hotkey Daemon configuration -{ - inputs, - lib, - config, - pkgs, - ... -}: { - services.skhd = lib.mkIf pkgs.stdenv.isDarwin { - enable = true; - package = pkgs.skhd; - }; - - home.file.".skhdrc".text = lib.mkIf pkgs.stdenv.isDarwin '' - ## Navigation (lalt - ...) - # Space Navigation (four spaces per display): lalt - {1, 2, 3, 4} - lalt - 1 : yabai -m space --focus 1 - lalt - 2 : yabai -m space --focus 2 - lalt - 3 : yabai -m space --focus 3 - lalt - 4 : yabai -m space --focus 4 - lalt - 5 : yabai -m space --focus 5 - lalt - 6 : yabai -m space --focus 6 - lalt - 7 : yabai -m space --focus 7 - lalt - 8 : yabai -m space --focus 8 - lalt - 9 : yabai -m space --focus 9 - lalt - 0 : yabai -m space --focus 0 - - # Window Navigation (through display borders): lalt - {h, j, k, l} - lalt - h : yabai -m window --focus west || yabai -m display --focus west - lalt - j : yabai -m window --focus south || yabai -m display --focus south - lalt - k : yabai -m window --focus north || yabai -m display --focus north - lalt - l : yabai -m window --focus east || yabai -m display --focus east - - # Float / Unfloat window: lalt - space - lalt - space : yabai -m window --toggle float; sketchybar --trigger window_focus - - # Make window zoom to fullscreen: shift + lalt - f - shift + lalt - f : yabai -m window --toggle zoom-fullscreen; sketchybar --trigger window_focus - - # Make window zoom to parent node: lalt - f - lalt - f : yabai -m window --toggle zoom-parent; sketchybar --trigger window_focus - - ## Window Movement (shift + lalt - ...) - # Moving windows in spaces: shift + lalt - {h, j, k, l} - shift + lalt - 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 + lalt - 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 + lalt - 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 + lalt - 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 + lalt - s - shift + lalt - s : yabai -m window --toggle split - - # Moving windows between spaces: shift + lalt - {1, 2, 3, 4, p, n } (Assumes 4 Spaces Max per Display) - shift + lalt - 1 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\ - yabai -m window --space $((1+4*($DISPLAY - 1)));\ - sketchybar --trigger windows_on_spaces - - shift + lalt - 2 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\ - yabai -m window --space $((2+4*($DISPLAY - 1)));\ - sketchybar --trigger windows_on_spaces - - shift + lalt - 3 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\ - yabai -m window --space $((3+4*($DISPLAY - 1)));\ - sketchybar --trigger windows_on_spaces - - shift + lalt - 4 : DISPLAY="$(yabai -m query --displays --display | jq '.index')";\ - yabai -m window --space $((4+4*($DISPLAY - 1)));\ - sketchybar --trigger windows_on_spaces - - shift + lalt - p : yabai -m window --space prev; yabai -m space --focus prev; sketchybar --trigger windows_on_spaces - shift + lalt - n : yabai -m window --space next; yabai -m space --focus next; sketchybar --trigger windows_on_spaces - - # Mirror Space on X and Y Axis: shift + lalt - {x, y} - shift + lalt - x : yabai -m space --mirror x-axis - shift + lalt - 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 + lalt - ...) - # Resize windows: ctrl + lalt - {h, j, k, l} - ctrl + lalt - h : yabai -m window --resize right:-100:0 || yabai -m window --resize left:-100:0 - ctrl + lalt - j : yabai -m window --resize bottom:0:100 || yabai -m window --resize top:0:100 - ctrl + lalt - k : yabai -m window --resize bottom:0:-100 || yabai -m window --resize top:0:-100 - ctrl + lalt - l : yabai -m window --resize right:100:0 || yabai -m window --resize left:100:0 - - # Equalize size of windows: ctrl + lalt - e - ctrl + lalt - e : yabai -m space --balance - - # Enable / Disable gaps in current workspace: ctrl + lalt - g - ctrl + lalt - g : yabai -m space --toggle padding; yabai -m space --toggle gap - - # Enable / Disable window borders in current workspace: ctrl + lalt - b - ctrl + lalt - b : yabai -m config window_border off - shift + ctrl + lalt - b : yabai -m config window_border on - - lalt - return : kitty - ''; -} - diff --git a/inbox/nix.nix b/inbox/nix.nix deleted file mode 100644 index 96fced2..0000000 --- a/inbox/nix.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - 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 - ''; -} \ No newline at end of file diff --git a/inbox/yabai.nix b/inbox/yabai.nix deleted file mode 100644 index dbba1f5..0000000 --- a/inbox/yabai.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ - 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 - ''; - }; -} - -