Initialize a new mac

Table of Contents

1. Prepare

cd
mkdir projects
cd projects
mkdir personal others xmind
touch xmind/.gitconfig
[user]
  email = kevin@xmind.app

2. Manual

2.1. xcode

2.2. better touch tool3(not needed)

2.3. firefox configuration, chrome

2.4. instead by the latter with brew cask

2.4.1. ShowyEdge

2.4.2. Surge3 / ClashX

2.4.3. alfred3 / raycast

3. Install Nix

3.1. Install

sh <(curl -L https://nixos.org/nix/install)

3.2. Install git

nix-env -qaP --description git
nix-env -iA nixpkgs.gitFull
nix-env -i corkscrew
ssh-keygen -t ed25519 -C "kkxandeer@gmail.com"
vi ~/.ssh/config
pbcopy < ~/.ssh/id_ed25519.pub

Copy ssh pub to Github.

Copy below to ~/.ssh/config. This has migrated to dots.

Host *
  IgnoreUnknown UseKeychain
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519
  ForwardAgent yes
  ProxyCommand ~/.nix-profile/bin/corkscrew localhost 8010 %h %p  ~/.ssh/id_ed25519

3.3. Install nix-darwin

nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer
rm -rf result

3.4. Install dotfiles

nix-env -i stow
mkdir -p ~/projects/personal
cd ~/projects/personal
git clone git@github.com:xandeer/dotfiles.git
cd dotfiles
# after gpg2 installed
make dedot
make install
darwin-rebuild switch
cd ~
mr -j 9 update

3.5. FAQ

3.5.1. opening lock file '/nix/store/*.lock': Permission denied

sudo chown -R kevin:staff /nix

4. Brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# https://homebrew-file.readthedocs.io/en/latest/installation.html
/bin/bash -c "$(curl -fsSL https://raw.github.com/rcmdnk/homebrew-file/install/install.sh)"

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

brew file install

4.1. Karabiner

brew services start goku

4.2. faq

4.2.1. fatal: could not resolve head to a revision

git -C $(brew --repository homebrew/core) checkout master
# or
git -C $(brew --repository homebrew/core) reset --hard HEAD

5. nvm (disabled)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
src
nvm install node

6. tdlib telega

g clone https://github.com/tdlib/td.git
cd td
rmrf build
take build
# cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DZLIB_LIBRARY=/usr/local/opt/zlib/lib/ -DZLIB_INCLUDE_DIR=/usr/local/opt/zlib/include ..
cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ ..
cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@1.1/ ..
make -j8
rm /usr/local/lib/libtdjson.*
sudo make install
cd ~/.emacs.d/straight/repos/telega.el
git checkout master
git pull
(telega-server-build)

7. emacs

7.1. Install icon fonts

(all-the-icons-install-fonts)