refactor(deploy): dedupe injection calls in deploy-skill.sh (skills-dnm)
This commit is contained in:
parent
1108dda5ef
commit
c186c77fd2
|
|
@ -136,52 +136,60 @@ inject_nix_config() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Helper to inject a home.file entry into a Nix config
|
||||
# Usage: inject_home_file <target_nix_file> <dest_path_in_home> <source_relative_to_config> <extra_props> <comment>
|
||||
inject_home_file() {
|
||||
local target_file="$1"
|
||||
local home_path="$2"
|
||||
local source_path="$3"
|
||||
local extra_props="$4"
|
||||
local comment="$5"
|
||||
|
||||
local config_block="
|
||||
# Skill: $comment
|
||||
home.file.\"$home_path\" = {
|
||||
source = $source_path;
|
||||
$extra_props
|
||||
};"
|
||||
inject_nix_config "$target_file" "$config_block" "$home_path"
|
||||
}
|
||||
|
||||
echo "Configuring system..."
|
||||
echo ""
|
||||
|
||||
# 1. Claude Code Config
|
||||
CLAUDE_CONFIG="
|
||||
# Skill: $SKILL_NAME
|
||||
home.file.\".claude/skills/$SKILL_NAME\" = {
|
||||
source = ../claude/skills/$SKILL_NAME;
|
||||
recursive = true;
|
||||
};"
|
||||
inject_nix_config "$DOTFILES_REPO/home/claude.nix" "$CLAUDE_CONFIG" ".claude/skills/$SKILL_NAME"
|
||||
inject_home_file "$DOTFILES_REPO/home/claude.nix" \
|
||||
".claude/skills/$SKILL_NAME" \
|
||||
"../claude/skills/$SKILL_NAME" \
|
||||
"recursive = true;" \
|
||||
"$SKILL_NAME"
|
||||
|
||||
# 2. OpenCode Config
|
||||
OPENCODE_CONFIG="
|
||||
# Skill: $SKILL_NAME
|
||||
home.file.\".config/opencode/skills/$SKILL_NAME\" = {
|
||||
source = ../claude/skills/$SKILL_NAME;
|
||||
recursive = true;
|
||||
};"
|
||||
inject_nix_config "$DOTFILES_REPO/home/opencode.nix" "$OPENCODE_CONFIG" ".config/opencode/skills/$SKILL_NAME"
|
||||
inject_home_file "$DOTFILES_REPO/home/opencode.nix" \
|
||||
".config/opencode/skills/$SKILL_NAME" \
|
||||
"../claude/skills/$SKILL_NAME" \
|
||||
"recursive = true;" \
|
||||
"$SKILL_NAME"
|
||||
|
||||
# 3. Antigravity / Global Config
|
||||
# Check if antigravity.nix exists, otherwise warn
|
||||
ANTIGRAVITY_NIX="$DOTFILES_REPO/home/antigravity.nix"
|
||||
if [[ -f "$ANTIGRAVITY_NIX" ]]; then
|
||||
# For global scripts, we need to find executable scripts in the skill
|
||||
SCRIPTS=$(find "$SKILL_SOURCE/scripts" -name "*.sh" -type f)
|
||||
|
||||
if [[ -n "$SCRIPTS" ]]; then
|
||||
GLOBAL_CONFIG=""
|
||||
if [[ -d "$SKILL_SOURCE/scripts" ]]; then
|
||||
SCRIPTS=$(find "$SKILL_SOURCE/scripts" -name "*.sh" -type f)
|
||||
|
||||
for script in $SCRIPTS; do
|
||||
SCRIPT_NAME=$(basename "$script")
|
||||
SCRIPT_NO_EXT="${SCRIPT_NAME%.*}"
|
||||
# If skill has only one script and it matches skill name or is 'search', use skill name
|
||||
# Otherwise use script name
|
||||
LINK_NAME="$SCRIPT_NO_EXT"
|
||||
|
||||
GLOBAL_CONFIG="$GLOBAL_CONFIG
|
||||
# Skill: $SKILL_NAME ($SCRIPT_NAME)
|
||||
home.file.\".local/bin/$LINK_NAME\" = {
|
||||
source = ../claude/skills/$SKILL_NAME/scripts/$SCRIPT_NAME;
|
||||
executable = true;
|
||||
};"
|
||||
inject_home_file "$ANTIGRAVITY_NIX" \
|
||||
".local/bin/$LINK_NAME" \
|
||||
"../claude/skills/$SKILL_NAME/scripts/$SCRIPT_NAME" \
|
||||
"executable = true;" \
|
||||
"$SKILL_NAME ($SCRIPT_NAME)"
|
||||
done
|
||||
|
||||
inject_nix_config "$ANTIGRAVITY_NIX" "$GLOBAL_CONFIG" ".local/bin/$LINK_NAME"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ $ANTIGRAVITY_NIX not found. Skipping global binary configuration."
|
||||
|
|
|
|||
Loading…
Reference in a new issue