2026-08-08 21:20:27 -04:00
|
|
|
|
{ config, pkgs, lib, ... }:
|
2026-07-18 09:21:51 -04:00
|
|
|
|
|
|
|
|
|
|
let
|
2026-08-08 21:20:27 -04:00
|
|
|
|
home = config.home.homeDirectory;
|
|
|
|
|
|
dotfiles = "${home}/.dotfiles";
|
|
|
|
|
|
firstmateHome = "${home}/Documents/firstmate";
|
2026-10-25 13:04:30 -04:00
|
|
|
|
# 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
|
|
|
|
|
|
'';
|
2026-11-07 17:42:21 -05:00
|
|
|
|
# Pinned pstack skills tree (cursor/plugins). `tdd` is deliberately absent:
|
2026-11-07 18:03:15 -05:00
|
|
|
|
# an existing user-level tdd skill owns that name. See firstmate's
|
2026-11-07 17:42:21 -05:00
|
|
|
|
# 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=";
|
|
|
|
|
|
};
|
2026-07-18 09:21:51 -04:00
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
home.username = "laptran";
|
|
|
|
|
|
home.homeDirectory = "/Users/laptran";
|
|
|
|
|
|
home.stateVersion = "24.11";
|
2026-09-18 15:14:43 -04:00
|
|
|
|
# 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;
|
2026-07-18 09:21:51 -04:00
|
|
|
|
home.packages = with pkgs; [
|
|
|
|
|
|
ripgrep
|
|
|
|
|
|
fd
|
|
|
|
|
|
fzf
|
|
|
|
|
|
jq
|
|
|
|
|
|
lazygit
|
|
|
|
|
|
neovim
|
|
|
|
|
|
nerd-fonts.hack
|
2026-08-08 21:20:27 -04:00
|
|
|
|
ngrok # reverse TCP tunnel so the phone can SSH in over cellular (unfree)
|
|
|
|
|
|
beets # music tagger / library organizer + navidrome sync plugin
|
2026-10-25 13:04:30 -04:00
|
|
|
|
] ++ [ ytTranscribe ];
|
2026-07-18 09:21:51 -04:00
|
|
|
|
fonts.fontconfig.enable = true;
|
|
|
|
|
|
home.sessionVariables.EDITOR = "nvim";
|
2026-08-08 21:20:27 -04:00
|
|
|
|
|
2026-07-18 22:54:23 -04:00
|
|
|
|
programs.zsh = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
autosuggestion.enable = true; # ghost text from history
|
|
|
|
|
|
syntaxHighlighting.enable = true; # commands turn green when valid
|
|
|
|
|
|
initContent = ''
|
|
|
|
|
|
bindkey '^f' autosuggest-accept
|
2026-11-06 21:10:54 -05:00
|
|
|
|
# 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
|
2026-07-18 22:54:23 -04:00
|
|
|
|
'';
|
|
|
|
|
|
shellAliases = {
|
|
|
|
|
|
".." = "cd ..";
|
|
|
|
|
|
ll = "ls -plart";
|
|
|
|
|
|
add = "git add .";
|
|
|
|
|
|
push = "git push";
|
|
|
|
|
|
pull = "git pull";
|
|
|
|
|
|
m = "git switch main";
|
2026-07-18 23:03:12 -04:00
|
|
|
|
# High-agency agent launchers (same idea across tools)
|
2026-07-18 22:54:23 -04:00
|
|
|
|
cc = "claude --dangerously-skip-permissions";
|
|
|
|
|
|
co = "codex --full-auto";
|
2026-07-18 23:03:12 -04:00
|
|
|
|
gb = "grok --yolo";
|
2026-11-08 10:55:37 -05:00
|
|
|
|
# firstmate primary session via Pi on the OpenCode Go subscription; crewmates = OpenCode by default
|
2026-11-06 21:21:18 -05:00
|
|
|
|
fm = "cd ${firstmateHome} && exec pi";
|
2026-09-18 13:58:49 -04:00
|
|
|
|
oc2 = "${home}/.local/bin/oc2";
|
2026-08-08 21:20:27 -04:00
|
|
|
|
# Sync ~/Music into the beets library on Unraid (requires NAS mounted).
|
|
|
|
|
|
sync-music = "~/.local/bin/sync-music";
|
2026-10-25 13:04:30 -04:00
|
|
|
|
# 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";
|
2026-08-08 21:20:27 -04:00
|
|
|
|
# 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 <TOK>`)
|
|
|
|
|
|
ngrok-tunnel = "ngrok tcp 22";
|
2026-07-18 22:54:23 -04:00
|
|
|
|
};
|
|
|
|
|
|
};
|
2026-07-18 09:21:51 -04:00
|
|
|
|
|
2026-07-18 22:54:23 -04:00
|
|
|
|
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) ";
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-08-08 21:20:27 -04:00
|
|
|
|
# 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;
|
|
|
|
|
|
};
|
2026-10-05 21:25:29 -04:00
|
|
|
|
# herdr treats ~/.config/herdr as both its config directory and its state
|
2026-10-05 23:19:25 -04:00
|
|
|
|
# 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.
|
2026-10-05 21:25:29 -04:00
|
|
|
|
home.file.".config/herdr/config.toml" = {
|
|
|
|
|
|
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/herdr/config.toml";
|
2026-08-08 21:20:27 -04:00
|
|
|
|
force = true;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-10-05 21:25:29 -04:00
|
|
|
|
# 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
|
2026-10-05 22:24:32 -04:00
|
|
|
|
# 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" ] ''
|
2026-10-05 21:25:29 -04:00
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
if [ -L "$HOME/.config/herdr" ]; then
|
2026-10-05 22:14:44 -04:00
|
|
|
|
run ${pkgs.coreutils}/bin/rm "$HOME/.config/herdr"
|
2026-10-05 21:25:29 -04:00
|
|
|
|
fi
|
2026-10-05 22:00:15 -04:00
|
|
|
|
repoHerdr="${dotfiles}/home/.config/herdr"
|
|
|
|
|
|
if [ -d "$repoHerdr" ]; then
|
2026-10-05 22:14:44 -04:00
|
|
|
|
run ${pkgs.coreutils}/bin/rm -rf \
|
|
|
|
|
|
"$repoHerdr/herdr.sock" \
|
|
|
|
|
|
"$repoHerdr/herdr-client.sock" \
|
|
|
|
|
|
"$repoHerdr/herdr.sock.agent" \
|
|
|
|
|
|
"$repoHerdr/herdr-server.log" \
|
2026-10-05 22:32:40 -04:00
|
|
|
|
"$repoHerdr/herdr-client.log" \
|
2026-10-05 22:14:44 -04:00
|
|
|
|
"$repoHerdr/.plugins.lock" \
|
|
|
|
|
|
"$repoHerdr/session.json" \
|
|
|
|
|
|
"$repoHerdr/release-notes.json" \
|
2026-10-05 22:32:40 -04:00
|
|
|
|
"$repoHerdr/session-snapshots" \
|
|
|
|
|
|
"$repoHerdr/sessions"
|
2026-10-05 22:00:15 -04:00
|
|
|
|
fi
|
2026-10-05 21:25:29 -04:00
|
|
|
|
'';
|
|
|
|
|
|
|
2026-08-08 21:20:27 -04:00
|
|
|
|
# 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;
|
|
|
|
|
|
};
|
2026-07-18 23:03:12 -04:00
|
|
|
|
|
|
|
|
|
|
# Claude Code settings (also read by Grok for permissions/compat)
|
2026-08-08 21:20:27 -04:00
|
|
|
|
home.file.".claude/settings.json" = {
|
|
|
|
|
|
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.claude/settings.json";
|
|
|
|
|
|
force = true;
|
|
|
|
|
|
};
|
2026-07-18 23:03:12 -04:00
|
|
|
|
|
|
|
|
|
|
# Shared agent policy - one file, many harnesses
|
2026-08-08 21:20:27 -04:00
|
|
|
|
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;
|
|
|
|
|
|
};
|
2026-10-04 15:05:50 -04:00
|
|
|
|
# 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;
|
|
|
|
|
|
};
|
2026-11-06 21:10:54 -05:00
|
|
|
|
# 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;
|
|
|
|
|
|
};
|
2026-10-04 15:05:50 -04:00
|
|
|
|
# Codex 0.160+ profiles live in $CODEX_HOME/<name>.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;
|
|
|
|
|
|
};
|
2026-08-08 21:20:27 -04:00
|
|
|
|
home.file.".config/opencode/AGENTS.md" = {
|
|
|
|
|
|
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
|
|
|
|
|
|
force = true;
|
|
|
|
|
|
};
|
2026-09-21 21:55:00 -04:00
|
|
|
|
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;
|
|
|
|
|
|
};
|
2026-09-18 13:58:49 -04:00
|
|
|
|
# OpenCode 2 isolated config - never share ~/.config/opencode with 1.x
|
|
|
|
|
|
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;
|
|
|
|
|
|
};
|
2026-10-25 12:22:48 -04:00
|
|
|
|
home.file.".local/bin/security-audit-sandbox" = {
|
|
|
|
|
|
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/security-audit-sandbox";
|
|
|
|
|
|
force = true;
|
|
|
|
|
|
};
|
2026-10-25 15:15:23 -04:00
|
|
|
|
# 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.
|
2026-10-25 13:04:30 -04:00
|
|
|
|
home.file.".local/bin/yt-transcribe" = {
|
|
|
|
|
|
source = "${ytTranscribe}/bin/yt-transcribe";
|
|
|
|
|
|
};
|
2026-08-08 21:20:27 -04:00
|
|
|
|
home.file.".grok/AGENTS.md" = {
|
|
|
|
|
|
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
|
|
|
|
|
|
force = true;
|
|
|
|
|
|
};
|
2026-07-18 23:03:12 -04:00
|
|
|
|
|
|
|
|
|
|
# Grok Build native config
|
2026-08-08 21:20:27 -04:00
|
|
|
|
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;
|
2026-09-27 21:30:11 -04:00
|
|
|
|
# never put it in the Nix store. Seed OpenCode+herdr defaults only when absent.
|
2026-08-08 21:20:27 -04:00
|
|
|
|
# Do NOT npm install -g here: activation PATH often resolves Nix's npm, which
|
2026-09-27 21:30:11 -04:00
|
|
|
|
# cannot write into the store (EACCES). The firstmate companion CLIs (*-axi)
|
|
|
|
|
|
# are installed by home.activation.axiTools below via Homebrew's node.
|
2026-08-08 21:20:27 -04:00
|
|
|
|
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"
|
2026-09-27 21:30:11 -04:00
|
|
|
|
[ -f "$fm/config/crew-harness" ] || printf 'opencode\n' > "$fm/config/crew-harness"
|
2026-09-18 13:58:49 -04:00
|
|
|
|
|
|
|
|
|
|
# Crew dispatch profile - source of truth in dotfiles (reproducible across
|
|
|
|
|
|
# machines). Symlinked into firstmate config so a rebuild restores routing.
|
2026-09-27 21:30:11 -04:00
|
|
|
|
# Crew harness and model routing are task-specific in crew-dispatch.json.
|
2026-09-18 13:58:49 -04:00
|
|
|
|
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"
|
2026-08-08 21:20:27 -04:00
|
|
|
|
'';
|
|
|
|
|
|
|
2026-09-27 21:30:11 -04:00
|
|
|
|
# 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 pin it and reinstall on drift; the rest install when absent.
|
|
|
|
|
|
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
|
|
|
|
|
|
# Pin tasks-axi; reinstall only when the installed version differs.
|
|
|
|
|
|
want_tasks_axi="0.2.6"
|
|
|
|
|
|
have_tasks_axi="$(tasks-axi --version 2>/dev/null | head -1 | tr -d '[:space:]')"
|
|
|
|
|
|
if [ "$have_tasks_axi" != "$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
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
2026-08-08 21:20:27 -04:00
|
|
|
|
# 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"
|
|
|
|
|
|
'';
|
2026-09-18 13:58:49 -04:00
|
|
|
|
|
2026-10-04 15:05:50 -04:00
|
|
|
|
# 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"
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
2026-11-08 12:37:34 -05:00
|
|
|
|
# OpenCode 2 is the stable Homebrew `opencode` formula, declared unlinked in
|
|
|
|
|
|
# configuration.nix; home/bin/oc2 runs its keg binary. Nothing to install here.
|
2026-09-21 17:38:35 -04:00
|
|
|
|
|
2026-09-27 21:30:11 -04:00
|
|
|
|
# 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,
|
2026-11-08 12:15:22 -05:00
|
|
|
|
# never Nix's npm (EACCES on the store). Skip-if-present so a rebuild never
|
|
|
|
|
|
# pulls a new version mid-session; refresh manually with
|
2026-09-27 21:30:11 -04:00
|
|
|
|
# /opt/homebrew/bin/npm update -g backpass acpx
|
|
|
|
|
|
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
|
|
|
|
|
|
if [ ! -x /opt/homebrew/bin/acpx ]; then
|
|
|
|
|
|
"$npm" install -g acpx@latest
|
|
|
|
|
|
fi
|
|
|
|
|
|
if [ ! -x /opt/homebrew/bin/backpass ]; then
|
|
|
|
|
|
"$npm" install -g backpass
|
|
|
|
|
|
fi
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
2026-09-21 17:38:35 -04:00
|
|
|
|
# kunchenguid/no-mistakes gate (git push no-mistakes) - declarative install + daemon + global config
|
2026-09-30 19:37:53 -04:00
|
|
|
|
# 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
|
2026-09-21 17:38:35 -04:00
|
|
|
|
# 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
|
2026-09-30 19:37:53 -04:00
|
|
|
|
# Ensure global config uses Pi (idempotent - only writes if missing or still `agent: auto`)
|
2026-09-21 17:38:35 -04:00
|
|
|
|
cfg="$HOME/.no-mistakes/config.yaml"
|
2026-09-30 20:12:45 -04:00
|
|
|
|
if [ -f "$cfg" ] && grep -qE '^[[:space:]]*agent:[[:space:]]*auto[[:space:]]*$' "$cfg"; then
|
2026-09-21 17:38:35 -04:00
|
|
|
|
tmp="$(mktemp)"
|
2026-09-30 20:12:45 -04:00
|
|
|
|
sed 's|^[[:space:]]*agent:[[:space:]]*auto[[:space:]]*$|# Managed by dotfiles/home.nix home.activation.noMistakes\nagent: [pi]|' "$cfg" > "$tmp" && mv "$tmp" "$cfg"
|
2026-09-21 17:38:35 -04:00
|
|
|
|
fi
|
|
|
|
|
|
if [ ! -f "$cfg" ]; then
|
|
|
|
|
|
mkdir -p "$(dirname "$cfg")"
|
2026-09-30 19:37:53 -04:00
|
|
|
|
printf 'agent: [pi]\n' > "$cfg"
|
2026-09-21 17:38:35 -04:00
|
|
|
|
fi
|
2026-10-08 18:25:29 -04:00
|
|
|
|
# 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
|
2026-09-21 17:38:35 -04:00
|
|
|
|
# Ensure daemon running (launchd on macOS)
|
|
|
|
|
|
"$bin" daemon restart >/dev/null 2>&1 || "$bin" daemon start >/dev/null 2>&1 || true
|
|
|
|
|
|
'';
|
2026-10-24 15:30:10 -04:00
|
|
|
|
|
2026-10-24 19:54:36 -04:00
|
|
|
|
# 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.
|
2026-10-24 20:12:10 -04:00
|
|
|
|
# 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
|
2026-11-08 12:15:22 -05:00
|
|
|
|
# when installed, like backpass, so a rebuild never pulls a new skill
|
2026-10-24 20:34:29 -04:00
|
|
|
|
# version mid-session. The skill's own README still requires an OS-enforced
|
|
|
|
|
|
# sandbox before it may run target-controlled builds, tests, browsers, or
|
2026-10-25 12:49:13 -04:00
|
|
|
|
# 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.
|
2026-10-24 19:54:36 -04:00
|
|
|
|
home.activation.securityAuditSkill = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
# Activation PATH lacks /opt/homebrew/bin, so npx's `#!/usr/bin/env node`
|
2026-10-24 20:55:01 -04:00
|
|
|
|
# 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"
|
2026-10-24 19:54:36 -04:00
|
|
|
|
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
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
2026-11-07 18:00:40 -05:00
|
|
|
|
# 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.
|
2026-11-07 18:03:15 -05:00
|
|
|
|
# `tdd` is skipped on purpose: an existing user-level tdd skill owns that
|
|
|
|
|
|
# name, so the pstack copy is never installed.
|
2026-11-07 17:42:21 -05:00
|
|
|
|
# Each run replaces only the eleven target directories; every other skill,
|
2026-11-07 18:03:15 -05:00
|
|
|
|
# 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.
|
2026-11-07 17:42:21 -05:00
|
|
|
|
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"
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
2026-10-24 15:30:10 -04:00
|
|
|
|
# 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
|
2026-10-24 15:46:06 -04:00
|
|
|
|
# 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.
|
2026-10-24 15:30:10 -04:00
|
|
|
|
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
|
2026-10-24 15:46:06 -04:00
|
|
|
|
selectedModel="$("$defaults" read ru.starmel.OpenSuperWhisper selectedWhisperModelPath 2>/dev/null || true)"
|
|
|
|
|
|
if [ -f "$modelPath" ] && { [ -z "$selectedModel" ] || [ ! -f "$selectedModel" ]; }; then
|
2026-10-24 15:30:10 -04:00
|
|
|
|
"$defaults" write ru.starmel.OpenSuperWhisper selectedWhisperModelPath -string "$modelPath"
|
|
|
|
|
|
fi
|
|
|
|
|
|
'';
|
2026-07-18 09:21:51 -04:00
|
|
|
|
}
|