feat: simplify flake.nix

This commit is contained in:
Ryan Yin
2023-07-26 20:07:42 +08:00
parent eebbb9f5e6
commit 204cb03922
70 changed files with 1183 additions and 1165 deletions

View File

@@ -1,140 +1,35 @@
{ pkgs, ...}: {
{pkgs, ...}: {
##########################################################################
#
# MacOS specific nix-darwin configuration
#
# Nix is not well supported on macOS, I met some strange bug recently.
# So install apps using [homebrew](https://daiderd.com/nix-darwin/manual/index.html#opt-homebrew.enable) here.
#
# Install all apps and packages here.
#
# NOTE: Your can find all available options in:
# https://daiderd.com/nix-darwin/manual/index.html
#
# TODO Fell free to modify this file to fit your needs.
#
##########################################################################
system = {
# Install packages from nix's official package repository.
#
# The packages installed here are available to all users, and are reproducible across machines, and are rollbackable.
# But on macOS, it's less stable than homebrew.
#
# Related Discussion: https://discourse.nixos.org/t/darwin-again/29331
environment.systemPackages = with pkgs; [
neovim
git
nushell # my custom shell
];
environment.variables.EDITOR = "nvim";
# activationScripts are executed every time you boot the system or run `nixos-rebuild` / `darwin-rebuild`.
activationScripts.postUserActivation.text = ''
# activateSettings -u will reload the settings from the database and apply them to the current session,
# so we do not need to logout and login again to make the changes take effect.
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
'';
defaults = {
menuExtraClock.Show24Hour = true; # show 24 hour clock
# customize dock
dock = {
autohide = true;
show-recents = false; # disable recent apps
# customize Hot Corners(触发角, 鼠标移动到屏幕角落时触发的动作)
wvous-tl-corner = 2; # top-left - Mission Control
wvous-tr-corner = 13; # top-right - Lock Screen
wvous-bl-corner = 3; # bottom-left - Application Windows
wvous-br-corner = 4; # bottom-right - Desktop
};
# customize finder
finder = {
_FXShowPosixPathInTitle = true; # show full path in finder title
AppleShowAllExtensions = true; # show all file extensions
FXEnableExtensionChangeWarning = false; # disable warning when changing file extension
QuitMenuItem = true; # enable quit menu item
ShowPathbar = true; # show path bar
ShowStatusBar = true; # show status bar
};
# customize trackpad
trackpad = {
# tap - 轻触触摸板, click - 点击触摸板
Clicking = true; # enable tap to click(轻触触摸板相当于点击)
TrackpadRightClick = true; # enable two finger right click
TrackpadThreeFingerDrag = true; # enable three finger drag
};
# customize macOS
NSGlobalDomain = {
# `defaults read NSGlobalDomain "xxx"`
"com.apple.swipescrolldirection" = true; # enable natural scrolling(default to true)
"com.apple.sound.beep.feedback" = 0; # disable beep sound when pressing volume up/down key
AppleInterfaceStyle = "Dark"; # dark mode
AppleKeyboardUIMode = 3; # Mode 3 enables full keyboard control.
ApplePressAndHoldEnabled = true; # enable press and hold
# If you press and hold certain keyboard keys when in a text area, the keys character begins to repeat.
# This is very useful for vim users, they use `hjkl` to move cursor.
# sets how long it takes before it starts repeating.
InitialKeyRepeat = 15; # normal minimum is 15 (225 ms), maximum is 120 (1800 ms)
# sets how fast it repeats once it starts.
KeyRepeat = 3; # normal minimum is 2 (30 ms), maximum is 120 (1800 ms)
NSAutomaticCapitalizationEnabled = false; # disable auto capitalization(自动大写)
NSAutomaticDashSubstitutionEnabled = false; # disable auto dash substitution(智能破折号替换)
NSAutomaticPeriodSubstitutionEnabled = false; # disable auto period substitution(智能句号替换)
NSAutomaticQuoteSubstitutionEnabled = false; # disable auto quote substitution(智能引号替换)
NSAutomaticSpellingCorrectionEnabled = false; # disable auto spelling correction(自动拼写检查)
NSNavPanelExpandedStateForSaveMode = true; # expand save panel by default(保存文件时的路径选择/文件名输入页)
NSNavPanelExpandedStateForSaveMode2 = true;
};
# customize settings that not supported by nix-darwin directly
CustomUserPreferences = {
NSGlobalDomain = {
# Add a context menu item for showing the Web Inspector in web views
WebKitDeveloperExtras = true;
};
"com.apple.finder" = {
ShowExternalHardDrivesOnDesktop = true;
ShowHardDrivesOnDesktop = true;
ShowMountedServersOnDesktop = true;
ShowRemovableMediaOnDesktop = true;
_FXSortFoldersFirst = true;
# When performing a search, search the current folder by default
FXDefaultSearchScope = "SCcf";
};
"com.apple.desktopservices" = {
# Avoid creating .DS_Store files on network or USB volumes
DSDontWriteNetworkStores = true;
DSDontWriteUSBStores = true;
};
"com.apple.screensaver" = {
# Require password immediately after sleep or screen saver begins
askForPassword = 1;
askForPasswordDelay = 0;
};
"com.apple.screencapture" = {
location = "~/Desktop";
type = "png";
};
"com.apple.AdLib" = {
allowApplePersonalizedAdvertising = false;
};
# Prevent Photos from opening automatically when devices are plugged in
"com.apple.ImageCapture".disableHotPlug = true;
};
loginwindow = {
GuestEnabled = false; # disable guest user
SHOWFULLNAME = true; # show full name in login window
};
};
# keyboard settings is not very useful on macOS
# the most important thing is to remap option key to alt key globally,
# but it's not supported by macOS yet.
keyboard = {
enableKeyMapping = true; # enable key mapping so that we can use `option` as `control`
# NOTE: do NOT support remap capslock to both control and escape at the same time
remapCapsLockToControl = false; # remap caps lock to control, useful for emac users
remapCapsLockToEscape = true; # remap caps lock to escape, useful for vim users
# swap left command and left alt
# so it matches common keyboard layout: `ctrl | command | alt`
#
# disabled, caused only problems!
swapLeftCommandAndLeftAlt = false;
};
};
# Create /etc/zshrc that loads the nix-darwin environment.
# this is required if you want to use darwin's default shell - zsh
programs.zsh.enable = true;
environment.shells = [
pkgs.zsh
pkgs.nushell # my custom shell
];
# Homebrew Mirror
environment.variables = {
@@ -145,12 +40,11 @@
HOMEBREW_PIP_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple";
};
# homebrew need to be installed manually, see https://brew.sh
homebrew = {
# TODO Homebrew install takes a long time,
# So only enable this when you make changes.
enable = false;
# TODO Homebrew install takes a long time,
# So only enable this when you make changes.
enable = true;
onActivation = {
autoUpdate = false;
@@ -161,12 +55,12 @@
# Applications to install from Mac App Store using mas.
# You need to install all these Apps manually first so that your apple account have records for them.
# otherwise Apple Store will refuse to install them.
# For details, see https://github.com/mas-cli/mas
# For details, see https://github.com/mas-cli/mas
masApps = {
# Xcode = 497799835;
Wechat = 836500024;
QQ = 451108668;
WeCom = 1189898970; # Wechat for Work
WeCom = 1189898970; # Wechat for Work
TecentMetting = 1484048379;
NeteaseCloudMusic = 944848654;
QQMusic = 595615424;
@@ -184,22 +78,25 @@
brews = [
# `brew install`
"wget" # download tool
"curl" # no not install curl via nixpkgs, it's not working well on macOS!
"aria2" # download tool
"httpie" # http client
"wireguard-tools" # wireguard
"wget" # download tool
"curl" # no not install curl via nixpkgs, it's not working well on macOS!
"aria2" # download tool
"httpie" # http client
"wireguard-tools" # wireguard
# Usage:
# https://github.com/tailscale/tailscale/wiki/Tailscaled-on-macOS#run-the-tailscaled-daemon
# 1. `sudo tailscaled install-system-daemon`
# 2. `tailscale up --accept-routes`
"tailscale" # tailscale
"tailscale" # tailscale
# https://github.com/rgcr/m-cli
"m-cli" #  Swiss Army Knife for macOS
];
# `brew install --cask`
casks = [
"squirrel" # input method for Chinese, rime-squirrel
"squirrel" # input method for Chinese, rime-squirrel
"firefox"
"google-chrome"
@@ -213,20 +110,20 @@
"microsoft-remote-desktop"
# "anki"
"clashx" # proxy tool
"iina" # video player
"openinterminal-lite" # open current folder in terminal
"syncthing" # file sync
"raycast" # (HotKey: alt/option + space)search, caculate and run scripts(with many plugins)
"iglance" # beautiful system monitor
"eudic" # 欧路词典
"clashx" # proxy tool
"iina" # video player
"openinterminal-lite" # open current folder in terminal
"syncthing" # file sync
"raycast" # (HotKey: alt/option + space)search, caculate and run scripts(with many plugins)
"iglance" # beautiful system monitor
"eudic" # 欧路词典
# "reaper" # audio editor
# Development
"insomnia" # REST client
"wireshark" # network analyzer
"jdk-mission-control" # Java Mission Control
"google-cloud-sdk" # Google Cloud SDK
"insomnia" # REST client
"wireshark" # network analyzer
"jdk-mission-control" # Java Mission Control
"google-cloud-sdk" # Google Cloud SDK
];
};
}