Files
home-manager/tests/modules/programs/claude-code/collision-assertions.nix
jiezhuzzz cbb77679b3 claude-code: link plugins so agents and commands load
Claude Code lists a plugin's `agents/` and `commands/` entries with a
`readdir` that accepts only regular files, so symlinked directory entries
are skipped. Managed plugins were linked recursively, which materializes a
real directory holding one symlink per file, and wrapped with
`pkgs.symlinkJoin`, which mirrors directories and symlinks the leaf files.
Both layers dropped every agent and command a plugin provides.

Link each plugin as a single directory symlink, and wrap it with a
`runCommand` that links only top-level entries so component directories stay
symlinks to the original.

Also accept an attribute set for `plugins`, making the personal-plugin
directory name user-controlled and stable rather than derived from the
source's base name, which yields names such as `bxa1s0m3h4sh-source` that
change whenever the plugin is updated. The list form keeps working, with a
warning.
2026-07-27 11:11:02 -05:00

29 lines
805 B
Nix

{ config, ... }:
{
programs.claude-code = {
enable = true;
package = config.lib.test.mkStubPackage {
name = "claude-code";
version = "2.1.157";
buildScript = ''
mkdir -p $out/bin
touch $out/bin/claude
chmod 755 $out/bin/claude
'';
};
# An attribute set cannot hold duplicate names, so uniqueness can only be
# violated by colliding with the generated Home Manager plugin, which is
# present because `mcpServers` is set.
mcpServers.github = {
type = "http";
url = "https://api.githubcopilot.com/mcp/";
};
plugins.claude-code-home-manager = ./test-plugin;
};
test.asserts.assertions.expected = [
"`programs.claude-code.plugins` entries must resolve to unique personal-plugin directory names"
];
}