From e8fb6be9cd98a1ac9d4fa2d46fed54f9c4a50c10 Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Fri, 25 Sep 2026 08:08:05 +0200 Subject: [PATCH] feat(agents): declarative paperclip systemd user service Replaces paperclip's own 'paperclipai service install' flow (self-managed shim + cli store): ExecStart points at pkgs.llm-agents.paperclip directly, keeping the embedded PostgreSQL on the nixpkgs build. Enabled alongside babysitter in the coding agents set. --- profiles/sets/coding/agents/agents.nix | 2 + profiles/sets/coding/agents/paperclip.nix | 53 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 profiles/sets/coding/agents/paperclip.nix diff --git a/profiles/sets/coding/agents/agents.nix b/profiles/sets/coding/agents/agents.nix index e0f6dca..d12bfce 100644 --- a/profiles/sets/coding/agents/agents.nix +++ b/profiles/sets/coding/agents/agents.nix @@ -21,10 +21,12 @@ ./agents-lib.nix ./babysitter.nix ./opencode.nix + ./paperclip.nix ./pi.nix ]; coding.agents.babysitter.enable = true; + coding.agents.paperclip.enable = true; programs.mcp = { enable = true; diff --git a/profiles/sets/coding/agents/paperclip.nix b/profiles/sets/coding/agents/paperclip.nix new file mode 100644 index 0000000..9c20234 --- /dev/null +++ b/profiles/sets/coding/agents/paperclip.nix @@ -0,0 +1,53 @@ +# 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 { + 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" + ]; + WorkingDirectory = "%h"; + Restart = "always"; + RestartSec = 5; + # Graceful stop: allow active agent runs to finish. + TimeoutStopSec = 300; + }; + + wantedBy = ["default.target"]; + }; + }; +}