This commit is contained in:
Harivansh Rathi 2026-03-12 19:06:07 -04:00
parent 02c996d21a
commit 28622332a3
83 changed files with 6969 additions and 57 deletions

13
home/claude.nix Normal file
View file

@ -0,0 +1,13 @@
{...}: {
home.file.".claude/CLAUDE.md".source = ../config/claude/CLAUDE.md;
home.file.".claude/commands" = {
source = ../config/claude/commands;
recursive = true;
};
home.file.".claude/settings.json".source = ../config/claude/settings.json;
home.file.".claude/settings.local.json".source = ../config/claude/settings.local.json;
home.file.".claude/statusline.sh" = {
source = ../config/claude/statusline.sh;
executable = true;
};
}

4
home/codex.nix Normal file
View file

@ -0,0 +1,4 @@
{...}: {
home.file.".codex/AGENTS.md".source = ../config/codex/AGENTS.md;
home.file.".codex/config.toml".source = ../config/codex/config.toml;
}

View file

@ -1,12 +1,22 @@
{...}: {
imports = [
./bat.nix
./dotfiles.nix
./claude.nix
./codex.nix
./gcloud.nix
./gh.nix
./ghostty.nix
./git.nix
./karabiner.nix
./k9s.nix
./lazygit.nix
./nvim.nix
./rectangle.nix
./tmux.nix
./zsh.nix
];
home.stateVersion = "24.11";
programs.home-manager.enable = true;
xdg.enable = true;
}

View file

@ -1,36 +0,0 @@
{
config,
lib,
...
}: let
dotfilesDir = "${config.home.homeDirectory}/dots";
link = path: config.lib.file.mkOutOfStoreSymlink "${dotfilesDir}/${path}";
in {
home.activation.ensureDotfilesRepo = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
if [ ! -d "${dotfilesDir}" ]; then
echo "Expected dotfiles repo at ${dotfilesDir}"
exit 1
fi
'';
home.file.".aerospace.toml".source = link "aerospace/.aerospace.toml";
home.file.".zshenv".source = link "zsh/.zshenv";
home.file.".zshrc".source = link "zsh/.zshrc";
home.file.".config/nvim".source = link "nvim/.config/nvim";
home.file.".config/karabiner/karabiner.json".source =
link "karabiner/.config/karabiner/karabiner.json";
home.file.".claude/CLAUDE.md".source = link "claude/.claude/CLAUDE.md";
home.file.".claude/commands".source = link "claude/.claude/commands";
home.file.".claude/settings.json".source = link "claude/.claude/settings.json";
home.file.".claude/statusline.sh".source = link "claude/.claude/statusline.sh";
home.file.".codex/AGENTS.md".source = link "codex/.codex/AGENTS.md";
home.file.".codex/config.toml".source = link "codex/.codex/config.toml";
home.file."Library/Application Support/lazygit/config.yml".source =
link "lazygit/Library/Application Support/lazygit/config.yml";
}

10
home/gcloud.nix Normal file
View file

@ -0,0 +1,10 @@
{lib, ...}: {
xdg.configFile."gcloud/active_config".text = "default\n";
xdg.configFile."gcloud/configurations/config_default".text = lib.generators.toINI {} {
core = {
account = "rathiharivansh@gmail.com";
project = "hari-gc";
};
};
}

16
home/gh.nix Normal file
View file

@ -0,0 +1,16 @@
{...}: {
programs.gh = {
enable = true;
gitCredentialHelper.enable = false;
settings = {
git_protocol = "https";
prompt = "enabled";
prefer_editor_prompt = "disabled";
aliases = {
co = "pr checkout";
};
};
};
}

17
home/k9s.nix Normal file
View file

@ -0,0 +1,17 @@
{...}: {
programs.k9s = {
enable = true;
views = {
"v1/pods" = {
columns = [
"NAME"
"USER:.metadata.labels.handle"
"STATUS"
"READY"
"AGE"
];
};
};
};
}

4
home/karabiner.nix Normal file
View file

@ -0,0 +1,4 @@
{...}: {
xdg.configFile."karabiner/karabiner.json".source =
../config/karabiner/karabiner.json;
}

4
home/lazygit.nix Normal file
View file

@ -0,0 +1,4 @@
{...}: {
home.file."Library/Application Support/lazygit/config.yml".source =
../config/lazygit/config.yml;
}

