refactor: consume agent-lib through m3ta-home

This commit is contained in:
2026-06-13 09:25:40 +02:00
parent c692ca1c63
commit 879bdb3005
6 changed files with 339 additions and 136 deletions
+9 -116
View File
@@ -18,66 +18,6 @@
vercel = [];
};
agentLibSharedSkillsDir = ".agents/skills";
agentLibHomeManagerStub = {lib, ...}: {
options.home.homeDirectory = lib.mkOption {
type = lib.types.str;
default = "/var/lib/hermes";
};
options.home.file = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule ({name, ...}: {
options = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
};
executable = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
};
force = lib.mkOption {
type = lib.types.bool;
default = false;
};
ignorelinks = lib.mkOption {
type = lib.types.bool;
default = false;
};
onChange = lib.mkOption {
type = lib.types.lines;
default = "";
};
recursive = lib.mkOption {
type = lib.types.bool;
default = false;
};
source = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
};
target = lib.mkOption {
type = lib.types.str;
default = name;
};
text = lib.mkOption {
type = lib.types.nullOr lib.types.lines;
default = null;
};
};
}));
default = {};
};
options.home.packages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
};
options.assertions = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
default = [];
};
};
agentLibSourceSelections =
lib.mapAttrs (_sourceName: exclude: {
skills = {
@@ -87,63 +27,15 @@
})
agentSkillExclusions;
# Evaluate agent-lib's Hermes target renderer with a minimal Home Manager
# surface, then expose its selected shared-skill outputs as a single Nix store
# directory for hermes-agent's native `skills.external_dirs` setting. The full
# Home Manager module is not imported into this NixOS host because Hermes runs
# as a system service user rather than a managed login user's Home Manager
# generation.
agentLibEval = lib.evalModules {
specialArgs = {inherit pkgs;};
modules = [
agentLibHomeManagerStub
inputs.agent-lib.homeManagerModules.default
{
home.homeDirectory = "/var/lib/hermes";
programs.agent-lib = {
enable = true;
lockFile = ../../../agent-sources.lock.json;
shared.skillsDir = agentLibSharedSkillsDir;
targets.hermes.enable = true;
profiles.default.sources = agentLibSourceSelections;
};
}
];
# Deterministic store renderer consumed directly by Hermes. m3ta-home
# re-exports the focused helper so nixos-config does not need a direct
# agent-lib flake input.
hermesSkills = inputs.m3ta-home.lib.mkHermesSkillsDir {
system = pkgs.stdenv.hostPlatform.system;
name = "hermes-agent-lib-skills";
lockFile = ../../../agent-sources.lock.json;
sources = agentLibSourceSelections;
};
agentLibFailedAssertions = lib.filter (assertion: !assertion.assertion) agentLibEval.config.assertions;
agentLibHomeFiles =
if agentLibFailedAssertions != []
then throw (builtins.head agentLibFailedAssertions).message
else agentLibEval.config.home.file;
hermesSkillHomeFiles =
lib.filterAttrs (
targetPath: file:
lib.hasPrefix "${agentLibSharedSkillsDir}/" targetPath
&& file ? source
&& file.source != null
)
agentLibHomeFiles;
linkHermesSkill = targetPath: file: let
skillName = lib.removePrefix "${agentLibSharedSkillsDir}/" targetPath;
in ''
ln -s ${file.source} "$out"/${lib.escapeShellArg skillName}
'';
# Deterministic store renderer consumed directly by Hermes. Each entry is a
# symlink to the immutable skill directory selected by agent-lib, so
# `$out/<skill>/SKILL.md` exists without a mutable copy service.
hermesSkills =
if hermesSkillHomeFiles == {}
then throw "agent-lib: Hermes skill selection produced no skills"
else
pkgs.runCommand "hermes-agent-lib-skills" {} ''
mkdir -p $out
${lib.concatMapAttrsStringSep "\n" linkHermesSkill hermesSkillHomeFiles}
'';
in {
virtualisation.docker.enable = true;
@@ -179,6 +71,7 @@ in {
];
extraPackages = with pkgs; [
basecamp
docker
git
curl