2026-09-25 08:08:05 +02:00
|
|
|
# Paperclip — control plane for managing teams of AI agents.
|
|
|
|
|
#
|
|
|
|
|
# Declarative systemd user service replacing paperclip's own
|
|
|
|
|
# `paperclipai service install` flow. That flow expects a self-managed
|
|
|
|
|
# payload (~/.local/bin/paperclipai shim + ~/.paperclip/cli store with
|
|
|
|
|
# install.json); as soon as any of those artifacts exists, `paperclipai
|
|
|
|
|
# doctor` demands the full managed install. On NixOS the binary comes from
|
|
|
|
|
# pkgs.llm-agents.paperclip instead — pointing ExecStart at it directly
|
|
|
|
|
# also keeps the embedded PostgreSQL on the nixpkgs build (the npm payload
|
|
|
|
|
# ships FHS-linked postgres binaries that do not run on NixOS).
|
|
|
|
|
#
|
|
|
|
|
# NOTE: never run `paperclipai service install` on a machine using this
|
|
|
|
|
# module — it would try to rewrite the home-manager-managed unit (fails on
|
|
|
|
|
# the read-only symlink) and re-create the shim/manifest state its doctor
|
|
|
|
|
# then demands. `paperclipai service start/stop/status/logs` keep working
|
|
|
|
|
# since they only wrap systemctl on the same unit name.
|
|
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
|
|
|
|
pkgs,
|
|
|
|
|
...
|
|
|
|
|
}: {
|
|
|
|
|
options.coding.agents.paperclip.enable = lib.mkEnableOption "the Paperclip systemd user service";
|
|
|
|
|
|
|
|
|
|
config = lib.mkIf config.coding.agents.paperclip.enable {
|
2026-10-09 03:03:07 +02:00
|
|
|
home.packages = with pkgs; [llm-agents.paperclip];
|
2026-09-25 08:08:05 +02:00
|
|
|
systemd.user.services.paperclipai = {
|
|
|
|
|
Unit = {
|
|
|
|
|
Description = "Paperclip AI (default)";
|
|
|
|
|
After = ["network.target"];
|
|
|
|
|
StartLimitIntervalSec = 60;
|
|
|
|
|
StartLimitBurst = 5;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
|
Type = "notify";
|
|
|
|
|
NotifyAccess = "all";
|
|
|
|
|
ExecStart = "${lib.getExe pkgs.llm-agents.paperclip} run --instance default";
|
|
|
|
|
Environment = [
|
|
|
|
|
"PAPERCLIP_SERVICE_MANAGED=1"
|
|
|
|
|
"PAPERCLIP_INSTANCE_ID=default"
|
|
|
|
|
"PAPERCLIP_HOME=%h/.paperclip"
|
|
|
|
|
];
|
2026-09-25 08:19:52 +02:00
|
|
|
# Optional per-user env file (e.g. ZAI_API_KEY for the GLM coding
|
|
|
|
|
# plan) — inherited by agent harnesses spawned from the service.
|
|
|
|
|
# Leading '-' keeps the unit working when the file is absent.
|
|
|
|
|
EnvironmentFile = "-%h/.config/paperclip.env";
|
2026-09-25 08:08:05 +02:00
|
|
|
WorkingDirectory = "%h";
|
|
|
|
|
Restart = "always";
|
|
|
|
|
RestartSec = 5;
|
|
|
|
|
# Graceful stop: allow active agent runs to finish.
|
|
|
|
|
TimeoutStopSec = 300;
|
|
|
|
|
};
|
|
|
|
|
|
2026-09-25 08:11:35 +02:00
|
|
|
Install.WantedBy = ["default.target"];
|
2026-09-25 08:08:05 +02:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|