Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Deliberate decisions in this repo - do NOT silently revert them:

- `homebrew.onActivation.cleanup = "zap"` in `configuration.nix` is intentional. It forces the good habit of declaring every Homebrew package in the Nix config instead of installing things ad-hoc, which keeps the machine reproducible. Do not soften it to `uninstall` or `none`. Users are warned about its effect in README.md; this note is for anyone tempted to change the setting itself.
- Never commit `.no-mistakes/` validation evidence to this public repo. `.no-mistakes/` is gitignored; if a validation pipeline stages evidence into a branch, drop it before merging.
- `homebrew.onActivation.cleanup = "none"` in `configuration.nix` is intentional for first adoption on an existing Mac. Do not change it to `zap` until every Homebrew package and cask that should be kept has been declared in `configuration.nix`.
- Never commit `.no-mistakes/` validation evidence to this public repo. `.no-mistakes/` is gitignored; if a validation pipeline stages evidence into a branch, drop it before merging.
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Running the switch builds:
- Shell (zsh, aliases, starship prompt)
- Editor (Neovim config)
- Terminal (WezTerm config)
- Agent configs (Claude, Codex, opencode all share one AGENTS.md)
- Dotfile symlinks for Neovim, WezTerm, and herdr

## Prerequisites

Expand Down Expand Up @@ -84,8 +84,8 @@ No separate build-and-copy step.
This repo is mine.
If you clone it, review these before you run `bootstrap.sh`:

