mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 07:04:47 +00:00
skills.sh
This commit is contained in:
parent
e8b2fcc996
commit
fee73ac6bf
2 changed files with 76 additions and 0 deletions
75
home/skills.nix
Normal file
75
home/skills.nix
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
globalSkills = [
|
||||
{
|
||||
name = "rams";
|
||||
source = "https://github.com/brianlovin/claude-config";
|
||||
}
|
||||
{
|
||||
name = "agent-browser";
|
||||
source = "https://github.com/vercel-labs/agent-browser";
|
||||
}
|
||||
{
|
||||
name = "find-skills";
|
||||
source = "https://github.com/vercel-labs/skills";
|
||||
}
|
||||
{
|
||||
name = "frontend-design";
|
||||
source = "https://github.com/anthropics/skills";
|
||||
}
|
||||
{
|
||||
name = "next-best-practices";
|
||||
source = "https://github.com/vercel-labs/next-skills";
|
||||
}
|
||||
{
|
||||
name = "turborepo";
|
||||
source = "https://github.com/vercel/turborepo";
|
||||
}
|
||||
];
|
||||
|
||||
manifestHash = builtins.hashString "sha256" (builtins.toJSON globalSkills);
|
||||
|
||||
installCommands = lib.concatMapStringsSep "\n" (skill: ''
|
||||
"${pkgs.nodejs_22}/bin/npx" skills add ${lib.escapeShellArg skill.source} --skill ${lib.escapeShellArg skill.name} -g -y
|
||||
'') globalSkills;
|
||||
|
||||
missingChecks = lib.concatMapStringsSep "\n" (skill: ''
|
||||
if [ ! -e "$HOME/.agents/skills/${skill.name}" ]; then
|
||||
needs_sync=1
|
||||
fi
|
||||
'') globalSkills;
|
||||
in {
|
||||
home.activation.ensureGlobalSkills = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||
state_dir="${config.xdg.stateHome}/skills"
|
||||
stamp_file="$state_dir/global-skills-manifest.sha256"
|
||||
desired_hash=${lib.escapeShellArg manifestHash}
|
||||
needs_sync=0
|
||||
|
||||
mkdir -p "$state_dir" "$HOME/.agents/skills"
|
||||
|
||||
if [ ! -f "$stamp_file" ] || [ "$(cat "$stamp_file")" != "$desired_hash" ]; then
|
||||
needs_sync=1
|
||||
fi
|
||||
|
||||
${missingChecks}
|
||||
|
||||
if [ "$needs_sync" -eq 1 ]; then
|
||||
export PATH="${lib.makeBinPath [
|
||||
pkgs.nodejs_22
|
||||
pkgs.git
|
||||
pkgs.coreutils
|
||||
pkgs.findutils
|
||||
pkgs.gnugrep
|
||||
pkgs.gnused
|
||||
]}:$PATH"
|
||||
|
||||
${installCommands}
|
||||
|
||||
printf '%s\n' "$desired_hash" > "$stamp_file"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue