From 0c8fa3a2a270747f3dbb54fe8792f3f0aec997e3 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Mon, 3 Aug 2026 01:22:44 -0400 Subject: Initial commit: combined darwin + guix-linux home-manager flake Supersedes nix-dotfiles (darwin) and guix-dotfiles' ad-hoc nix-home-manager flake (linux). See README.md/MIGRATION.md. --- hosts/RyanMac/configuration.nix | 438 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 438 insertions(+) create mode 100644 hosts/RyanMac/configuration.nix (limited to 'hosts') diff --git a/hosts/RyanMac/configuration.nix b/hosts/RyanMac/configuration.nix new file mode 100644 index 0000000..e19490d --- /dev/null +++ b/hosts/RyanMac/configuration.nix @@ -0,0 +1,438 @@ +{ config, pkgs, inputs, lib, ... }: +let + username = "ryan"; + + defaultBrowser = "zen"; + + thirdPartyTaps = { + "netbirdio/homebrew-tap" = inputs.homebrew-netbird; + "FelixKratz/homebrew-formulae" = inputs.homebrew-felixkratz; + }; + + pinnedNixpkgs = pkgs.writeText "flake-registry.json" (builtins.toJSON { + version = 2; + flakes = [ + { + from = { type = "indirect"; id = "nixpkgs"; }; + to = { + type = "path"; + path = inputs.nixpkgs.outPath; + lastModified = inputs.nixpkgs.lastModified; + narHash = inputs.nixpkgs.narHash; + }; + } + ]; + }); + + mkSpace = i: { + name = toString (117+i); + value = { + enabled = true; + value = { + type = "standard"; + parameters = [ (48 + i) (builtins.elemAt [ 18 19 20 21 22 23 25 26 28 ] (i - 1)) 524288 ]; # opt + num + #parameters = [ (48 + i) (builtins.elemAt [ 18 19 20 21 22 23 25 26 28 ] (i - 1)) 1048576 ]; # cmd + num + }; + }; + }; + + spaceHotkeys = builtins.listToAttrs (map mkSpace (lib.range 1 9)); + + manualHotkeys = { + "64" = { + enabled = true; + }; + }; + +in { + # Modules + imports = [ + inputs.nix-homebrew.darwinModules.nix-homebrew + ../../modules/darwin/random-wallpaper + ]; + + # Define the system's user and home dir location + users.users."${username}" = { + name = "${username}"; + home = "/Users/${username}"; + }; + + system.primaryUser = "${username}"; + + # Set the hostname for this machine + networking.hostName = "RyanMac"; + + # Install the wallpaper engine + local.randomWallpaper = { + enable = true; + directory = "${../../files/Wallpapers}"; + }; + + # Configure yabai + services.yabai = { + enable = true; + enableScriptingAddition = false; + config = { + mouse_follows_focus = "on"; + layout = "bsp"; + window_placement = "second_child"; + top_padding = "10"; + bottom_padding = "10"; + left_padding = "10"; + right_padding = "10"; + window_gap = "10"; + mouse_modifier = "alt"; + mouse_drop_action = "swap"; + mouse_action1 = "move"; + mouse_action2 = "resize"; + focus_follows_mouse = "autofocus"; + }; + extraConfig = '' + yabai -m rule --add app='System Settings' manage=off + yabai -m rule --add app="^Zen$" title="^Picture-in-Picture$" manage=off + '' + # Add simple-bar signals if enabled + + lib.optionalString config.home-manager.users.${username}.ryan.simple-bar.enable '' + yabai -m signal --add event=window_focused action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows when focused application changes" + yabai -m signal --add event=window_resized action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows when a window is resized" + yabai -m signal --add event=window_destroyed action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-ba spaces & windows when an application window is closed" + yabai -m signal --add event=space_changed action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows on space change" + yabai -m signal --add event=display_changed action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows on display focus change" + yabai -m signal --add event=window_title_changed action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows when current window title changes" + yabai -m signal --add event=space_destroyed action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows on space removal" + yabai -m signal --add event=space_created action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows on space creation" + yabai -m signal --add event=application_activated action="curl http://localhost:7776/yabai/spaces/refresh && curl http://localhost:7776/yabai/windows/refresh" label="Refresh simple-bar spaces & windows when application is activated" + yabai -m signal --add event=display_added action="curl http://localhost:7776/yabai/displays/refresh" label="Refresh simple-bar displays when a new dispay is added" + yabai -m signal --add event=display_removed action="curl http://localhost:7776/yabai/displays/refresh" label="Refresh simple-bar displays when a dispay is removed" + yabai -m signal --add event=display_moved action="curl http://localhost:7776/yabai/displays/refresh" label="Refresh simple-bar displays when a dispay is moved" + ''; + }; + + # Configure JankyBorders + services.jankyborders = { + enable = true; + style = "round"; + width = 6.0; + hidpi = true; + ax_focus = true; + active_color = "gradient(top_left=0xee33ccff,bottom_right=0xee00ff99)"; + inactive_color = "0xaa595959"; + }; + + # Install the /etc/nix/flake-registry.json file we made above + environment.etc."nix/flake-registry.json".source = pinnedNixpkgs; + + # Install RyanCA Root + security.pki.certificateFiles = [ + ../../files/CACerts/RyanCA.crt + ]; + + # Virby linux builder + services.virby = { + enable = true; + cores = 4; + diskSize = "50GiB"; + onDemand = { + enable = true; + ttl = 30; + }; + rosetta = true; + }; + + nix = { + enable = true; + settings = { + flake-registry = "/etc/nix/flake-registry.json"; + extra-substituters = [ + "https://virby-nix-darwin.cachix.org" + ]; + extra-trusted-public-keys = [ + "virby-nix-darwin.cachix.org-1:z9GiEZeBU5bEeoDQjyfHPMGPBaIQJOOvYOOjGMKIlLo=" + ]; + "extra-experimental-features" = [ "nix-command" "flakes" ]; + }; + }; + + # Determines the nix-darwin release compatibility + system.stateVersion = 6; + + # System profile programs + programs = { + zsh.enable = true; + }; + + # Install homebrew itself + nix-homebrew = { + enable = true; + enableRosetta = true; + user = "${username}"; + mutableTaps = false; + taps = { + "homebrew/homebrew-core" = inputs.homebrew-core; + "homebrew/homebrew-cask" = inputs.homebrew-cask; + } // thirdPartyTaps; + trust.taps = builtins.attrNames thirdPartyTaps; + }; + + # Install homebrew casks/apps + homebrew = { + enable = true; + + onActivation = { + cleanup = "zap"; + }; + + global.brewfile = true; + + taps = builtins.attrNames config.nix-homebrew.taps; + + brews = [ ]; + + casks = [ + "utm" + "ghostty" + "zen" + "ungoogled-chromium" + "tailscale-app" + "netbird-ui" + "ubersicht" + "hammerspoon" + ]; + }; + + # Keyboard shortcuts using skhd + services.skhd = { + enable = true; + skhdConfig = '' + alt - d : osascript -e 'tell application "System Events" to key code 49 using {command down}' + alt - return : osascript -e 'tell application "Ghostty"' -e 'new window' -e 'activate' -e 'end tell' + + shift + alt - q : ${pkgs.yabai}/bin/yabai -m window --close + + alt - up : ${pkgs.yabai}/bin/yabai -m window --focus north || ${pkgs.yabai}/bin/yabai -m display --focus north + shift + alt - up : ${pkgs.yabai}/bin/yabai -m window --swap north || ${pkgs.yabai}/bin/yabai -m window --display north + alt - down : ${pkgs.yabai}/bin/yabai -m window --focus south || ${pkgs.yabai}/bin/yabai -m display --focus south + shift + alt - down : ${pkgs.yabai}/bin/yabai -m window --swap south || ${pkgs.yabai}/bin/yabai -m window --display south + alt - right : ${pkgs.yabai}/bin/yabai -m window --focus east || ${pkgs.yabai}/bin/yabai -m display --focus east + shift + alt - right : ${pkgs.yabai}/bin/yabai -m window --swap east || ${pkgs.yabai}/bin/yabai -m window --display east + alt - left : ${pkgs.yabai}/bin/yabai -m window --focus west || ${pkgs.yabai}/bin/yabai -m display --focus west + shift + alt - left: ${pkgs.yabai}/bin/yabai -m window --swap west || ${pkgs.yabai}/bin/yabai -m window --display west + + shift + alt - space: ${pkgs.yabai}/bin/yabai -m window --toggle float + + shift + alt - return: ${pkgs.yabai}/bin/yabai -m window --toggle sticky + + alt - f : ${pkgs.yabai}/bin/yabai -m window --toggle zoom-fullscreen + + shift + alt - f: ${pkgs.yabai}/bin/yabai -m window --toggle native-fullscreen + + shift + alt - 1 : ${pkgs.yabai}/bin/yabai -m window --space 1 + shift + alt - 2 : ${pkgs.yabai}/bin/yabai -m window --space 2 + shift + alt - 3 : ${pkgs.yabai}/bin/yabai -m window --space 3 + shift + alt - 4 : ${pkgs.yabai}/bin/yabai -m window --space 4 + shift + alt - 5 : ${pkgs.yabai}/bin/yabai -m window --space 5 + shift + alt - 6 : ${pkgs.yabai}/bin/yabai -m window --space 6 + shift + alt - 7 : ${pkgs.yabai}/bin/yabai -m window --space 7 + shift + alt - 8 : ${pkgs.yabai}/bin/yabai -m window --space 8 + shift + alt - 9 : ${pkgs.yabai}/bin/yabai -m window --space 9 + ''; + }; + + # System configuration + time.timeZone = "America/New_York"; + + power.sleep = { + display = 10; + computer = 30; + }; + + system.defaults = { + WindowManager = { + EnableTilingOptionAccelerator = false; + }; + NSGlobalDomain = { + # 24 hour time + AppleICUForce24HourTime = true; + + # Dark Mode + AppleInterfaceStyle = "Dark"; + + # Key repeat rate + KeyRepeat = 2; + InitialKeyRepeat = 35; + + # Swap F1-12 to be default + "com.apple.keyboard.fnState" = true; + + # Disable Keyboard bullcrap + NSAutomaticCapitalizationEnabled = false; + NSAutomaticDashSubstitutionEnabled = false; + NSAutomaticPeriodSubstitutionEnabled = false; + NSAutomaticQuoteSubstitutionEnabled = false; + NSAutomaticSpellingCorrectionEnabled = false; + ApplePressAndHoldEnabled = false; + }; + + # screensaver/power settings + screensaver = { + askForPassword = true; + askForPasswordDelay = 0; + }; + + # Control center stuff + controlcenter = { + BatteryShowPercentage = true; + Bluetooth = true; + }; + + # Clock settings + menuExtraClock = { + Show24Hour = true; + ShowDate = 1; # Always + ShowDayOfWeek = true; + ShowSeconds = true; + }; + + # Screen capture settings + screencapture = { + target = "clipboard"; + type = "png"; + }; + + # finder good settings + finder = { + AppleShowAllExtensions = true; + AppleShowAllFiles = true; + ShowPathbar = true; + FXEnableExtensionChangeWarning = false; + _FXShowPosixPathInTitle = true; + NewWindowTarget = "Home"; + ShowExternalHardDrivesOnDesktop = false; + ShowHardDrivesOnDesktop = false; + ShowMountedServersOnDesktop = false; + ShowRemovableMediaOnDesktop = false; + ShowStatusBar = true; + }; + + spaces = { + "spans-displays" = false; # independent spaces per display + }; + + # Login Window Settings + loginwindow = { + GuestEnabled = false; + DisableConsoleAccess = true; + }; + + # dock settings + dock = { + magnification = true; + largesize = 96; + tilesize = 32; + minimize-to-application = false; + orientation = "bottom"; + autohide = true; + mru-spaces = false; # Disable auto-rearrange spaces + persistent-apps = [ + { app = "/Applications/Zen.app"; } + #{ app = "/System/Applications/Launchpad.app"; } + { app = "/System/Applications/Messages.app"; } + { app = "/System/Applications/Facetime.app"; } + { app = "/System/Applications/Calendar.app"; } + { app = "/System/Applications/App Store.app"; } + { app = "/System/Applications/System Settings.app"; } + { app = "/Applications/Ghostty.app"; } + { app = "/Applications/UTM.app"; } + ]; + persistent-others = [ + { folder = { path = "/Users/${username}/Downloads"; showas = "grid"; arrangement = "date-created"; }; } + { folder = { path = "/Users/${username}/Applications"; showas = "grid"; arrangement = "name"; }; } + ]; + show-recents = false; + }; + + # Custom preferences + CustomUserPreferences = { + NSGlobalDomain = { + # Always show menu bar + AppleMenuBarVisibleInFullscreen = true; + + # Hide the menubar by default + "_HIHideMenuBar" = true; + + # Option + L lock + NSUserKeyEquivalents = { + "Lock Screen" = "~l"; + }; + }; + + "com.apple.desktopservices" = { + DSDontWriteNetworkStores = true; + DSDontWriteUSBStores = true; + }; + + "com.apple.WindowManager" = { + EnableStandardClickToShowDesktop = false; + StandardHideDesktopIcons = false; + }; + + "com.apple.screensaver" = { + askForPassword = true; + askForPasswordDelay = 2; + }; + + "com.apple.AdLib" = { + allowApplePersonalizedAdvertising = false; + }; + + "com.apple.Accessibility" = { + ReduceMotionEnabled = 1; + }; + + "com.apple.symbolichotkeys" = { + AppleSymbolicHotKeys = manualHotkeys // spaceHotkeys; + }; + }; + universalaccess.reduceMotion = true; + }; + + # Post-Activation scripts + system.activationScripts.postActivation.text = '' + echo "Configuring NTP servers..." + systemsetup -setnetworktimeserver pool.ntp.org > /dev/null 2>&1 || true + systemsetup -setusingnetworktime on > /dev/null 2>&1 || true + + ryancasum="$(${pkgs.openssl}/bin/openssl x509 -in "${../../files/CACerts/RyanCA.crt}" -noout -fingerprint -sha1 | sed 's/.*=//; s/://g')" + if ! /usr/bin/security find-certificate -a -Z "/Library/Keychains/System.keychain" | tr -d ':' | grep -iq "$ryancasum"; then + echo "Installing RyanCA Certificate..." + /usr/bin/security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${../../files/CACerts/RyanCA.crt} + fi + + echo "Reloading Preferences DB..." + sudo -iu ${username} /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u + + echo "Setting default browser" + ${pkgs.defaultbrowser}/bin/defaultbrowser ${defaultBrowser} + + echo "Adding Keyboard brightness controls to Control Center..." + sudo -iu ${username} defaults -currentHost write com.apple.controlcenter KeyboardBrightness -int 25 + + # this is fragile so it goes at the bottom + echo "Reloading skhd..." + sudo -iu ${username} ${pkgs.skhd}/bin/skhd -r + + # Notes if we are running for the first time and writes a message for actions that may need to be done on macOS or linux + MARK="/opt/.nix-complete" + if [ ! -f "$MARK" ]; then + echo "o0o0o0o0o0o MacOS Initial Deploy Notes o0o0o0o0o0o" + echo "--------------------------------------------------" + echo "The following actions must be taken since they are not configurable by Nix. This must be done only ONCE." + echo "" + echo "1. Create 9 spaces." + echo "2. Set keyboard autofill settings" + echo "--------------------------------------------------" + fi + touch "$MARK" + ''; + +} -- cgit v1.3.1