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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Feature ideas and personal changes
url: https://github.com/kunchenguid/dotfiles/fork
url: https://github.com/digantamisra98/dotfiles/fork
about: Feature requests are not accepted here, but you are welcome to fork this repo and make it yours.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Running the switch builds:
On a brand new Mac, from a bare clone of this repo:

```sh
git clone https://github.com/kunchenguid/dotfiles.git
git clone https://github.com/digantamisra98/dotfiles.git
cd dotfiles
```

Expand All @@ -46,13 +46,12 @@ Change the host label or CPU architecture if needed, and read the Homebrew clean
./bootstrap.sh
```

`bootstrap.sh` does four things, in order:
`bootstrap.sh` does three things, in order:

1. Installs Determinate Nix, if it isn't already installed.
2. Symlinks this repo to `~/.dotfiles`.
This has to happen before the first build, because `home.nix` points at config files through `~/.dotfiles`.
3. Checks the `user` configured in `flake.nix` against your actual macOS username, and offers to fix it for you if they differ.
4. Runs the first `darwin-rebuild switch`.
3. Runs the first `darwin-rebuild switch`.
It fetches the `darwin-rebuild` tool from the nix-darwin 26.05 release branch, then applies this repo's locked flake config.

After that, `darwin-rebuild` exists and you're on the normal workflow below.
Expand All @@ -62,10 +61,11 @@ After that, `darwin-rebuild` exists and you're on the normal workflow below.
Once Nix is installed (`bootstrap.sh` step 1 handles that), you can check that the config builds without touching your system - handy when you have edited something:

```sh
nix flake check --no-build
nix build .#darwinConfigurations.mac.system --dry-run
nix flake check --no-build --impure
nix build .#darwinConfigurations.mac.system --dry-run --impure
```

`--impure` is needed because `flake.nix` reads your username from the environment.
If you renamed the host label in "Make it yours", substitute your label for `mac` in these commands.

## Daily use
Expand All @@ -84,7 +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`.
- **Username**: nothing to change.
`flake.nix` reads your macOS username from the environment at build time (`SUDO_USER` under sudo, `USER` otherwise), so the same branch works on any machine.
Everything else (`configuration.nix`, `home.nix`, home directory paths) is threaded from that one variable.
- **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.
Expand Down
28 changes: 3 additions & 25 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,7 @@ echo "==> Step 2: symlink this repo to ~/.dotfiles"
# has to exist before the first switch or the build will fail to find them.
ln -sfn "$DIR" ~/.dotfiles

