AgentSkillsCN

Understanding Workstation Config

本技能详细介绍了工作站单体仓库的结构,阐述了NixOS与home-manager的组织方式,以及如何浏览配置。在入职培训或尝试理解开发机配置时使用。

SKILL.md
--- frontmatter
name: Understanding Workstation Config
description: This skill explains the workstation monorepo structure, how NixOS and home-manager are organized, and how to navigate the configuration. Use this when onboarding or trying to understand how the devbox is configured.

Understanding Workstation Config

This repo manages a NixOS devbox with standalone home-manager.

Repository Structure

code
workstation/
├── flake.nix                 # Single flake: system + home-manager
├── flake.lock                # Pinned nixpkgs version
│
├── hosts/                    # NixOS system configurations
│   └── devbox/
│       ├── configuration.nix # System packages, SSH, firewall, users
│       ├── hardware.nix      # Hetzner ARM-specific (boot, kernel)
│       └── disko.nix         # Disk partitioning
│
├── users/                    # Home-manager configurations
│   └── dev/
│       └── home.nix          # User env: git, tmux, nvim, bash
│
├── assets/                   # Content deployed by home-manager
│   ├── claude/               # Claude skills and commands
│   └── nvim/                 # Neovim Lua config (lua/user/)
│
├── secrets/                  # sops-nix encrypted secrets (skeleton)
│
├── scripts/                  # Helper scripts
│   └── update-ssh-config.sh
│
└── .claude/                  # THIS REPO's Claude documentation
    ├── skills/               # How to understand/modify this config
    └── commands/             # Quick actions for this repo

Key Concepts

Standalone Home-Manager

Home-manager is NOT a NixOS module here. This means:

  • sudo nixos-rebuild switch only applies system changes
  • home-manager switch applies user changes (faster, no sudo)
  • They share the same nixpkgs pin via pkgsFor pattern

assets/ vs .claude/

  • assets/claude/ — Skills deployed TO the devbox user (~/.claude/skills)
  • .claude/ — Skills for working WITH this repo (not deployed)

pkgsFor Pattern

The flake defines pkgsFor once to prevent drift:

nix
pkgsFor = system: import nixpkgs {
  inherit system;
  config.allowUnfree = true;
};

Both NixOS and home-manager use this, ensuring consistent packages.

External Flake Inputs

LLM tools come from numtide/llm-agents.nix, passed to home-manager via extraSpecialArgs:

PackageSourceNotes
claude-codellm-agents.nixDaily updates, binary cache at cache.numtide.com
ccusagellm-agents.nixUsage analytics, statusline for Claude Code
beadsllm-agents.nixDistributed issue tracker for AI workflows
devenvnixpkgsDevelopment environments

Important: We do NOT use inputs.nixpkgs.follows for llm-agents. This preserves binary cache hits from Numtide's cache.

Claude Code Settings

The ~/.claude/settings.json uses a "managed fragment + merge" pattern because Claude Code writes runtime state to this file:

  • ~/.claude/settings.managed.json — Nix-managed config (read-only symlink)
  • ~/.claude/settings.json — Mutable file Claude Code can write to
  • On home-manager switch, managed keys are merged into settings.json
  • Claude Code's runtime state (feedbackSurveyState, enabledPlugins, etc.) is preserved
  • Our managed keys (like statusLine) win on conflict

Common Tasks

TaskCommand
Apply system changessudo nixos-rebuild switch --flake .#devbox
Apply user changeshome-manager switch --flake .#dev
Update nixpkgsnix flake update
Check flakenix flake check

Files to Edit

Want to change...Edit this file
System packageshosts/devbox/configuration.nix
User packagesusers/dev/home.nix
Bash aliasesusers/dev/home.nix (programs.bash)
Git configusers/dev/home.nix (programs.git)
Claude skills (deployed)assets/claude/skills/
Neovim configassets/nvim/lua/user/
SSH server settingshosts/devbox/configuration.nix
Flake inputsflake.nix
Claude Code statuslineusers/dev/home.nix (managedSettings)