- **Username**: run `./bootstrap.sh` (it detects your macOS username and offers to set it) OR change the single `user = "kunchen"` line in `flake.nix`.
Everything else (`configuration.nix`, `home.nix`, home directory paths) is threaded from that one variable.
- **Username**: this copy is configured for `user = "bytedance"` in `flake.nix`.
The home directory is explicitly set to `/Users/bytedance` in `configuration.nix` and `home.nix`.
- **Host label** `"mac"`, in three places: `flake.nix` (the `darwinConfigurations."mac"` name), `rebuild.sh:5` (the `#mac` at the end of the flake reference), and `bootstrap.sh`'s first-switch command (also `#mac`).
All three have to match.
- **CPU architecture**, `hostPlatform` in `configuration.nix` (see Prerequisites above).
Expand All @@ -104,21 +104,19 @@ programs.git = {
};
```

**Homebrew cleanup warning:** `configuration.nix` sets `homebrew.onActivation.cleanup = "zap"`.
That means every time you switch, Homebrew removes any package or cask on your machine that isn't listed in the `brews` and `casks` arrays in `configuration.nix`.
If you already have Homebrew stuff installed that isn't in that list, the first switch will uninstall it.
Read through `brews` and `casks` before you run `bootstrap.sh` or `rebuild.sh` for the first time, and add anything you want to keep.
**Homebrew cleanup warning:** this copy starts with `homebrew.onActivation.cleanup = "none"`.
That keeps existing Homebrew packages and casks on the first switch, which is safer on a Mac that already has software installed.
After everything you want to keep is listed in the `brews` and `casks` arrays in `configuration.nix`, you can choose whether to tighten this later.

**About `herdr`:** it's in the `brews` list.
It's a real public Homebrew formula (`brew info herdr` finds it in homebrew-core, no tap needed), so it will install fine.
If you don't use it, just remove it from `brews` in your copy.

**Heads-up:**

- `home/AGENTS.md` is my personal agent policy, and `home.nix` installs it for Claude, Codex, and opencode.
If you clone this repo, you'd silently inherit my agent instructions - edit or delete `home/AGENTS.md` if you don't want that.
- The `cc` and `co` shell aliases in `home.nix` are high-agency shortcuts: `claude --dangerously-skip-permissions` and `codex --full-auto`.
They're convenient for me, but know what they do before you use them.
- `home/AGENTS.md` is kept as an optional template only. This copy does not install it over local Claude, Codex, or opencode instruction files.
- `home/.claude/settings.json` is kept in the repo as an optional template only. This copy does not install it over local Claude settings.
- The `cc` and `co` shell aliases in `home.nix` are conservative shortcuts for `claude` and `codex`.

## Repo tour

Expand All @@ -128,7 +126,7 @@ If you don't use it, just remove it from `brews` in your copy.
- `home.nix` - user-level config: shell, packages, prompt, and the symlinks described below.
- `rebuild.sh` - re-applies the config after the first switch.
Run this every time you make a change.
- `home/` - the actual config files that get symlinked into place (Neovim, WezTerm, herdr, Claude settings, the shared `AGENTS.md`).
- `home/` - the actual config files that get symlinked into place (Neovim, WezTerm, herdr). `home/AGENTS.md` and `home/.claude/settings.json` are optional templates and are not installed automatically.

## How the symlinks work

Expand Down
6 changes: 3 additions & 3 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

system.primaryUser = user;
users.users.${user} = {
home = "/Users/${user}";
home = "/Users/bytedance";
};
system.stateVersion = 6;
system.defaults = {
NSGlobalDomain = {
AppleInterfaceStyle = "Dark";
KeyRepeat = 2; # fast key repeat
InitialKeyRepeat = 15; # short delay before repeat
_HIHideMenuBar = true; # auto-hide the menu bar
Expand All @@ -27,11 +26,12 @@
};
nix-homebrew = {
enable = true;
autoMigrate = true;
inherit user;
};
homebrew = {
enable = true;
onActivation.cleanup = "zap"; # remove anything not listed here
onActivation.cleanup = "none"; # first switch: keep existing Homebrew installs
onActivation.autoUpdate = true;
onActivation.extraFlags = [ "--force" ];
brews = [
Expand Down
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
let
# The one username line to change if this isn't your machine.
# bootstrap.sh offers to rewrite this for you if your macOS username differs.
user = "kunchen";
user = "bytedance";
in
{
darwinConfigurations."mac" = nix-darwin.lib.darwinSystem {
Expand All @@ -30,6 +30,7 @@
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "before-nix";
home-manager.extraSpecialArgs = { inherit user; };
home-manager.users.${user} = import ./home.nix;
}
Expand Down
33 changes: 20 additions & 13 deletions home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ in

{
home.username = user;
home.homeDirectory = "/Users/${user}";
home.homeDirectory = "/Users/bytedance";
home.stateVersion = "24.11";
home.packages = with pkgs; [
# cli i use constantly
Expand All @@ -20,7 +20,23 @@ in
nerd-fonts.hack
];
fonts.fontconfig.enable = true;
home.sessionVariables.EDITOR = "nvim";
home.sessionPath = [
"${config.home.homeDirectory}/.npm-global/bin"
"${config.home.homeDirectory}/.local/bin"
"${config.home.homeDirectory}/go/bin"
"${config.home.homeDirectory}/flutter/bin"
"${config.home.homeDirectory}/.pub-cache/bin"
"${config.home.homeDirectory}/.larklink/bin"
"${config.home.homeDirectory}/.bun/bin"
"/usr/local/go/bin"
"/opt/homebrew/bin"
];
home.sessionVariables = {
EDITOR = "nvim";
GOPATH = "${config.home.homeDirectory}/go";
GOROOT = "/usr/local/go";
BUN_INSTALL = "${config.home.homeDirectory}/.bun";
};

programs.zsh = {
enable = true;
Expand All @@ -35,8 +51,8 @@ in
push = "git push";
pull = "git pull";
m = "git switch main";
cc = "claude --dangerously-skip-permissions";
co = "codex --full-auto";
cc = "claude";
co = "codex";
};
};

Expand All @@ -60,13 +76,4 @@ in
config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/nvim";
home.file.".config/herdr".source =
config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/herdr";
home.file.".claude/settings.json".source =
config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.claude/settings.json";

home.file.".claude/CLAUDE.md".source =
config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
home.file.".codex/AGENTS.md".source =
config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
home.file.".config/opencode/AGENTS.md".source =
config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
}
23 changes: 10 additions & 13 deletions home/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# global agent instructions

- Never use the em dash "—". Use plain dash "-" instead
- When writing commit messages, NEVER auto-add your agent name as co-author
- Never manually modify CHANGELOG.md files or any files that are marked as auto-generated
- When making technical decisions, do not give much weight to development cost.
Instead, prefer quality, simplicity, robustness, scalability, and long term maintainability.
- When doing bug fixes, always start with reproducing the bug in an E2E setting as closely aligned with how an end user would experience it as possible.
This makes sure you find the real problem so your fix will actually solve it.
- When end-to-end testing a product, be picky about the UI you see and be obsessed with pixel perfection.
If something clearly looks off, even if it is not directly related to what you are doing, try to get it fixed along the way.
- Apply that same high standard to engineering excellence: lint, test failures, and test flakiness.
If you see one, even if it is not caused by what you are working on right now, still get it fixed.
# Global agent instructions

- Use Chinese for user-facing replies by default.
- Do not use em dashes. Use plain hyphens instead.
- When writing commit messages, never auto-add your agent name as co-author.
- Never manually modify CHANGELOG.md files or any files marked as auto-generated.
- Protect existing user changes. Do not reset, stash, overwrite, or delete unrelated work unless explicitly asked.
- Keep changes surgical. Match the existing style and touch only the files needed for the task.
- Prefer simple, robust, maintainable solutions over shortcuts chosen only to reduce development effort.
- When fixing bugs, reproduce the issue first in a setting close to how the user experiences it.
- Verify meaningful changes with focused tests, lint, type checks, or a clear manual check when automated tests are unavailable.