From c186c77fd270182583aac5bbf9589c0bd5073055 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 3 Jan 2026 12:02:43 -0800 Subject: [PATCH] refactor(deploy): dedupe injection calls in deploy-skill.sh (skills-dnm) --- bin/deploy-skill.sh | 64 +++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/bin/deploy-skill.sh b/bin/deploy-skill.sh index 27f70cf..1901994 100755 --- a/bin/deploy-skill.sh +++ b/bin/deploy-skill.sh @@ -136,52 +136,60 @@ inject_nix_config() { fi } +# Helper to inject a home.file entry into a Nix config +# Usage: inject_home_file +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."