nix-darwin, home-manager and dotfiles managed by nix.
- nix with nix flakes
- nix-darwin
- home-manager (via nix-darwin but could work as standalone too)
- homebrew casks (via nix-darwin)
- several dev-shells [WIP]
Host | Hardware | named after |
---|---|---|
Kare |
Apple Laptop | Susan Kare |
Hopper |
Apple Laptop | Grace Hopper |
My standard username is pw
. All code will be placed in the ~/Documents/Code/weiland/
directory.
Previously, all my code was stored in ~/src/weiland
.
on a freshly clean mac machine
During Setup:
- Login in to iCloud
- System Settings -> iCloud -> iCloud Drive: enable Desktop & Documents Folders.
- Disable Optimize Mac Storage for Documents (and later in Photos, too), so all data will be downloaded.
Making sure system is up-to-date:
sudo softwareupdate --install --all --restart --verbose
Install command line developer tools:
xcode-select --install
Then, install Xcode from the App Store.
Now, accept the Xcode and SDK license:
sudo xcodebuild -license accept
And make sure Xcode runs:
sudo xcodebuild -runFirstLaunch
Open Xcode go to Preferences, open the Platforms tab and download iOS and VisioOS Simulators.
Actually, I try to avoid it, but looking at you AusweisApp.app
softwareupdate –install-rosetta
Create code directory:
mkdir -p ~/Documents/Code/weiland
mkdir ~/Documents/Code/clones
mkdir ~/Documents/Code/tests
mkdir ~/Documents/Code/go
On a new system, the file modes might be lost, and have to be fixed so the keys can be accessed:
chmod 600 ~/Documents/Configs/ssh/id_pw
Now we can clone. In order to prevent password prompts and because there is no ~/.ssh
directory yet with key pairs, we start with a different key path:
GIT_SSH_COMMAND='ssh -i ~/Documents/Configs/ssh/id_pw -o IdentitiesOnly=yes' git clone git@github.com:weiland/nix-config.git ~/Documents/Code/weiland/nix-config
other ways to clone (if ssh keys or GitHub are already setup):
# using ssh (with default key in ~/.ssh)
git clone git@github.com:weiland/nix-config.git ~/Documents/Code/weiland/nix-config
# or using default (i.e. login to GitHub)
git clone https://github.com/weiland/nix-config.git ~/Documents/Code/weiland/nix-config
If there is no git ...
(which is supposed to be there actually with ventura/sonoma and installed xcode dev-tools)You can follow the next step and install nix and then you can create a nix shell with git
installed temporarely:
nix run nixpkgs#git
# or via old nix-env command
nix-env -iA nixpkgs.git
And now cd into the newly cloned nix-config
directory:
$ cd ~/Documents/Code/weiland/nix-config
Via the official nix installer:
sh <(curl -L https://nixos.org/nix/install)
Or using Determinate Nix Install / fish shell installation
Or using The Determinate Nix Installer, which performs well on mac (esp. after mac upgrades) and brings flake support by default:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
If already in the fish shell:
sh (curl -L https://nixos.org/nix/install | psub)
Enable flakes via config file
Not needed when using my home-manager config (or the Determinate Nix installer).
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
It can run independently but is later controlled via nix-darwin.
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The brew
command will ba available later after applying the home-manager settings.
This will apply the nix-darwin config and the home-manager config, so all mac default preferences will be set as well as all apps, tools and binaries will be installed.
# making sure to be in the right directory
cd ~/Documents/Code/weiland/nix-config
The following commands will install the host Hopper
. Which can be replaced with any other hostname that exists in the ./hosts/
directory.
nix run --extra-experimental-features "nix-command flakes" nix-darwin -- switch --flake .#Hopper
You have to enter your sudo password (at least once, perhaps more often as longer it takes) and click on Allow when prompted.
Or if using flakes remotely:
TODO(weiland): Fix command below
nix flake --extra-experimental-features 'nix-command flakes' init -t github:weiland/nix-config#darwin
The next step is to restart the mac:
sudo reboot
Now nix-command
and flakes
are enabled by default, so --extra-experimental-features
can be omitted.
Run again:
nix run nix-darwin -- switch --flake .#Hopper
# for further times, one can use in any directory:
nix run nix-darwin -- switch --flake ~/.config/nix-darwin#Hopper
(Perhaps Full Disk Access is required. Enabled it in the Privacy & Security System Settings for the current Terminal.)
Set config:
$ defaults write com.googlecode.iterm2 PrefsCustomFolder "/Users/pw/Documents/Code/nix-config/data/iterm"
Alternatively:
- Open iterm2
- General -> Preferences -> check Load preferences from a custom folder or URL
- choose
/Users/pw/Documents/Code/weiland/nix-config/data/iterm
- And don't overwrite the existing one.
- Generally, allow Full Disk Access for iTerm in System Settings -> Privacy & Security
For pre Sonoma:
If no directory can be selected, iterm has no access to the hard disk. This can be fixed by open `System Settings` -> Privacy & Security -> Hard Disk Access -> add _iterm2.app_.Import a new colorscheme
#### Use a different colorschemeSet colorscheme:
open ~/Documents/Code/weiland/nix-config/data/iterm/Oceanic-Next.itermcolors
Open any other additional itermcolors-file.
Other colorschemes for iterm can be found at: https://iterm2colorschemes.com
and should be downloaded to data/iterm/
.
- Open & allow access (in Privacy & Security)
- Open & allow access (in Privacy & Security) & choose recommended
- Set Tracking Speed to Fast
- Click Wallpaper to reveal desktop to Only in Stage Manager
- Import old fish history
[ -e ~/Documents/Backups/fish_history ] && cp ~/Documents/Backups/fish_history ~/.local/share/fish/fish_history
- Import recenttracks.txt (or if new
mv ~/Downloads/recenttracks-*.csv ~/.local/share/recenttracks.csv
) - Optionally: import z history file as well (for the same host)
~/Library/Application\ Support/zoxide/db.zo
- import keyboard layout
sudo cp -r data/keyboard_layout/ABC\ Extended\ German\ Umlauts.bundle /Library/Keyboard\ Layouts/
- restart mac
- System Settings -> Keyboard -> Input Sources -> Edit -> + -> Others
- Allow Accessibility Settings (required for FF Browser extension to work)
- Login to Firefox Sync.
- Adjust Toolbar (remove spaces and unused icons)
- Login to Container Extension.
- Set DDG as default search engine
- Apply DuckDuckGo Settings: https://duckduckgo.com/?kae=-1&k18=1&kaj=m&kak=-1&kao=-1&kap=-1&kaq=-1&kau=-1&kav=1&kax=-1&kp=-2
- Login to email accounts
- Login via Apple (try a few times)
- add main calendar account.
- turn off notification from other calendars
- show calendar week numbers
- uncheck Go to today after adding items in Advanced Settings 🤯
- Adjust items in Finder sidebar to: Recents, Documents, Applications, Downloads, home, TU Darmstadt
- hide tags
- Make sure filename extensions are shown.
- Edit -> Substitutions -> uncheck Emoji Substitutions
- Start new messages from certain email (same goes for FaceTime)
To receive text messages on this mac device.
On the iPhone: - Settings -> Messages -> Text Message Forwarding -> _Enable_ this Mac- TestFlight: Download Element X
- Element X: Login to matrix account & verify session
- gh cli:
gh auth login
: choose GitHub.com, ssh and login via browser - Signal Beta: Login & sync
- Telegram: Login
- Discord: Login
- Tealdeer: Update cache
tldr --update
- Ivory: login to all accounts (
vis.social
,chaos.social
anddet.social
) - Reeder: Login and sync and Sort: Oldest first
- Mela: Set the right Calendar and Reminders.
- Dash: Download Elixir, Vue, Swift and Node docs
- Sublime Text: Tools -> Install Package Control
- Outlook: Login and set Trans Pride Theme
- Slack: Login
- Discord: Login
- Spotify: Under Display Preferences, disable now-playing panel
- Spotify: Disable the Song change notifications
- import from https://someonewhocares.org/hosts/ to
/etc/hosts
- Download the good Siri Voices for VoiceOver etc (Dansk, Norsk, French, German and English)
- Choose nice views
- Remove GarageBand and iMovie
- System Settings -> General -> Storage -> Remove Audio lib (from Garage Band)
- set up cards, address and hide email
via ssh using rsync:
# copy with archive and compress option
rsync -avz -e ssh old@device.local:~/Downloads ~/Downloads
# copying web projects but skipping node modules
rsync -avz -e ssh old@device.local:~/src ~/src --exclude node_modules
Or use Finder for external hard drives or AirDrop.
should be turned on by default
-
System Settings -> Privacy & Security -> Turn On FileVault
-
Also, make sure that Find My Mac is enabled under Apple ID_ -> iCloud.
- Make sure excluded paths are set (General -> Time Machine)
- Plug in external hard drive and set the right volume
- system works after restart
- fish is default shell in iTerm
- git user is correct
- git commits work
- git push via ssh work
# in nix-config directory
nix flake update
# from somewhere else
nix flake update --flake ~/Documents/Code/weiland/nix-config
Formatting nix files:
nix fmt # using nixfmt-rfc-style
- Downloads and Desktop are empty
- Documents and Photos are all synced (and uploaded)
- sync Firefox (on another device, i.e. Phone, Tablet other computer) and Firefox Containers
- backup fish history
cp ~/.local/share/fish/fish_history ~/Documents/Backups
- zoxide history (optional)
cp ~/Library/Application\ Support/zoxide/db.zo ~/Documents/Backups
- export crontab
crontab -l >> ~/Documents/Backups/crontab
- backup recenttracks
cp ~/.local/share/recenttracks.csv ~/Documents/Backups/recenttracks.csv
(or download new one) - manually installed fonts (via Font Book)
- PhotoBooth photos
- VS Code settings and extensions
- optional: leftover Screenshots (in
~/tmp
) - make a full time machine backup
- make sure everything in
~/Documents/Code/
is committed and all branches are pushed (including thisnix-config
repo)