50
home/nvim.nix Normal file
View file

@ -0,0 +1,50 @@
{
lib,
pkgs,
...
}: let
nvimConfig = lib.cleanSourceWith {
src = ../config/nvim;
filter = path: type: builtins.baseNameOf path != ".git";
};
python = pkgs.writeShellScriptBin "python" ''
exec ${pkgs.python3}/bin/python3 "$@"
'';
in {
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
defaultEditor = true;
withNodeJs = true;
extraPackages = with pkgs; [
bat
clang-tools
fd
fzf
gh
git
go_1_26
gopls
lua-language-server
pyright
python
python3
ripgrep
rust-analyzer
rustup
stylua
vscode-langservers-extracted
nodePackages.bash-language-server
nodePackages.typescript
nodePackages.typescript-language-server
];
};
xdg.configFile."nvim" = {
source = nvimConfig;
recursive = true;
};
}

4
home/rectangle.nix Normal file
View file

@ -0,0 +1,4 @@
{...}: {
home.file."Library/Preferences/com.knollsoft.Rectangle.plist".source =
../config/rectangle/Rectangle.plist;
}

256
home/zsh.nix Normal file
View file

@ -0,0 +1,256 @@
{
config,
lib,
pkgs,
...
}: {
home.activation.ensureOhMyZshCache = lib.hm.dag.entryAfter ["writeBoundary"] ''
mkdir -p "${config.xdg.cacheHome}/oh-my-zsh"
'';
home.packages = [pkgs.oh-my-zsh];
programs.zsh = {
enable = true;
enableCompletion = false;
defaultKeymap = "viins";
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
c = "codex --dangerously-bypass-approvals-and-sandbox";
ca = "cursor-agent";
cc = "claude --dangerously-skip-permissions";
ch = "claude-handoff";
cl = "clear";
gc = "git commit";
gd = "git diff";
gk = "git checkout";
gp = "git push";
gpo = "git pull origin";
gs = "git status";
ld = "lumen diff";
lg = "lazygit";
nim = "nvim .";
sshnet = "ssh -i ~/.ssh/atlas-ssh.txt rathiharivansh@152.53.195.59";
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
};
envExtra = ''
. "$HOME/.cargo/env"
'';
initContent = lib.mkMerge [
(lib.mkOrder 550 ''
# OpenSpec shell completions configuration
fpath=("$HOME/.oh-my-zsh/custom/completions" $fpath)
'')
(lib.mkOrder 800 ''
export ZSH="${pkgs.oh-my-zsh}/share/oh-my-zsh"
export ZSH_CACHE_DIR="${config.xdg.cacheHome}/oh-my-zsh"
ZSH_THEME="agnoster"
plugins=(git)
ZSH_DISABLE_COMPFIX=true
source "$ZSH/oh-my-zsh.sh"
'')
(lib.mkOrder 1000 ''
export HOMEBREW_PREFIX="/opt/homebrew"
export HOMEBREW_CELLAR="/opt/homebrew/Cellar"
export HOMEBREW_REPOSITORY="/opt/homebrew"
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
export MANPATH="/opt/homebrew/share/man''${MANPATH+:$MANPATH}:"
export INFOPATH="/opt/homebrew/share/info:''${INFOPATH:-}"
if [[ -f ~/.config/secrets/shell.zsh ]]; then
source ~/.config/secrets/shell.zsh
elif [[ -f ~/.secrets ]]; then
source ~/.secrets
fi
export PATH="$HOME/.local/bin:$PATH"
export PATH="${pkgs.postgresql_16}/bin:$PATH"
export PATH="$HOME/.opencode/bin:$PATH"
eval "$(zoxide init zsh)"
[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
export PATH="$HOME/.antigravity/antigravity/bin:$PATH"
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
export PNPM_HOME="$HOME/Library/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
export PATH="$HOME/.amp/bin:$PATH"
unalias ga 2>/dev/null
ga() {
if [[ $# -eq 0 ]]; then
git add .
else
git add "$@"
fi
}
git() {
command git "$@"
local exit_code=$?
case "$1" in
add|stage|reset|checkout)
if command -v critic >/dev/null 2>&1; then
( critic review 2>/dev/null & )
fi
;;
esac
return $exit_code
}
iosrun() {
local project=$(find . -maxdepth 1 -name "*.xcodeproj" | head -1)
local scheme=$(basename "$project" .xcodeproj)
local derived=".derived-data"
local sim_name="''${1:-iPhone 16e}"
if [[ -z "$project" ]]; then
echo "No .xcodeproj found in current directory"
return 1
fi
echo "Building $scheme..."
if ! xcodebuild -project "$project" -scheme "$scheme" \
-destination "platform=iOS Simulator,name=$sim_name" \
-derivedDataPath "$derived" build -quiet; then
echo "Build failed"
return 1
fi
echo "Build succeeded. Launching simulator..."
xcrun simctl boot "$sim_name" 2>/dev/null
open -a Simulator
local app_path="$derived/Build/Products/Debug-iphonesimulator/$scheme.app"
local bundle_id=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$app_path/Info.plist")
echo "Installing $scheme..."
while ! xcrun simctl install "$sim_name" "$app_path" 2>/dev/null; do
sleep 0.5
done
echo "Launching $bundle_id..."
while ! xcrun simctl launch "$sim_name" "$bundle_id" 2>&1 | grep -q "$bundle_id"; do
sleep 0.5
done
echo "Launched $bundle_id - streaming logs (Ctrl+C to stop)"
echo "----------------------------------------"
xcrun simctl spawn "$sim_name" log stream \
--predicate "(subsystem CONTAINS '$bundle_id' OR process == '$scheme') AND NOT subsystem BEGINSWITH 'com.apple'" \
--style compact \
--color always 2>/dev/null | while read -r line; do
if [[ "$line" == *"error"* ]] || [[ "$line" == *"Error"* ]]; then
echo "\033[31m$line\033[0m"
elif [[ "$line" == *"warning"* ]] || [[ "$line" == *"Warning"* ]]; then
echo "\033[33m$line\033[0m"
else
echo "$line"
fi
done
}
mdview() {
markserv "$1"
}
if command -v wt >/dev/null 2>&1; then
eval "$(command wt config shell init zsh)"
fi
wtc() { wt switch --create --base @ "$@"; }
unalias gpr 2>/dev/null
gpr() {
while true; do
local pr=$(gh pr list --limit 50 \
--json number,title,author,headRefName \
--template '{{range .}}#{{.number}} {{.title}} ({{.author.login}}) [{{.headRefName}}]{{"\n"}}{{end}}' \
| fzf --preview 'gh pr view {1} --comments' \
--preview-window=right:60%:wrap \
--header 'enter: view | ctrl-m: merge | ctrl-x: close | ctrl-o: checkout | ctrl-b: browser' \
--bind 'ctrl-o:execute(gh pr checkout {1})' \
--bind 'ctrl-b:execute(gh pr view {1} --web)' \
--expect=ctrl-m,ctrl-x,enter)
[[ -z "$pr" ]] && return
local key=$(echo "$pr" | head -1)
local selection=$(echo "$pr" | tail -1)
local num=$(echo "$selection" | grep -o '#[0-9]*' | tr -d '#')
[[ -z "$num" ]] && return
case "$key" in
ctrl-m)
echo "Merge PR #$num? (y/n)"
read -q && gh pr merge "$num" --merge
echo
;;
ctrl-x)
echo "Close PR #$num? (y/n)"
read -q && gh pr close "$num"
echo
;;
enter|"")
gh pr view "$num"
;;
esac
done
}
ghpr() {
local base=$(git rev-parse --abbrev-ref HEAD)
local upstream="''${1:-main}"
local remote_ref="origin/$upstream"
local unpushed=$(git log "$remote_ref"..HEAD --oneline 2>/dev/null)
if [[ -z "$unpushed" ]]; then
if git diff --cached --quiet; then
echo "No unpushed commits and no staged changes"
return 1
fi
echo "No unpushed commits, but staged changes found. Opening commit dialog..."
git commit || return 1
fi
local msg=$(git log "$remote_ref"..HEAD --format='%s' --reverse | head -1)
local branch=$(echo "$msg" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
git checkout -b "$branch"
git checkout "$base"
git reset --hard "$remote_ref"
git checkout "$branch"
git push -u origin "$branch"
gh pr create --base "$upstream" --fill --web 2>/dev/null || gh pr create --base "$upstream" --fill
gh pr view "$branch" --json url -q '.url'
}
'')
(lib.mkAfter ''
bindkey '^k' forward-car
bindkey '^j' backward-car
'')
];
};
}