@kunchenguid: my new video is up! this is a popular request I received from my last video about agentic engineering workflow full wal…

X AI KOLs Timeline 新闻

摘要

A detailed walkthrough of setting up a reproducible declarative development environment for agentic engineering on macOS using Nix, Homebrew, Home Manager, WezTerm, and Starship.

my new video is up! this is a popular request I received from my last video about agentic engineering workflow full walk through that recreates my entire agentic engineering dev environment configs from scratch, and explains what everything does enjoy! https://t.co/pr4L6BKQZr
查看原文
查看缓存全文

缓存时间: 2026/07/05 20:38

my new video is up! this is a popular request I received from my last video about agentic engineering workflow

full walk through that recreates my entire agentic engineering dev environment configs from scratch, and explains what everything does

enjoy! https://t.co/pr4L6BKQZr


TL;DR

从全新 Mac 开始,通过 Nix Darwin、Home Manager、WezTerm、Starship 等工具,一步步搭建可复现、声明式的智能体工程开发环境。

为什么需要可复现的配置

当你在新机器上搭建环境,或者 AI 智能体搞崩系统后需要快速恢复时,手动重复操作既耗时又容易出错。我的解决方案是 Nix——一个声明式、可复现的配置系统,原本针对 NixOS 设计,但现在通过 Determinate Nix 安装器也能在 macOS 上完整使用。

第一步:安装 Nix

  1. 打开终端,运行 Determinate Nix 安装命令(见视频简介)。
  2. 选择 yes,等待安装完成。
  3. 运行提示中的刷新命令,使新环境生效。

第二步:创建配置仓库与 Nix Darwin

初始化仓库

mkdir files && cd files
git init
ln -s "$(pwd)" ~/files   # 固定符号链接,方便脚本引用

配置 Nix Darwin

flake.nix 样板(注意替换用户名和版本号):

{
  description = "macOS configuration";
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/23.11";  # 固定稳定版本
    nix-darwin.url = "github:LnL7/nix-darwin/23.11";
  };
  outputs = { self, nix-darwin, nixpkgs }: {
    darwinConfigurations.mac = nix-darwin.lib.darwinSystem {
      modules = [ ./configuration.nix ];
    };
  };
}

configuration.nix 基础内容:

{ config, pkgs, ... }: {
  nix.enable = false;  # 由 Determinate Nix 管理
  nixpkgs.config.allowUnfree = true;
  system.stateVersion = 6;
  networking.hostName = "mac";  # 示例
  users.users."your-username".home = "/Users/your-username";  # 替换
  # 后续系统偏好设置、Homebrew、Home Manager 等模块会添加到这里
}

应用配置

git add -A && git commit -m "initial nix-darwin config"
nix run nix-darwin -- switch --flake .

创建快速重建脚本 rebuild.sh

#!/bin/bash
nix run nix-darwin -- switch --flake .
chmod +x rebuild.sh

第三步:配置 macOS 系统偏好

configuration.nix 中添加系统设置(示例):

system.defaults = {
  NSGlobalDomain.AppleInterfaceStyle = "Dark";
  NSGlobalDomain.KeyRepeat = 2;       # 快速按键重复
  NSGlobalDomain.InitialKeyRepeat = 15; # 短延迟
  dock.autohide = true;
  dock.orientation = "bottom";
  finder.AppleShowAllExtensions = true;
  finder.FXPreferredViewStyle = "Nlsv";  # 列表视图
  desktop.ViewOptions = { ShowDesktopIcons = false; };
  trackpad.Clicking = true;  # 轻点点击
};

运行 ./rebuild.sh,配置立即生效。

第四步:用 Nix 管理 Homebrew

为保持完全可复现,通过 Nix 安装 Homebrew。在 flake.nix 中添加输入和模块:

inputs = {
  # ... 原有 ...
  nix-homebrew.url = "github:zhaofengli/nix-homebrew";
  homebrew-bundle = { url = "github:homebrew/homebrew-bundle"; flake = false; };
  homebrew-core = { url = "github:homebrew/homebrew-core"; flake = false; };
  homebrew-cask = { url = "github:homebrew/homebrew-cask"; flake = false; };
};
outputs = {
  # ... 原有 ...
  nix-homebrew.lib, homebrew-bundle, homebrew-core, homebrew-cask, ...
}: {
  darwinConfigurations.mac = nix-darwin.lib.darwinSystem {
    modules = [
      ./configuration.nix
      nix-homebrew.darwinModules.nix-homebrew
      {
        nix-homebrew = {
          enable = true;
          enableRosetta = true;  # Apple Silicon 需要
          user = "your-username";
        };
        homebrew = {
          enable = true;
          cleanup = "zap";  # 移除不在 Nix 配置中的包
          casks = [
            "wezterm"  # 我使用的终端
            # 其他 casks 可继续添加
          ];
        };
      }
    ];
  };
};

