From 1d1371be2b1ec1453846a2f987b45b79fc4d472e Mon Sep 17 00:00:00 2001 From: whoami Date: Sun, 17 Aug 2025 17:23:51 +0800 Subject: [PATCH] nix-darwin --- nix/flake.lock | 49 +++++++++++++++ nix/flake.nix | 21 +++++++ nix/hosts/macbook/brew.nix | 70 +++++++++++++++++++++ nix/hosts/macbook/default.nix | 54 ++++++++++++++++ nix/hosts/macbook/system.nix | 114 ++++++++++++++++++++++++++++++++++ 5 files changed, 308 insertions(+) create mode 100644 nix/flake.lock create mode 100644 nix/flake.nix create mode 100644 nix/hosts/macbook/brew.nix create mode 100644 nix/hosts/macbook/default.nix create mode 100644 nix/hosts/macbook/system.nix diff --git a/nix/flake.lock b/nix/flake.lock new file mode 100644 index 0000000..3690b21 --- /dev/null +++ b/nix/flake.lock @@ -0,0 +1,49 @@ +{ + "nodes": { + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1751313918, + "narHash": "sha256-HsJM3XLa43WpG+665aGEh8iS8AfEwOIQWk3Mke3e7nk=", + "owner": "nix-darwin", + "repo": "nix-darwin", + "rev": "e04a388232d9a6ba56967ce5b53a8a6f713cdfcf", + "type": "github" + }, + "original": { + "owner": "nix-darwin", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1753934836, + "narHash": "sha256-G06FmIBj0I5bMW1Q8hAEIl5N7IHMK7+Ta4KA+BmneDA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8679b16e11becd487b45d568358ddf9d5640d860", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/flake.nix b/nix/flake.nix new file mode 100644 index 0000000..586b4e5 --- /dev/null +++ b/nix/flake.nix @@ -0,0 +1,21 @@ +{ + description = "My macOS Flake config"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-darwin.url = "github:nix-darwin/nix-darwin/master"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, nix-darwin, ... }: { + darwinConfigurations."zen" = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + ./hosts/macbook/default.nix + ./hosts/macbook/brew.nix + ./hosts/macbook/system.nix + ]; + }; + + }; +} diff --git a/nix/hosts/macbook/brew.nix b/nix/hosts/macbook/brew.nix new file mode 100644 index 0000000..2c7063c --- /dev/null +++ b/nix/hosts/macbook/brew.nix @@ -0,0 +1,70 @@ +{ config, pkgs, ...}: + +{ + homebrew = { + enable = true; + brewPrefix = "/opt/homebrew/bin"; + taps = [ + "daipeihust/tap" + "felixkratz/formulae" + "koekeishiya/formulae" + "nikitabobko/tap" + "railwaycat/emacsmacport" + "js0ny/tap" + ]; + + brews = [ + "folderify" + "coreutils" + ]; + + casks = [ + "visual-studio-code" + "kitty" + "vivaldi" + "neovide" + "clash-verge-rev" + "obsidian" + "mullvad-vpn" + "alacritty" + "alt-tab" + "apparency" + "betterdisplay" + "discord" + "dotnet-sdk" + "iina" + "iterm2" + "karabiner-elements" + "keka" + "localsend" + "ltspice" + "orbstack" + "qlcolorcode" + # "qlimagesize" discontinued. + "qlmarkdown" + "qlstephen" + "qlvideo" + "qspace-pro" + "quicklook-json" + "quicklookase" + "raycast" + "rider" + "rustdesk" + "scroll-reverser" + "sioyek" + "skim" + "squirrel" + "steam" + "telegram-desktop" + "Filen" + "TickTick" + "cherry-studio" + "firefox" + "Wireshark" + "LibreWolf" + "brave-browser" + "font-maple-mono-nf-cn" + ]; + }; + +} diff --git a/nix/hosts/macbook/default.nix b/nix/hosts/macbook/default.nix new file mode 100644 index 0000000..c5855ff --- /dev/null +++ b/nix/hosts/macbook/default.nix @@ -0,0 +1,54 @@ +{ config, pkgs, ... }: + +{ + # Managed by Determinate + nix.enable = false; + system.stateVersion = 6; + system.primaryUser = "js0ny"; + nixpkgs.config.allowUnfree = true; + environment.systemPackages = with pkgs; [ + git + vim + wget + age + aichat + bat + btop + cmake + coreutils + curlie + dos2unix + duf + dust + duti + fastfetch + fd + ffmpeg + fish + fzf + delta + glow + go + hyperfine + imagemagick + just + lazygit + less + lsd + neovim + nushell + pandoc + procs + pnpm + ripgrep + ripgrep-all + starship + tlrc + tmux + uv + zoxide + ]; + + programs.zsh.enable = true; + +} diff --git a/nix/hosts/macbook/system.nix b/nix/hosts/macbook/system.nix new file mode 100644 index 0000000..d489269 --- /dev/null +++ b/nix/hosts/macbook/system.nix @@ -0,0 +1,114 @@ +{ config, pkgs, ... }: + +{ + time.timeZone = "Asia/Shanghai"; + system.defaults = { + dock = { + appswitcher-all-displays = true; + autohide = true; + # Launch Animation + launchanim = false; + # Minimize Animation + mineffect = "suck"; + minimize-to-application = true; + persistent-apps = [ + { app = "/Applications/Vivaldi.app"; } + { app = "/Applications/kitty.app"; } + { app = "/Applications/Obsidian.app"; } + { app = "Applications/Visual Studio Code.app"; } + { app = "/Applications/LibreWolf.app"; } + # { spacer = { small = false; }; } + # { spacer = { small = true; }; } + # { folder = "/System/Applications/Utilities"; } + # { folder = "/Users/js0ny/Downloads/"; } + ]; + persistent-others = [ + "/Users/js0ny/Downloads" + "/Users/js0ny/Source" + ]; + show-recents = false; + orientation = "bottom"; + # tr - Top Right + # tl - Top Left (disable this) + # br - Bottom Right + # bl - Bottom Left + # `1`: Disabled + # `2`: Mission Control + # `3`: Application Windows + # `4`: Desktop + # `5`: Start Screen Saver + # `6`: Disable Screen Saver + # `7`: Dashboard + # `10`: Put Display to Sleep + # `11`: Launchpad + # `12`: Notification Center + # `13`: Lock Screen + # `14`: Quick Note + wvous-tr-corner = 2; + wvous-bl-corner = 11; # Simulate Windows button on Windows + wvous-br-corner = 4; + }; + finder = { + AppleShowAllFiles = true; + ShowStatusBar = true; + ShowPathbar = true; + FXRemoveOldTrashItems = true; + AppleShowAllExtensions = true; + QuitMenuItem = true; + ShowExternalHardDrivesOnDesktop = false; + ShowRemovableMediaOnDesktop = false; + # This will look show full path in title bar + # For example: /Users/username/Downloads + # instead of just Downloads + _FXShowPosixPathInTitle = false; + _FXSortFoldersFirst = true; + FXEnableExtensionChangeWarning = false; + # Use `Home` instead of `PfHm` + # nix-darwin won't parse `PfHm` + NewWindowTarget = "Home"; + }; + trackpad = { + TrackpadRightClick = true; + TrackpadThreeFingerDrag = true; + }; + screencapture = { + location = "~/Pictures/Screenshots"; + type = "png"; + include-date = true; + }; + SoftwareUpdate.AutomaticallyInstallMacOSUpdates = false; + ".GlobalPreferences" = { + "com.apple.sound.beep.sound" = "/System/Library/Sounds/Blow.aiff"; + }; + NSGlobalDomain = { + AppleInterfaceStyle = "Dark"; + AppleInterfaceStyleSwitchesAutomatically = true; + AppleShowAllExtensions = true; + # Use Fn key as standard function keys instead of media keys + "com.apple.keyboard.fnState" = true; + AppleMeasurementUnits = "Centimeters"; + AppleICUForce24HourTime = true; + }; + controlcenter.BatteryShowPercentage = true; + # Fn usage: + # 0: Show Emoji & Symbols + # 1: Change Input Source + # 2: Show Emoji & Symbols + # 3: Start Dictation + hitoolbox.AppleFnUsageType = "Change Input Source"; + WindowManager = { + EnableTilingByEdgeDrag = true; + EnableTopTilingByEdgeDrag = true; + EnableTilingOptionAccelerator = true; + EnableTiledWindowMargins = true; + }; + # universalaccess = { + # mouseDriverCursorSize = 1.5; + # reduceMotion = true; + # reduceTransparency = false; + # }; + menuExtraClock = { + ShowSeconds = true; + }; + }; +} \ No newline at end of file