feat(openclaw): add openclaw-superpowers extension

- Add openclaw-superpowers as a flake input.
- Implement superpowers option in openclaw-podman module.
- Automate skill symlinking, state directory creation, and cron registration.
- Ensure PyYAML is installed within the container via a post-startup service.
- Enable superpowers in the main configuration.
This commit is contained in:
ashisgreat22 2026-03-20 15:20:51 +01:00
parent aa670604b5
commit 562ec5526c
4 changed files with 82 additions and 0 deletions

View file

@ -12,6 +12,7 @@
config,
lib,
pkgs,
inputs,
...
}:
@ -22,6 +23,15 @@ in
options.myModules.openclaw-podman = {
enable = lib.mkEnableOption "OpenClaw AI Agent (Podman)";
superpowers = {
enable = lib.mkEnableOption "openclaw-superpowers extension";
src = lib.mkOption {
type = lib.types.path;
default = inputs.openclaw-superpowers;
description = "Path to openclaw-superpowers source";
};
};
port = lib.mkOption {
type = lib.types.port;
default = 18789;
@ -53,6 +63,8 @@ in
];
volumes = [
"/var/lib/openclaw:/home/node/.openclaw"
] ++ lib.optionals cfg.superpowers.enable [
"${cfg.superpowers.src}:/home/node/superpowers-src:ro"
];
};
@ -63,6 +75,53 @@ in
cp -f ${./openclaw-config.json} /var/lib/openclaw/openclaw.json
chown -R 1000:1000 /var/lib/openclaw
chmod -R u+rwX /var/lib/openclaw
${lib.optionalString cfg.superpowers.enable ''
# Setup openclaw-superpowers
mkdir -p /var/lib/openclaw/extensions
mkdir -p /var/lib/openclaw/skill-state
ln -sfT /home/node/superpowers-src/skills /var/lib/openclaw/extensions/superpowers
# Replicate install.sh stateful skill registration
REPO_SRC="${cfg.superpowers.src}"
for skill_file in $REPO_SRC/skills/openclaw-native/*/SKILL.md; do
[ -f "$skill_file" ] || continue
skill_name=$(basename $(dirname "$skill_file"))
# Check if stateful: true in frontmatter
if sed -n '2,/^---$/p' "$skill_file" | grep -q '^stateful: *true'; then
mkdir -p "/var/lib/openclaw/skill-state/$skill_name"
if [ ! -f "/var/lib/openclaw/skill-state/$skill_name/state.yaml" ]; then
echo "# Runtime state for $skill_name managed by openclaw-superpowers" > "/var/lib/openclaw/skill-state/$skill_name/state.yaml"
fi
fi
done
chown -R 1000:1000 /var/lib/openclaw/extensions /var/lib/openclaw/skill-state
''}
'';
# Optional: Install PyYAML inside the container on startup
# We do this as a postStart or a simple background loop if needed,
# but a better way is to ensure the image has it.
# Since we can't easily change the image here, we'll try to run a one-time pip install.
systemd.services."openclaw-superpowers-setup" = lib.mkIf cfg.superpowers.enable {
description = "One-time setup for OpenClaw superpowers (PyYAML and Cron)";
after = [ "podman-openclaw.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.podman}/bin/podman exec -u node openclaw bash -c '\
python3 -m pip install --user PyYAML && \
for skill_file in /home/node/superpowers-src/skills/openclaw-native/*/SKILL.md; do \
[ -f \"$skill_file\" ] || continue; \
skill_name=$(basename $(dirname \"$skill_file\")); \
fm_cron=$(sed -n \"2,/^---$/p\" \"$skill_file\" | grep \"^cron:\" | sed \"s/^cron: *//\" | tr -d \"'\\\"\"); \
if [ -n \"$fm_cron\" ]; then \
openclaw cron add \"$skill_name\" \"$fm_cron\" || echo \"Cron add failed for $skill_name\"; \
fi; \
done'";
RemainAfterExit = true;
};
};
};
}