From 646b68b960b4178d0452237da6605a9850b63bf5 Mon Sep 17 00:00:00 2001 From: Wong Ding Feng Date: Sun, 16 Nov 2025 23:52:15 +0800 Subject: [PATCH] mmm --- common.nix | 6 +-- darwin/configuration.nix | 8 ++-- home-manager/common.nix | 15 ------- home-manager/modules/packages.nix | 71 +++++------------------------ home-manager/modules/skhd.nix | 9 ++-- home-manager/modules/yabai.nix | 74 ++++++++++++++----------------- 6 files changed, 56 insertions(+), 127 deletions(-) diff --git a/common.nix b/common.nix index cbe6670..97c4a9b 100644 --- a/common.nix +++ b/common.nix @@ -18,9 +18,6 @@ # Opinionated: disable global registry flake-registry = ""; - # Deduplicate and optimize nix store - auto-optimise-store = true; - # Trusted users (useful for remote builds) # trusted-users = [ "root" "@wheel" ]; @@ -28,6 +25,9 @@ nix-path = config.nix.nixPath; }; + # Deduplicate and optimize nix store + optimise.automatic = true; + # Garbage collection gc = { automatic = true; diff --git a/darwin/configuration.nix b/darwin/configuration.nix index 80d0c02..f7fcef1 100644 --- a/darwin/configuration.nix +++ b/darwin/configuration.nix @@ -23,9 +23,6 @@ # macOS-specific Nix settings (common.nix has the shared ones) # Any darwin-specific nix configuration can go here - # Auto upgrade nix package and the daemon service - services.nix-daemon.enable = true; - # Necessary for using flakes on this system nix.package = pkgs.nix; @@ -49,6 +46,9 @@ name = "df"; home = "/Users/df"; }; + + # Set primary user for system defaults + system.primaryUser = "df"; # System-wide packages environment.systemPackages = with pkgs; [ @@ -84,6 +84,6 @@ }; # Security - security.pam.enableSudoTouchIdAuth = true; + security.pam.services.sudo_local.touchIdAuth = true; } diff --git a/home-manager/common.nix b/home-manager/common.nix index e624f91..3f66046 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -6,21 +6,6 @@ pkgs, ... }: { - nixpkgs = { - # You can add overlays here - overlays = [ - # Add overlays your own flake exports (from overlays and pkgs dir): - inputs.self.overlays.additions - inputs.self.overlays.modifications - inputs.self.overlays.unstable-packages - ]; - # Configure your nixpkgs instance - config = { - # Disable if you don't want unfree packages - allowUnfree = true; - }; - }; - # Enable home-manager programs.home-manager.enable = true; diff --git a/home-manager/modules/packages.nix b/home-manager/modules/packages.nix index 5633461..746dcb7 100644 --- a/home-manager/modules/packages.nix +++ b/home-manager/modules/packages.nix @@ -31,65 +31,16 @@ with pkgs; let west pyelftools ]); -in { - imports = [ - ./modules/yabai/yabai.nix - ./modules/skhd/skhd.nix - ]; - - nixpkgs.overlays = [ - (final: prev: { - maven363 = prev.maven.overrideAttrs (old: rec { - pname = "apache-maven"; - version = "3.6.3"; - src = prev.pkgs.fetchurl { - url = "mirror://apache/maven/maven-3/${version}/binaries/${pname}-${version}-bin.tar.gz"; - sha256 = "sha256-Jq2R11GzqaUwh676dD9OFqF3QdORWyGc90ESv4ekOMU="; - }; - }); - }) - ]; - nixpkgs.config.permittedInsecurePackages = [ - "hadoop-3.3.1" - "libressl-3.4.3" - ]; - nix = { - configureBuildUsers = true; - 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; - - auto-optimise-store = true; - max-jobs = 32; - cores = 0; - http-connections = 64; + maven363 = pkgs.maven.overrideAttrs (old: rec { + pname = "apache-maven"; + version = "3.6.3"; + src = pkgs.fetchurl { + url = "mirror://apache/maven/maven-3/${version}/binaries/${pname}-${version}-bin.tar.gz"; + sha256 = "sha256-Jq2R11GzqaUwh676dD9OFqF3QdORWyGc90ESv4ekOMU="; }; - package = nixUnstable; - }; - - nix.extraOptions = - "" - + lib.optionalString (pkgs.system == "aarch64-darwin") '' - extra-platforms = x86_64-darwin aarch64-darwin - ''; - - environment.systemPackages = with pkgs; [ + }); +in { + home.packages = with pkgs; [ gitAndTools.gitFull neovim vim @@ -131,7 +82,7 @@ in { htop - exa + eza openconnect yq @@ -170,7 +121,7 @@ in { # apktool no darwin docker - lima + # lima - removed due to CVEs, use unstable version if needed llvmPackages_14.clangUseLLVM headscale diff --git a/home-manager/modules/skhd.nix b/home-manager/modules/skhd.nix index 60d8a87..b2045fc 100644 --- a/home-manager/modules/skhd.nix +++ b/home-manager/modules/skhd.nix @@ -6,10 +6,12 @@ pkgs, ... }: { - services.skhd = { + services.skhd = lib.mkIf pkgs.stdenv.isDarwin { enable = true; package = pkgs.skhd; - skhdConfig = '' + }; + + 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 @@ -104,7 +106,6 @@ # 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') - ''; - }; + ''; } diff --git a/home-manager/modules/yabai.nix b/home-manager/modules/yabai.nix index 132c300..5056efd 100644 --- a/home-manager/modules/yabai.nix +++ b/home-manager/modules/yabai.nix @@ -1,4 +1,6 @@ # Yabai window manager configuration (macOS only) +# Note: Yabai is a system-level service and should be configured through nix-darwin +# This file only installs the package for home-manager { inputs, lib, @@ -6,51 +8,40 @@ pkgs, ... }: { - # Only enable on macOS since yabai is macOS-specific - services.yabai = lib.mkIf pkgs.stdenv.isDarwin { - enable = true; - - # enableScriptingAddition = true; - - package = pkgs.yabai; - - config = { + # Install yabai package for user + home.packages = lib.mkIf pkgs.stdenv.isDarwin [ + pkgs.yabai + ]; + + # Create yabai config file + home.file.".yabairc" = lib.mkIf pkgs.stdenv.isDarwin { + text = '' + #!/usr/bin/env sh + # layout - layout = "bsp"; - auto_balance = "off"; - split_ratio = "0.50"; - window_placement = "second_child"; - + yabai -m config layout bsp + yabai -m config auto_balance off + yabai -m config split_ratio 0.50 + yabai -m config window_placement second_child + # Gaps - window_gap = 18; - top_padding = 18; - bottom_padding = 52; - left_padding = 18; - right_padding = 18; - + yabai -m config window_gap 18 + yabai -m config top_padding 18 + yabai -m config bottom_padding 52 + yabai -m config left_padding 18 + yabai -m config right_padding 18 + # shadows and borders - window_shadow = "float"; - + yabai -m config 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 = '' + yabai -m config mouse_follows_focus off + yabai -m config focus_follows_mouse off + yabai -m config mouse_modifier cmd + yabai -m config mouse_action1 move + yabai -m config mouse_action2 resize + yabai -m config mouse_drop_action swap + # 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 @@ -58,5 +49,6 @@ 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 ''; + executable = true; }; }