diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 9c1277c..a2862b2 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -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. diff --git a/README.md b/README.md index d55dfb9..473f5b7 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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. @@ -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 @@ -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. diff --git a/bootstrap.sh b/bootstrap.sh index 070a97f..55d6911 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -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, @@ -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. diff --git a/configuration.nix b/configuration.nix index 74baa39..27b2ffd 100644 --- a/configuration.nix +++ b/configuration.nix @@ -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" ]; }; } diff --git a/flake.lock b/flake.lock index 8e22e1a..b0fe676 100644 --- a/flake.lock +++ b/flake.lock @@ -98,7 +98,28 @@ "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treehouse": "treehouse" + } + }, + "treehouse": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1784059781, + "narHash": "sha256-Ulgkf8o2Z8Gt1uyqHEhwSxNUt1zSZ8Yj/Uf2IAb5oC8=", + "owner": "kunchenguid", + "repo": "treehouse", + "rev": "f31e04e052a3fba1f50afedc65f2c781769aab4a", + "type": "github" + }, + "original": { + "owner": "kunchenguid", + "repo": "treehouse", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 96b6b8d..4f3b863 100644 --- a/flake.nix +++ b/flake.nix @@ -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 { @@ -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 + # .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; } ]; diff --git a/home.nix b/home.nix index 365a1cb..500265a 100644 --- a/home.nix +++ b/home.nix @@ -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 { @@ -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 ]; @@ -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"; }; }; diff --git a/home/.claude/settings.json b/home/.claude/settings.json index e3ab775..839184a 100644 --- a/home/.claude/settings.json +++ b/home/.claude/settings.json @@ -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 + } + ] + } + ] } } diff --git a/home/.config/herdr/config.toml b/home/.config/herdr/config.toml index 8fa93ac..5e79fbc 100644 --- a/home/.config/herdr/config.toml +++ b/home/.config/herdr/config.toml @@ -1,3 +1,4 @@ +onboarding = false [keys] prefix = "ctrl+b" focus_pane_left = "prefix+h" diff --git a/home/.config/wezterm/wezterm.lua b/home/.config/wezterm/wezterm.lua index 8bb9ce8..3b176ca 100644 --- a/home/.config/wezterm/wezterm.lua +++ b/home/.config/wezterm/wezterm.lua @@ -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" diff --git a/home/AGENTS.md b/home/AGENTS.md index f9145ba..cd50070 100644 --- a/home/AGENTS.md +++ b/home/AGENTS.md @@ -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 @@ -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. diff --git a/rebuild.sh b/rebuild.sh index b0b6bf1..f43131d 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -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