{ config, pkgs, lib, ... }: let home = config.home.homeDirectory; dotfiles = "${home}/.dotfiles"; firstmateHome = "${home}/Documents/firstmate"; # yt-transcribe: captions-first transcription for YouTube/X/local media. # Source of truth is this repo's home/bin scripts; nix copies them into the # store so every context (launchd, shells) executes from local disk. Stable # ~/.local/bin symlinks below survive store-path changes between rebuilds. ytTranscribe = pkgs.runCommand "yt-transcribe" { } '' install -Dm755 ${./home/bin/yt-transcribe} $out/bin/yt-transcribe ''; # Pinned pstack skills tree (cursor/plugins). `tdd` is deliberately absent: # an existing user-level tdd skill owns that name. See firstmate's # docs/adopted-skills.md for why these eleven skills exist. pstackSkillNames = [ "statechart" "create-verification-skill" "maintain-verification-skill" "correct" "benchmark-checklist" "architect" "technical-writing" "unslop" "recall" "ketchup" "blast-radius" ]; pstackSkills = pkgs.fetchFromGitHub { owner = "cursor"; repo = "plugins"; rev = "6b0300214a09fd6029cfb7077043125758cd1fd2"; hash = "sha256-TDuZ1v+taPdqyvvCs1VHUjtpSy8zHxhQKJv/kIPTpK8="; }; in { home.username = "laptran"; home.homeDirectory = "/Users/laptran"; home.stateVersion = "24.11"; # home-configuration.nix(5) is generated via options.json that embeds a # nixpkgs store path without string context. Determinate Nix warns on every # rebuild. Package man pages are unaffected. manual.manpages.enable = false; home.packages = with pkgs; [ ripgrep fd fzf jq lazygit neovim nerd-fonts.hack ngrok # reverse TCP tunnel so the phone can SSH in over cellular (unfree) beets # music tagger / library organizer + navidrome sync plugin ] ++ [ ytTranscribe ]; home.file.".local/bin/actionlint" = { source = "${pkgs.actionlint}/bin/actionlint"; force = true; }; home.file.".local/bin/shellcheck" = { source = "${pkgs.shellcheck}/bin/shellcheck"; force = true; }; fonts.fontconfig.enable = true; home.sessionVariables.EDITOR = "nvim"; programs.zsh = { enable = true; autosuggestion.enable = true; # ghost text from history syntaxHighlighting.enable = true; # commands turn green when valid initContent = '' bindkey '^f' autosuggest-accept # Keep the OpenCode Go CLI, Pi, no-mistakes, and Hermes key aligned with # the desktop app login after an account switch. if [ -x "$HOME/.local/bin/opencode-go-key-sync" ]; then "$HOME/.local/bin/opencode-go-key-sync" >/dev/null 2>&1 || true fi ''; shellAliases = { ".." = "cd .."; ll = "ls -plart"; add = "git add ."; push = "git push"; pull = "git pull"; m = "git switch main"; # High-agency agent launchers (same idea across tools) cc = "claude --dangerously-skip-permissions"; co = "codex --full-auto"; gb = "grok --yolo"; # firstmate primary session in OpenCode 2 on the OpenCode Go subscription, # launched through the isolated-config oc2 wrapper; crewmates = OpenCode by # default. Permanent since 2026-11-15: fm-pi stays only as the explicit Pi # fallback, never as the default launcher. fm-oc2 is the explicit # OpenCode 2 name and stays byte-identical to fm. fm = "cd ${firstmateHome} && exec ${home}/.local/bin/oc2"; fm-oc2 = "cd ${firstmateHome} && exec ${home}/.local/bin/oc2"; fm-pi = "cd ${firstmateHome} && exec pi"; oc2 = "${home}/.local/bin/oc2"; # Sync ~/Music into the beets library on Unraid (requires NAS mounted). sync-music = "~/.local/bin/sync-music"; # Transcribe a YouTube/X URL or a local media file. Tool code lives in # this repo (nix store); the Unraid share holds only data — mount it at # /Volumes/data (or set YT_SHARE_ROOT for a different mount point). yt-transcribe = "${home}/.local/bin/yt-transcribe"; # Start the reverse tunnel so you can SSH into this Mac from your phone. # Run once when you go remote: `ngrok-tunnel`. Reads authtoken from # ~/.config/ngrok (set once per machine with `ngrok config add-authtoken `) ngrok-tunnel = "ngrok tcp 22"; }; }; programs.starship = { enable = true; settings = { add_newline = false; format = "$directory$git_branch$git_status$cmd_duration$line_break$character"; character = { success_symbol = "[❯](purple)"; error_symbol = "[❯](red)"; }; cmd_duration.format = "[$duration]($style) "; }; }; # Edit-in-place: real file stays in the repo; live path is an out-of-store symlink. # force = true: replace a pre-existing regular file once; source of truth is home/. home.file.".config/wezterm" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/wezterm"; force = true; }; home.file.".config/nvim" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/nvim"; force = true; }; # herdr treats ~/.config/herdr as both its config directory and its state # directory: it writes its sockets, logs, lock files and session state beside # config.toml, and it offers no option to relocate them. Keep that directory a # real directory and link only the config file - a whole-directory symlink into # this repo makes every running herdr server dirty the working tree. The exact # artifact list is the cleanup below, so it cannot drift from the code. home.file.".config/herdr/config.toml" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/herdr/config.toml"; force = true; }; # Migration from the previous whole-directory symlink at ~/.config/herdr. # home-manager links ~/.config/herdr/config.toml by following the existing # ~/.config/herdr symlink, which would move this repo's own tracked config.toml # to config.toml.backup and leave a symlink inside the tree. Drop the stale # symlink in the write phase, after writeBoundary and before linkGeneration: # checkLinkTargets already skips this target because the file is force = true, # and linkGeneration then creates the real directory. A real directory (the # post-migration state) is left untouched, so this is idempotent. The old # whole-directory symlink also left herdr runtime state (sockets, logs, # session.json, session-snapshots/, ...) in this repo; that state now resolves # to the real directory, so remove the known runtime artifacts by name. # config.toml and any other repo content in that directory are never touched. # Removing a live socket or log only drops the path - the running herdr server # keeps its own file handles. home.activation.herdrConfigDir = lib.hm.dag.entryBetween [ "linkGeneration" ] [ "writeBoundary" ] '' set -euo pipefail if [ -L "$HOME/.config/herdr" ]; then run ${pkgs.coreutils}/bin/rm "$HOME/.config/herdr" fi repoHerdr="${dotfiles}/home/.config/herdr" if [ -d "$repoHerdr" ]; then run ${pkgs.coreutils}/bin/rm -rf \ "$repoHerdr/herdr.sock" \ "$repoHerdr/herdr-client.sock" \ "$repoHerdr/herdr.sock.agent" \ "$repoHerdr/herdr-server.log" \ "$repoHerdr/herdr-client.log" \ "$repoHerdr/.plugins.lock" \ "$repoHerdr/session.json" \ "$repoHerdr/release-notes.json" \ "$repoHerdr/session-snapshots" \ "$repoHerdr/sessions" fi ''; # Beets music library manager - managed by nixpkgs package, config symlinked below. home.file.".config/beets" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/beets"; force = true; }; # Claude Code settings (also read by Grok for permissions/compat) home.file.".claude/settings.json" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.claude/settings.json"; force = true; }; # Shared agent policy - one file, many harnesses home.file.".claude/CLAUDE.md" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md"; force = true; }; home.file.".codex/AGENTS.md" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md"; force = true; }; # Codex provider routing -> OpenCode Go. ~/.codex/config.toml is deliberately # NOT symlinked: the ChatGPT desktop app owns and rewrites that file. The repo # fragment home/.codex/config.toml is merged into it by # home.activation.codexOpenCodeGo instead. The provider's command-backed auth # runs this helper, which reads the key from the opencode store. home.file.".local/bin/opencode-go-token" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/opencode-go-token"; force = true; }; # Copy the desktop app's OpenCode Go login into the CLI, Pi, and Hermes stores. # The app writes opencode.db only; those tools read auth.json and .env. home.file.".local/bin/opencode-go-key-sync" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/opencode-go-key-sync"; force = true; }; # Codex 0.160+ profiles live in $CODEX_HOME/.config.toml. The app does not # touch these, so they can be symlinked normally. home.file.".codex/luna.config.toml" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.codex/luna.config.toml"; force = true; }; home.file.".config/opencode/AGENTS.md" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md"; force = true; }; home.file.".config/opencode/opencode.json" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/opencode/opencode.json"; force = true; }; home.file.".config/opencode/skills" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/opencode/skills"; force = true; }; # OpenCode isolated config - keep it separate from ~/.config/opencode home.file.".config/opencode2/opencode.json" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/opencode2/opencode.json"; force = true; }; home.file.".config/opencode2/AGENTS.md" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md"; force = true; }; home.file.".local/bin/oc2" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/oc2"; force = true; }; home.file.".local/bin/security-audit-sandbox" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/security-audit-sandbox"; force = true; }; # Stable symlink for yt-transcribe: shells exec it from local disk. The # repo's home/bin script is the source of truth — a repo edit takes effect # on the next rebuild; the Unraid share holds only data. home.file.".local/bin/yt-transcribe" = { source = "${ytTranscribe}/bin/yt-transcribe"; }; home.file.".grok/AGENTS.md" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md"; force = true; }; # Grok Build native config home.file.".grok/config.toml" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.grok/config.toml"; force = true; }; # Pi agent - source of truth under home/.pi (sessions/auth/npm stay live under ~/.pi) home.file.".pi/agent/settings.json" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.pi/agent/settings.json"; force = true; }; home.file.".pi/agent/models.json" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.pi/agent/models.json"; force = true; }; home.file.".pi/agent/themes" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.pi/agent/themes"; force = true; }; home.file.".pi/agent/extensions/terminal-status-title.js" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.pi/agent/extensions/terminal-status-title.js"; force = true; }; home.file.".pi/agent/extensions/calm" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.pi/agent/extensions/calm"; force = true; }; home.file.".pi/agent/AGENTS.md" = { source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md"; force = true; }; # firstmate is a mutable agent distro (self-update, state/, projects/). Clone once; # never put it in the Nix store. Seed OpenCode+herdr defaults only when absent. # Do NOT npm install -g here: activation PATH often resolves Nix's npm, which # cannot write into the store (EACCES). The firstmate companion CLIs (*-axi) # are installed by home.activation.axiTools below via Homebrew's node. home.activation.firstmate = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail fm="${firstmateHome}" git="${pkgs.git}/bin/git" if [ ! -d "$fm/.git" ]; then mkdir -p "$(dirname "$fm")" $git clone https://github.com/kunchenguid/firstmate.git "$fm" fi mkdir -p "$fm/config" "$fm/data" "$fm/state" "$fm/projects" # Local gitignored operating choices (do not overwrite captain edits) [ -f "$fm/config/backend" ] || printf 'herdr\n' > "$fm/config/backend" [ -f "$fm/config/crew-harness" ] || printf 'opencode\n' > "$fm/config/crew-harness" # Crew dispatch profile - source of truth in dotfiles (reproducible across # machines). Symlinked into firstmate config so a rebuild restores routing. # Crew harness and model routing are task-specific in crew-dispatch.json. ln -sfn "${dotfiles}/home/.config/firstmate/crew-dispatch.json" "$fm/config/crew-dispatch.json" # Gitea PR helper for local-only mode: after the first mate (opencode) # reviews a crewmate branch, this pushes it + opens a Gitea PR via tea. ln -sfn "${dotfiles}/home/bin/fm-gitea-pr.sh" "$HOME/.local/bin/fm-gitea-pr.sh" ''; # Firstmate companion CLIs (*-axi). None is a Homebrew or Nix formula, so # install them through Homebrew's npm. tasks-axi is version-gated by firstmate # (>= 0.2.6 is required before a spawn/teardown automatic backlog transition # will run), so fill a missing or older copy; rebuild.sh moves it on to the # latest release. The rest install when absent on a fresh machine. home.activation.axiTools = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail # Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node` # shebang and the installed shims would fail. Prepend only - replacing PATH # breaks the rest of the HM activation (nix-env, gettext). export PATH="/opt/homebrew/bin:$PATH" npm=/opt/homebrew/bin/npm if [ ! -x "$npm" ]; then echo "axiTools: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2 exit 1 fi # tasks-axi: install the firstmate floor only when the copy is missing or # older. A newer copy is left alone so rebuild.sh's latest-release update # survives the next switch. want_tasks_axi="0.2.6" have_tasks_axi="$(tasks-axi --version 2>/dev/null | head -1 | tr -d '[:space:]' || true)" if [ -z "$have_tasks_axi" ] \ || [ "$(printf '%s\n%s\n' "$want_tasks_axi" "$have_tasks_axi" | sort -V | head -1)" != "$want_tasks_axi" ]; then "$npm" install -g "tasks-axi@$want_tasks_axi" fi # Companion CLIs without a firstmate-enforced version floor: install once. for tool in quota-axi gh-axi lavish-axi chrome-devtools-axi; do [ -x "/opt/homebrew/bin/$tool" ] || "$npm" install -g "$tool" done ''; # Authorize the SSH key so the phone can log in through the ngrok tunnel. # (home-manager 26.05 removed programs.ssh.authorizedKeys; manage the file # here so ~/.ssh is 0700 and authorized_keys is 0600. Public key is not a secret.) home.activation.authorizeSSHKey = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail mkdir -p "$HOME/.ssh" chmod 700 "$HOME/.ssh" printf '%s\n' "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGCZEGVYMDztSryFwoZ6cfpBH3ksP3h0yxZSanlcbrZ0 unraid-omada" > "$HOME/.ssh/authorized_keys" chmod 600 "$HOME/.ssh/authorized_keys" ''; # Wire the sync-music script into ~/.local/bin without touching anything else # that lives there (node, python3.11, hermes, etc.). Source of truth is the # dotfiles repo so a rebuild restores it if it ever disappears. home.activation.syncMusic = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail ln -sfn "${dotfiles}/home/bin/sync-music" "$HOME/.local/bin/sync-music" ''; # Codex (desktop app + CLI) -> OpenCode Go. The ChatGPT app owns and rewrites # ~/.codex/config.toml, so it must not be a symlink into the repo. Merge the # repo fragment into the live file on every activation instead; the app's own # sections survive. See home/bin/codex-opencode-go-sync. home.activation.codexOpenCodeGo = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail mkdir -p "$HOME/.codex" ${pkgs.python3.withPackages (ps: [ ps.tomlkit ])}/bin/python3 \ "${dotfiles}/home/bin/codex-opencode-go-sync" \ "${dotfiles}/home/.codex/config.toml" \ "$HOME/.codex/config.toml" ''; # OpenCode is the stable Homebrew `opencode` formula, linked in # configuration.nix; home/bin/oc2 runs its keg binary with an isolated config. # Nothing to install here. # backpass (kunchenguid/backpass) - gradient descent for agent memory: reads # the transcript stores of the harnesses this config already declares # (claude/codex/pi/opencode/grok), proposes evidence-backed edits to AGENTS.md # and skills, gated by `backpass apply`. Every model call goes through `acpx` # to a harness you already authenticated, so acpx is a hard runtime dep and # must be on PATH. Homebrew node v26 satisfies backpass (>= 22.5) and acpx # (>= 22.13). Neither is a Homebrew formula: install via Homebrew's npm, # never Nix's npm (EACCES on the store). Both track the registry's latest on # every rebuild: for each package the installed version is compared with the # published one, and an install runs only when they differ, so a current copy # is left alone and a stale one converges. The switch therefore always brings # both packages to the latest published version, whether or not a process of # that package is running: a running process keeps the code it already loaded # and picks the new version up at its next start, so the switch prints that as # a notice and still installs. The registry lookup and the install are optional # steps - a failure there warns and the switch continues. home.activation.backpass = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail # Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node` # shebang fails with "env: node: No such file or directory". Prepend only - # replacing PATH breaks the rest of the HM activation (nix-env, gettext). export PATH="/opt/homebrew/bin:$PATH" npm=/opt/homebrew/bin/npm if [ ! -x "$npm" ]; then echo "backpass: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2 exit 1 fi # Converge one npm global to the registry's latest. $1 is the package name, # $2 is the pgrep pattern matching that package's command line as launched # from the global bin, used only to explain that a live process keeps its # loaded code. Every optional failure returns 0, so `set -e` never aborts the # switch and later blocks still run. converge_npm_global() { pkg="$1" live="$2" # Installed version from npm's own global record; empty means absent. The # `|| true` keeps `set -e` quiet when npm exits non-zero over extraneous # packages. installed="$("$npm" ls -g --depth=0 2>/dev/null | sed -n "s/.*[[:space:]]$pkg@\([^[:space:]]*\).*/\1/p" | head -n 1 || true)" # Registry lookup is optional: an offline or timed-out lookup warns and # keeps the installed copy. latest="$("$npm" view "$pkg" version --fetch-timeout=15000 --fetch-retries=1 2>/dev/null | tr -d "[:space:]" || true)" if [ -z "$latest" ]; then echo "$pkg: cannot read the latest version from the npm registry (offline?) - keeping the installed copy, rebuild continues" >&2 return 0 fi if [ "$installed" = "$latest" ]; then echo "$pkg: already at $latest" else current="$installed" [ -n "$current" ] || current=none echo "$pkg: updating $current -> $latest" # Install failure is optional too: warn and keep the old copy. if "$npm" install -g "$pkg@$latest"; then echo "$pkg: installed $latest" else echo "$pkg: install of $latest failed - keeping the installed copy, rebuild continues" >&2 return 0 fi fi if pgrep -f "$live" >/dev/null 2>&1; then echo "$pkg: a running process keeps the code it already loaded - $latest takes effect at its next start" >&2 fi } converge_npm_global backpass "/opt/homebrew/bin/backpass" converge_npm_global acpx "/opt/homebrew/bin/acpx" ''; # kunchenguid/no-mistakes gate (git push no-mistakes) - declarative install + daemon + global config # Uses Pi for pipeline steps (the opencode-go subscription), by the captain's # decision: Pi is a neutralization-capable gate agent, which opencode is not, so # it is required to run the gate in firstmate's own checkout. Binary lives in # ~/.no-mistakes/bin # with symlink ~/.local/bin/no-mistakes (installer default). Do NOT npm install -g no-mistakes # - that npm name is jonathanong's static-analysis tool (shadowing bug fixed 2026-09-21). home.activation.noMistakes = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail bin="$HOME/.no-mistakes/bin/no-mistakes" link="$HOME/.local/bin/no-mistakes" # Install/refresh via upstream installer if missing or not kunchenguid build if [ ! -x "$bin" ] || ! "$bin" --version 2>/dev/null | grep -q "kunchenguid\|v1\."; then if [ -x "$bin" ]; then echo "no-mistakes: replacing unexpected binary at $bin" >&2 fi curl -fsSL https://raw.githubusercontent.com/kunchenguid/no-mistakes/main/docs/install.sh | sh fi # Ensure global config uses Pi (idempotent - only writes if missing or still `agent: auto`) cfg="$HOME/.no-mistakes/config.yaml" if [ -f "$cfg" ] && grep -qE '^[[:space:]]*agent:[[:space:]]*auto[[:space:]]*$' "$cfg"; then tmp="$(mktemp)" sed 's|^[[:space:]]*agent:[[:space:]]*auto[[:space:]]*$|# Managed by dotfiles/home.nix home.activation.noMistakes\nagent: [pi]|' "$cfg" > "$tmp" && mv "$tmp" "$cfg" fi if [ ! -f "$cfg" ]; then mkdir -p "$(dirname "$cfg")" printf 'agent: [pi]\n' > "$cfg" fi # Ensure the captain's model split (idempotent and additive, so hand edits survive). # Implementer, pipeline default, and pipeline fixer run deepseek-v4.1-flash; # the review role runs glm-5.3-flash, so review never uses the implementing model. if ! grep -qE '^[[:space:]]*agent_config:' "$cfg"; then printf 'agent_config:\n pi:\n model: opencode-go/deepseek-v4.1-flash\n' >> "$cfg" fi if ! grep -qE '^[[:space:]]*review_agents:' "$cfg"; then printf 'review_agents:\n reviewer:\n agent: pi\n model: opencode-go/glm-5.3-flash\n' >> "$cfg" fi # Ensure daemon running (launchd on macOS) "$bin" daemon restart >/dev/null 2>&1 || "$bin" daemon start >/dev/null 2>&1 || true ''; # cloudflare/security-audit - vulnerability-hunting skill for the coding agents. # Installed by the upstream Skills CLI through Homebrew's npx, because the skill # is a multi-file bundle and an upstream refresh must stay byte-identical. # Scope: the CLI's "universal" target is ~/.agents/skills, which Codex, Pi, and # OpenCode read as a user-level skill directory; Claude Code reads # ~/.claude/skills, so the CLI also links the skill there. Grok Build is out of # scope for this install: its skill directory is ~/.grok/skills, and the CLI # only populates it when `grok` is named in --agent. Never target # ~/.config/opencode/skills: home-manager owns that path with force = true and # mkOutOfStoreSymlink into the mutable dotfiles checkout, so a rebuild would # clobber the CLI's link and CLI writes would land in the git checkout. Skip # when installed, unlike backpass which tracks the latest release, so a # rebuild never pulls a new skill version mid-session. The skill's own README # still requires an OS-enforced sandbox before it may run target-controlled # builds, tests, browsers, or fuzzers. That sandbox is # home/bin/security-audit-sandbox; without it, those leads stay # `needs_validation`. # Install and refresh commands, plus the sandbox docs, are in readme.md. home.activation.securityAuditSkill = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail # Activation PATH lacks /opt/homebrew/bin, so npx's `#!/usr/bin/env node` # shebang fails. It also lacks /usr/bin, so the Skills CLI cannot spawn # /usr/bin/git and the clone fails with "spawn git ENOENT". Prepend both - # replacing PATH breaks the rest of the HM activation (nix-env, gettext). export PATH="/opt/homebrew/bin:/usr/bin:$PATH" npx=/opt/homebrew/bin/npx # Canonical copy plus the Claude Code link: rerun when either is missing so a # half-removed install heals, then skip while both exist. No `exit 0` here: # activation blocks are inlined into one flat script, and later blocks must # still run. if [ ! -f "$HOME/.agents/skills/security-audit/SKILL.md" ] \ || [ ! -e "$HOME/.claude/skills/security-audit" ]; then if [ ! -x "$npx" ]; then echo "securityAuditSkill: /opt/homebrew/bin/npx missing (declare node in homebrew.brews)" >&2 exit 1 fi # A rebuild must not fail when GitHub or npm is unreachable: the skill is an # enhancement, so warn and keep the rest of the switch going. if ! "$npx" --yes skills add https://github.com/cloudflare/security-audit-skill \ --skill security-audit --global \ --agent claude-code codex pi opencode --yes; then echo "securityAuditSkill: WARNING: skill install failed (network or Skills CLI unavailable); rebuild continues." >&2 echo "securityAuditSkill: rerun ./rebuild.sh or install manually with the command in readme.md." >&2 fi fi ''; # pstack skills installed from the pinned `pstackSkills` source above (folder # pstack/skills). The record of why these eleven skills exist is firstmate's # docs/adopted-skills.md. They live only in ~/.agents/skills, which is outside # git and Nix, so this block restores them on a fresh machine. # `tdd` is skipped on purpose: an existing user-level tdd skill owns that # name, so the pstack copy is never installed. # Each run replaces only the eleven target directories; every other skill, # including an existing tdd skill, stays untouched. No `exit 0` here, # because activation blocks are inlined into one flat script, so an early # exit would skip the blocks that follow. home.activation.pstackSkills = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail src="${pstackSkills}/pstack/skills" dest="$HOME/.agents/skills" if [ ! -d "$src" ]; then echo "pstackSkills: pinned source tree missing at $src" >&2 exit 1 fi mkdir -p "$dest" for name in ${lib.concatStringsSep " " pstackSkillNames}; do if [ ! -d "$src/$name" ]; then echo "pstackSkills: pinned source is missing skill $name" >&2 exit 1 fi # Remove first so a renamed source file never lingers in the old copy. rm -rf "$dest/$name" if ! cp -R "$src/$name" "$dest/$name"; then echo "pstackSkills: failed to install $name" >&2 exit 1 fi # Store files are read-only; make the installed copy writable again. chmod -R u+w "$dest/$name" done echo "pstackSkills: installed ${toString (lib.length pstackSkillNames)} pinned skills into $dest" ''; # OpenSuperWhisper - local voice-first prompting (cask in configuration.nix). # The app reads its model from its own Application Support directory, so the # 1.6 GB Whisper model is downloaded here once and kept outside the Nix store. # A failed download must not fail the switch: warn, drop the partial file, and # let the app's Settings download it later. Only a missing or unusable model # selection is seeded; every other setting belongs to the app and survives the # rebuild. Never write hasCompletedOnboarding - onboarding must still run so the # captain can grant Microphone/Accessibility (macOS TCC grants are manual by # design). A running app picks up new defaults on its next launch; do not kill # it here. home.activation.openSuperWhisper = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail supportDir="$HOME/Library/Application Support/ru.starmel.OpenSuperWhisper" modelDir="$supportDir/whisper-models" modelPath="$modelDir/ggml-large-v3-turbo.bin" modelUrl="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3-turbo.bin?download=true" modelSha="1fc70f774d38eb169993ac391eea357ef47c88757ef72ee5943879b7e8e2bc69" curl="${pkgs.curl}/bin/curl" mkdir -p "$modelDir" if [ ! -f "$modelPath" ]; then tmp="$(${pkgs.coreutils}/bin/mktemp "$modelDir/.ggml-large-v3-turbo.XXXXXX")" if "$curl" -fL --retry 3 --connect-timeout 30 -o "$tmp" "$modelUrl" \ && printf '%s %s\n' "$modelSha" "$tmp" | ${pkgs.coreutils}/bin/sha256sum -c - >/dev/null 2>&1; then mv "$tmp" "$modelPath" else echo "openSuperWhisper: WARNING: could not download or verify the Whisper model." >&2 echo "openSuperWhisper: the app still works; download \"Whisper V3 Large\" in Settings later." >&2 ${pkgs.coreutils}/bin/rm -f "$tmp" fi fi defaults=/usr/bin/defaults selectedModel="$("$defaults" read ru.starmel.OpenSuperWhisper selectedWhisperModelPath 2>/dev/null || true)" if [ -f "$modelPath" ] && { [ -z "$selectedModel" ] || [ ! -f "$selectedModel" ]; }; then "$defaults" write ru.starmel.OpenSuperWhisper selectedWhisperModelPath -string "$modelPath" fi ''; }