echo "==> Step 3: personalize the configured username"
# Do this before any sudo call: sudo resets $USER to root, so whoami has to
# run as the real interactive user first.
REAL_USER="$(whoami)"
FLAKE_USER="$(sed -nE 's/^[[:space:]]*user = "([^"]+)";.*/\1/p' "$DIR/flake.nix" | head -n1)"
if [ -z "$FLAKE_USER" ]; then
echo " Could not find the single \"user = \" line in flake.nix."
echo " Edit flake.nix yourself before continuing."
exit 1
elif [ "$FLAKE_USER" != "$REAL_USER" ]; then
echo " flake.nix is configured for user \"$FLAKE_USER\", but you are \"$REAL_USER\"."
read -r -p " Rewrite flake.nix's \"user = \" line to \"$REAL_USER\"? [y/N] " REPLY
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
sed -i '' -E "s/^([[:space:]]*user = \")[^\"]+(\";.*)/\1${REAL_USER}\2/" "$DIR/flake.nix"
echo " Updated. Review the change with: git diff flake.nix"
else
echo " Skipped. Edit the single \"user = \" line in flake.nix yourself before continuing."
exit 1
fi
else
echo " flake.nix already matches \"$REAL_USER\", nothing to do."
fi

echo "==> Step 4: first darwin-rebuild switch (pinned to nix-darwin-26.05)"
echo "==> Step 3: first darwin-rebuild switch (pinned to nix-darwin-26.05)"
# darwin-rebuild doesn't exist yet on a fresh machine, so run it straight
# from the flake this once. After this, rebuild.sh works normally.
# This fetches the darwin-rebuild tool from the nix-darwin-26.05 release branch,
Expand All @@ -55,8 +32,9 @@ echo "==> Step 4: first darwin-rebuild switch (pinned to nix-darwin-26.05)"
NIX_BIN="$(command -v nix)"
# "mac" is the flake host label - if you renamed it, change it in flake.nix
# and rebuild.sh too.
# --impure lets flake.nix read the username from the environment (SUDO_USER).
sudo "$NIX_BIN" run github:nix-darwin/nix-darwin/nix-darwin-26.05#darwin-rebuild -- \
switch --flake ~/.dotfiles#mac
switch --flake ~/.dotfiles#mac --impure
# If this still fails with "nix: command not found", open a new terminal
# (Determinate adds nix to new shells' PATH) and re-run ./bootstrap.sh.

Expand Down
15 changes: 15 additions & 0 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,33 @@
nix-homebrew = {
enable = true;
inherit user;
# Adopt a pre-existing Homebrew install instead of erroring out. Inert on a
# machine nix-homebrew already manages; needed for a clean first switch on a
# fresh Mac that already had Homebrew (e.g. reproducing this setup elsewhere).
autoMigrate = true;
};
homebrew = {
enable = true;
onActivation.cleanup = "zap"; # remove anything not listed here
onActivation.autoUpdate = true;
onActivation.extraFlags = [ "--force" ];
# Top-level formulae only (from `brew leaves`); dependencies are pulled
# in automatically, so they are intentionally not listed here.
brews = [
"bash"
"fish"
"gemini-cli"
"gh"
"git"
"herdr"
"python@3.14"
"uv"
];
casks = [
"wezterm"
"claude-code"
"copilot-cli"
"opensuperwhisper"
];
};
}
23 changes: 22 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@
home-manager.inputs.nixpkgs.follows = "nixpkgs";

nix-homebrew.url = "github:zhaofengli/nix-homebrew";

# treehouse: git worktree pool manager (Go), installed from its own flake.
treehouse.url = "github:kunchenguid/treehouse";
treehouse.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = inputs@{ self, nix-darwin, nix-homebrew, home-manager, nixpkgs }:
outputs = inputs@{ self, nix-darwin, nix-homebrew, home-manager, nixpkgs, ... }:
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";
# Read the username from the environment at evaluation time, so the same
# branch builds on any machine with no per-machine edits. SUDO_USER wins
# because darwin-rebuild runs under sudo, where USER is "root".
# getEnv needs impure evaluation - rebuild.sh and bootstrap.sh pass --impure.
sudoUser = builtins.getEnv "SUDO_USER";
envUser = builtins.getEnv "USER";
user =
if sudoUser != "" then sudoUser
else if envUser != "" && envUser != "root" then envUser
else throw "Cannot determine the username: run via ./rebuild.sh, or pass --impure so flake.nix can read $USER.";
in
{
darwinConfigurations."mac" = nix-darwin.lib.darwinSystem {
Expand All @@ -30,7 +41,11 @@
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user; };
# Rename any pre-existing dotfile (e.g. a hand-written ~/.zshrc) to
# <name>.backup instead of refusing to overwrite it. Lets the first
# switch adopt a machine that already had these files.
home-manager.backupFileExtension = "backup";
home-manager.extraSpecialArgs = { inherit user inputs; };
home-manager.users.${user} = import ./home.nix;
}
];
Expand Down
34 changes: 33 additions & 1 deletion home.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
{ config, pkgs, user, ... }:
{ config, pkgs, user, inputs, ... }:

let
dotfiles = "${config.home.homeDirectory}/.dotfiles";

