Add the content tier: a standalone flake that auto-discovers each skill (a directory containing a SKILL.md, at any depth) and exposes it as an individually addressable derivation built by lib.mkSkill. Directories without a SKILL.md are descended through as cosmetic containers; once a SKILL.md is found, that directory's subfolders are its assets, not further skills. Skill names must be globally unique across the tree — a collision is a hard eval-time error, not a warning. A fixture-driven skill-build check under `nix flake check` exercises the recursive walk, the builder, the SKILL.md-at-$out-root contract, the eval-time name passthru, and the collision error. The repo ships no real skill content yet, so packages.<system> is empty today.
28 lines
721 B
Nix
28 lines
721 B
Nix
# Builds a skill source directory into a derivation, `SKILL.md` at the `$out` root.
|
|
{
|
|
pkgs,
|
|
src,
|
|
name ? builtins.baseNameOf (toString src),
|
|
}:
|
|
pkgs.stdenvNoCC.mkDerivation {
|
|
inherit name src;
|
|
|
|
# A skill is just files to copy, with nothing to unpack, configure, or build.
|
|
dontUnpack = true;
|
|
dontConfigure = true;
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p "$out"
|
|
cp -R "$src"/. "$out/"
|
|
test -f "$out/SKILL.md" \
|
|
|| { echo "mkSkill: skill '${name}' has no SKILL.md at its root" >&2; exit 1; }
|
|
runHook postInstall
|
|
'';
|
|
|
|
# The name as an eval-time attribute, readable without building `$out`
|
|
# (no import-from-derivation).
|
|
passthru.skillName = name;
|
|
}
|