69 lines
2.4 KiB
Nix
69 lines
2.4 KiB
Nix
# Places operator-selected skills into each enabled agent's global skills
|
|
# directory, one per skill, for every project.
|
|
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.agents;
|
|
claudeCode = config.programs.claude-code;
|
|
pi = config.programs.pi-coding-agent;
|
|
|
|
skillFiles = configDir:
|
|
lib.listToAttrs (
|
|
map (skill: {
|
|
name = "${configDir}/skills/${skill.skillName}";
|
|
value = {
|
|
source = skill;
|
|
recursive = true;
|
|
};
|
|
}) cfg.skills
|
|
);
|
|
in
|
|
{
|
|
options.programs.agents.skills = lib.mkOption {
|
|
type = lib.types.listOf lib.types.package;
|
|
default = [ ];
|
|
example = lib.literalExpression "[ inputs.skills.packages.\${system}.some-skill ]";
|
|
description = ''
|
|
Skills to install globally into every enabled agent harness that supports
|
|
Agent Skills.
|
|
|
|
Selection is by derivation: pass skill derivations from the skills flake's
|
|
`packages.<system>`, each of which carries its placement name as an
|
|
eval-time attribute. An empty list installs nothing.
|
|
|
|
Every skill is written as its own recursive {option}`home.file`, so this
|
|
option composes with an operator's own harness-specific skills and with
|
|
other modules placing skills under the same directory rather than claiming
|
|
the tree. Placement is gated on each harness' enable option.
|
|
'';
|
|
};
|
|
|
|
# `agents` is an umbrella namespace with no shared enable, so the skills
|
|
# feature self-gates.
|
|
# An empty list writes nothing, and files land only when a compatible harness
|
|
# is enabled.
|
|
# Reading each skill's source realises its derivation, so gating on harness
|
|
# enablement also keeps that realisation off a host that installs nothing.
|
|
config = lib.mkMerge [
|
|
(lib.mkIf claudeCode.enable {
|
|
# Each name is the derivation's eval-time `skillName`, so placement reads
|
|
# no `$out` and needs no import-from-derivation.
|
|
# `recursive = true` materialises `skills/<name>/` as a directory of
|
|
# per-file symlinks, which lets this module, the operator's own skills,
|
|
# and self-placing tool modules share one `skills/` tree.
|
|
#
|
|
# This deliberately does not feed the single-valued
|
|
# `programs.claude-code.skills`, which would collide with an operator
|
|
# already setting it.
|
|
home.file = skillFiles claudeCode.configDir;
|
|
})
|
|
|
|
(lib.mkIf pi.enable {
|
|
home.file = skillFiles pi.configDir;
|
|
})
|
|
];
|
|
}
|