# no-mistakes: git-push validation proxy. No upstream flake, so install the
# signed prebuilt release binary directly. This keeps it in the Nix profile via
# rebuild — no curl installer, nothing in /usr/local, no sudo beyond darwin-rebuild.
# To bump: change version + hash (nix-prefetch-url the new darwin-arm64 tarball).
no-mistakes = pkgs.stdenvNoCC.mkDerivation rec {
pname = "no-mistakes";
version = "1.37.0";
src = pkgs.fetchurl {
url = "https://github.com/kunchenguid/no-mistakes/releases/download/v${version}/no-mistakes-v${version}-darwin-arm64.tar.gz";
hash = "sha256-jyrIccDKNdrpV78+IOt8r8/V/H3mIsRuXlGQgZJHSaE=";
};
sourceRoot = "."; # tarball is a single flat binary, no wrapping dir
dontConfigure = true;
dontBuild = true;
dontFixup = true; # skip ALL Mach-O post-processing (strip/re-sign); keeps the upstream
# Developer ID + hardened-runtime signature valid — arm64 kills a
# binary whose signature was invalidated. Nothing to fix in a static Go bin.
installPhase = ''
runHook preInstall
install -Dm755 no-mistakes $out/bin/no-mistakes
runHook postInstall
'';
};
in

{
Expand All @@ -16,6 +40,10 @@ in
jq # json on the command line
lazygit
neovim
# git worktree pool manager, from its own flake input
inputs.treehouse.packages.${pkgs.system}.default
# git-push validation proxy (prebuilt release binary, defined in the let block above)
no-mistakes
# the font everything renders in
nerd-fonts.hack
];
Expand All @@ -32,11 +60,15 @@ in
shellAliases = {
".." = "cd ..";
add = "git add .";
status = "git status";
push = "git push";
pull = "git pull";
gcm = "git commit -m";
gpp = "git push origin main";
m = "git switch main";
cc = "claude --dangerously-skip-permissions";
co = "codex --full-auto";
delds = "find . -type f -name '.DS_Store' -delete";
};
};

Expand Down
17 changes: 16 additions & 1 deletion home/.claude/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
{
"theme": "dark-ansi",
"statusLine": {
"type": "command",
"command": "input=$(cat); model=$(echo \"$input\" | jq -r '.model.display_name'); used=$(echo \"$input\" | jq -r '.context_window.used_percentage // empty'); if [ -n \"$used\" ]; then printf \"%s | ctx: %.0f%% used\" \"$model\" \"$used\"; else printf \"%s\" \"$model\"; fi"
},
"theme": "dark-ansi",
"skipDangerousModePermissionPrompt": true,
"hooks": {
"SessionStart": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "gh-axi",
"timeout": 10
}
]
}
]
}
}
1 change: 1 addition & 0 deletions home/.config/herdr/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
onboarding = false
[keys]
prefix = "ctrl+b"
focus_pane_left = "prefix+h"
Expand Down
4 changes: 2 additions & 2 deletions home/.config/wezterm/wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ local wezterm = require("wezterm")

local config = wezterm.config_builder()

config.color_scheme = "rose-pine-moon"
config.color_scheme = "Dark Violet (base16)"
config.font = wezterm.font("Hack Nerd Font")
config.font_size = 15.0
config.window_background_opacity = 0.8
config.window_background_opacity = 0.7
config.macos_window_background_blur = 50
config.hide_tab_bar_if_only_one_tab = true
config.window_decorations = "RESIZE"
Expand Down
10 changes: 7 additions & 3 deletions home/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# global agent instructions
# Diganta's agent instructions

These are common instructions for Diganta's agents across all scenarios.

# General Guidelines

- Never use the em dash "—". Use plain dash "-" instead
- When writing commit messages, NEVER auto-add your agent name as co-author
Expand All @@ -11,5 +15,5 @@
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.


- When running jobs on compute clusters, always allocate resources that will maximize usage throughout the job.
- When doing literature review, provide a comprehensive report in a HTML or markdown file containing the high level idea of the paper, blogpost, webpage along with central claims, results and potential weaknesses or conflicts with our proposal.
3 changes: 2 additions & 1 deletion rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
ln -sfn "$DIR" ~/.dotfiles
exec sudo darwin-rebuild switch --flake ~/.dotfiles#mac
# --impure lets flake.nix read the username from the environment (SUDO_USER).
exec sudo darwin-rebuild switch --flake ~/.dotfiles#mac --impure