运行 ./rebuild.sh,Homebrew 和 WezTerm 会自动安装。验证:brew --version

第五步:Home Manager——管理用户目录

Home Manager 负责用户级别的配置(dotfiles、包、环境变量)。在 flake.nix 中添加:

inputs = {
  # ... 原有 ...
  home-manager.url = "github:nix-community/home-manager";
  home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
  # ... 原有 ...
  home-manager, ...
}: {
  darwinConfigurations.mac = nix-darwin.lib.darwinSystem {
    modules = [
      # ... 原有 ...
      home-manager.darwinModules.home-manager
      {
        home-manager.useGlobalPkgs = true;
        home-manager.useUserPackages = true;
        home-manager.users."your-username" = import ./home.nix;
      }
    ];
  };
};

创建 home.nix(初始内容):

{ config, pkgs, ... }: {
  home.username = "your-username";
  home.homeDirectory = "/Users/your-username";
  home.stateVersion = "23.11";

  # 创建符号链接到 dotfiles 仓库
  home.file.".config/wezterm".source = ./config/wezterm;

  # 用户级包
  home.packages = with pkgs; [
    hack-font                     # Hack Nerd Font
    # 其他用户级包
  ];

  # 环境变量
  home.sessionVariables = {
    EDITOR = "nvim";
  };
}

创建 config/wezterm 目录,稍后填充配置。

第六步:Shell 增强(Zsh + Starship)

自动建议与语法高亮

home.nix 中添加:

programs.zsh = {
  enable = true;
  enableAutosuggestions = true;
  enableSyntaxHighlighting = true;
  initExtra = ''
    # Ctrl+F 接受自动建议
    bindkey '^f' autosuggest-accept
  '';
  shellAliases = {
    ll = "ls -la";
    gs = "git status";
    ga = "git add";
    gc = "git commit";
  };
};

Starship 提示符

继续在 home.nix 中添加:

programs.starship = {
  enable = true;
  settings = {
    add_newline = false;
    # 更多自定义可参考 starship 文档
  };
};

运行 ./rebuild.sh,新终端会话自动生效。

第七步:WezTerm——终极终端

WezTerm 是 Rust 编写的高性能终端,跨平台支持 Lua 配置。创建 ~/.config/wezterm/wezterm.lua

local wezterm = require 'wezterm'
return {
  -- 配色方案
  color_scheme = "Rosé Pine Moon",
  -- 字体
  font = wezterm.font("Hack Nerd Font", { size = 15 }),
  -- 透明与模糊
  window_background_opacity = 0.85,
  macos_window_background_blur = 20,
  -- 隐藏单标签标签栏
  hide_tab_bar_if_only_one_tab = true,
  -- 无边框窗口
  window_decorations = "RESIZE",
}

保存后 WezTerm 自动热重载,效果立即可见。

第八步:Neovim——主力编辑器

创建初始配置目录与文件:

mkdir -p ~/.config/nvim
touch ~/.config/nvim/init.lua

然后可以用 Neovim 编辑 init.lua 并逐步添加插件与设置(后续配置可放在 Home Manager 中管理,使其可复现)。


Source: YouTube Video by @kunchenguid

相似文章

@yanhua1010: 目前看到关于 “Agentic Engineering Workflow”的最完整的介绍 花了一个小时完整看完了,完全可以做成一个付费教程。 内容涵盖了tmux,agent记忆,skills,语音输入,长任务执行,并行worktree管理…

X AI KOLs Timeline

推荐了一份关于“Agentic Engineering Workflow”的完整介绍,涵盖了tmux、agent记忆、技能、语音输入、长任务执行、并行worktree管理、多agent调度以及可视化HTML编辑器Lavish和代码变更校验流水线no-mistakes。

@DeRonin_: 任何使用或学习智能体系统的人都应该读一读这个。我在每个新智能体项目前执行的安装顺序:1.…

X AI KOLs Following

一条分享智能体项目结构化安装顺序的推文:使用 direnv 配合密码管理器保障凭证安全,使用 litellm 或 portkey 作为模型代理管理成本和回退,使用 uv + git 在评估通过时提交以确保可复现性,使用 mitmproxy 实现 LLM 调用的全面可观测性。重点介绍了常见故障模式和安全漏洞。