Skip to content

Commit f234a1e

Browse files
committed
Add per-skill destinations for private Claude skills
1 parent 281ed9e commit f234a1e

2 files changed

Lines changed: 70 additions & 32 deletions

File tree

configs/claude-skills/default.nix

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ config, lib, ... }:
1+
{ config, lib, pkgs, ... }:
22

33
let
44
cfg = config.programs.claude-skills;
@@ -26,21 +26,74 @@ in
2626
# Private skills via git (activation script)
2727
home.activation.syncPrivateSkills = lib.mkIf cfg.enablePrivate (
2828
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
29-
SKILLS_DIR="$HOME/.claude/skills"
30-
CACHE_DIR="$HOME/.cache/claude-private-skills"
31-
32-
if [ ! -d "$CACHE_DIR" ]; then
33-
git clone -b ${cfg.privateRepo.ref} ${cfg.privateRepo.url} "$CACHE_DIR"
34-
else
35-
git -C "$CACHE_DIR" pull --ff-only origin ${cfg.privateRepo.ref} || true
36-
fi
37-
38-
# Symlink each private skill into ~/.claude/skills/
39-
for skill in "$CACHE_DIR"/*/; do
40-
[ -d "$skill" ] || continue
41-
skill_name=$(basename "$skill")
42-
ln -sfn "$skill" "$SKILLS_DIR/$skill_name"
43-
done
29+
SKILLS_DIR="$HOME/.claude/skills"
30+
CACHE_DIR="$HOME/.cache/claude-private-skills"
31+
MANAGED_LINKS_FILE="$HOME/.cache/claude-private-skills-managed-links"
32+
JQ_BIN="${pkgs.jq}/bin/jq"
33+
34+
mkdir -p "$SKILLS_DIR"
35+
mkdir -p "$(dirname "$MANAGED_LINKS_FILE")"
36+
37+
if [ ! -d "$CACHE_DIR" ]; then
38+
git clone -b ${cfg.privateRepo.ref} ${cfg.privateRepo.url} "$CACHE_DIR"
39+
else
40+
git -C "$CACHE_DIR" pull --ff-only origin ${cfg.privateRepo.ref} || true
41+
fi
42+
43+
# Clean only links that this activation previously managed.
44+
if [ -f "$MANAGED_LINKS_FILE" ]; then
45+
while IFS= read -r old_link; do
46+
[ -L "$old_link" ] && rm -f "$old_link"
47+
done < "$MANAGED_LINKS_FILE"
48+
fi
49+
: > "$MANAGED_LINKS_FILE"
50+
51+
# Discover skills recursively. A skill is any directory containing SKILL.md.
52+
while IFS= read -r skill_md; do
53+
skill_dir="$(dirname "$skill_md")"
54+
manifest="$skill_dir/skill.json"
55+
skill_name="$(basename "$skill_dir")"
56+
57+
enabled="true"
58+
destinations="$SKILLS_DIR"
59+
60+
# Optional per-skill metadata:
61+
# {
62+
# "enabled": true,
63+
# "destinations": ["~/.claude/skills", "~/work/byoc/.claude/skills"]
64+
# }
65+
if [ -f "$manifest" ]; then
66+
enabled="$("$JQ_BIN" -r '.enabled // true' "$manifest" 2>/dev/null || echo true)"
67+
if [ "$enabled" != "true" ]; then
68+
continue
69+
fi
70+
71+
destinations="$("$JQ_BIN" -r '(.destinations // ["~/.claude/skills"])[]' "$manifest" 2>/dev/null || echo "~/.claude/skills")"
72+
fi
73+
74+
while IFS= read -r destination; do
75+
[ -n "$destination" ] || continue
76+
77+
# Expand "~" to $HOME for destination paths.
78+
case "$destination" in
79+
"~")
80+
destination="$HOME"
81+
;;
82+
"~/"*)
83+
destination="$HOME/$(printf '%s' "$destination" | sed 's#^~/##')"
84+
;;
85+
esac
86+
87+
mkdir -p "$destination"
88+
target="$destination/$skill_name"
89+
ln -sfn "$skill_dir" "$target"
90+
echo "$target" >> "$MANAGED_LINKS_FILE"
91+
done <<EOF
92+
$destinations
93+
EOF
94+
done <<EOF
95+
$(find "$CACHE_DIR" -type f -name SKILL.md)
96+
EOF
4497
''
4598
);
4699
};

configs/claude/default.nix

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let
4848
];
4949
env = {
5050
# I think this is ok to be pubic, it's local to my browser anyway
51-
PLAYWRIGHT_MCP_EXTENSION_TOKEN = "wASkRXZOFCIn7QoeT2KiO7e8hj7dEV7I-K7vfl4gLjU";
51+
PLAYWRIGHT_MCP_EXTENSION_TOKEN = "7-yFGyEzSGhYDUCvdQXnZ0fzgEr0g2HuTyMhuWKgiLI";
5252
};
5353
};
5454
bash-history = {
@@ -58,21 +58,6 @@ let
5858
"mcp"
5959
];
6060
};
61-
say = {
62-
command = "bash";
63-
args = [
64-
"-c"
65-
"GOOGLE_AI_API_KEY=$(pass show api-keys/google-gemini) MCP_TTS_SUPPRESS_SPEAKING_OUTPUT=true exec $HOME/go/bin/mcp-tts"
66-
];
67-
};
68-
zomato = {
69-
command = "npx";
70-
args = [
71-
"-y"
72-
"mcp-remote"
73-
"https://mcp-server.zomato.com/mcp"
74-
];
75-
};
7661
};
7762
};
7863
in

0 commit comments

Comments
 (0)