Repository navigation
fix: run paperclip from cloned repo via pnpm dev:once #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||||||||||||
| let | ||||||||||||||||||
| inherit (inputs) host; | ||||||||||||||||||
| homeDir = config.home.homeDirectory; | ||||||||||||||||||
| repoDir = "${homeDir}/ghq/github.com/paperclipai/paperclip"; | ||||||||||||||||||
| in | ||||||||||||||||||
| # Only enable on kyber (server host) | ||||||||||||||||||
| lib.mkIf host.isKyber { | ||||||||||||||||||
|
|
@@ -18,7 +19,9 @@ lib.mkIf host.isKyber { | |||||||||||||||||
| ''; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Systemd service for Paperclip | ||||||||||||||||||
| # Uses bun runtime instead of node to avoid pino-http crash (logger[stringifySym] is not a function) | ||||||||||||||||||
| # Runs from cloned repo via pnpm dev:once — the global bun install has a | ||||||||||||||||||
| # pino-http/pino version mismatch that crashes node after the first request. | ||||||||||||||||||
| # The repo's lockfile resolves deps correctly. | ||||||||||||||||||
| systemd.user.services.paperclip = { | ||||||||||||||||||
| Unit = { | ||||||||||||||||||
| Description = "Paperclip AI agent orchestration platform"; | ||||||||||||||||||
|
|
@@ -27,14 +30,21 @@ lib.mkIf host.isKyber { | |||||||||||||||||
| }; | ||||||||||||||||||
| Service = { | ||||||||||||||||||
| Type = "simple"; | ||||||||||||||||||
| ExecStart = "${homeDir}/.nix-profile/bin/bun run ${homeDir}/.bun/install/global/node_modules/paperclipai/dist/index.js run --no-repair"; | ||||||||||||||||||
| ExecStart = "${homeDir}/.bun/bin/pnpm dev:once"; | ||||||||||||||||||
| Restart = "always"; | ||||||||||||||||||
| RestartSec = "5s"; | ||||||||||||||||||
| Environment = [ | ||||||||||||||||||
| "HOME=${homeDir}" | ||||||||||||||||||
| "HOST=0.0.0.0" | ||||||||||||||||||
| "PAPERCLIP_DEPLOYMENT_MODE=authenticated" | ||||||||||||||||||
| "PAPERCLIP_ALLOWED_HOSTNAMES=paperclip.shunkakinoki.com,172.17.0.1" | ||||||||||||||||||
| "PATH=${homeDir}/.local/bin:${homeDir}/.bun/bin:${homeDir}/.nix-profile/bin:${homeDir}/.local/share/pnpm:${homeDir}/.local/share/fnm/current/bin:${homeDir}/.npm-global/bin:/usr/local/bin:/usr/bin:/bin" | ||||||||||||||||||
| ]; | ||||||||||||||||||
| WorkingDirectory = "${homeDir}/.paperclip"; | ||||||||||||||||||
| EnvironmentFile = [ | ||||||||||||||||||
| "${homeDir}/dotfiles/.env" | ||||||||||||||||||
| "${homeDir}/.paperclip/instances/default/.env" | ||||||||||||||||||
|
Comment on lines
+40
to
+41
|
||||||||||||||||||
| "${homeDir}/dotfiles/.env" | |
| "${homeDir}/.paperclip/instances/default/.env" | |
| "-${homeDir}/dotfiles/.env" | |
| "-${homeDir}/.paperclip/instances/default/.env" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Systemd's EnvironmentFile directive treats unprefixed paths as required — the service will refuse to start if either file is missing (e.g. fresh machine, before manual setup). Prefix with - to make them optional:
EnvironmentFile = [
"-${homeDir}/dotfiles/.env"
"-${homeDir}/.paperclip/instances/default/.env"
];Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/modules/paperclip/default.nix, line 44:
<comment>Systemd's `EnvironmentFile` directive treats unprefixed paths as required — the service will refuse to start if either file is missing (e.g. fresh machine, before manual setup). Prefix with `-` to make them optional:
```nix
EnvironmentFile = [
"-${homeDir}/dotfiles/.env"
"-${homeDir}/.paperclip/instances/default/.env"
];
```</comment>
<file context>
@@ -27,14 +30,21 @@ lib.mkIf host.isKyber {
];
- WorkingDirectory = "${homeDir}/.paperclip";
+ EnvironmentFile = [
+ "${homeDir}/dotfiles/.env"
+ "${homeDir}/.paperclip/instances/default/.env"
+ ];
</file context>
| "${homeDir}/dotfiles/.env" | |
| "${homeDir}/.paperclip/instances/default/.env" | |
| "-${homeDir}/dotfiles/.env" | |
| "-${homeDir}/.paperclip/instances/default/.env" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The EnvironmentFile directive in systemd will cause the service to fail to start if any of the specified files do not exist. Since these files (such as ~/dotfiles/.env or the instance-specific .env) might be missing on a fresh installation or before manual configuration, it is more robust to prefix the paths with -. This tells systemd to ignore the file if it is missing, allowing the service to attempt to start and let the application handle missing environment variables (consistent with the logic in hydrate.sh).
EnvironmentFile = [
"-${homeDir}/dotfiles/.env"
"-${homeDir}/.paperclip/instances/default/.env"
];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EnvironmentFile entries will cause service failure if files are missing.
Systemd's EnvironmentFile directive will fail service startup if the specified file doesn't exist. Consider prefixing with - to make them optional if that's acceptable, or ensure the files are created before service start.
EnvironmentFile = [
- "${homeDir}/dotfiles/.env"
- "${homeDir}/.paperclip/instances/default/.env"
+ "-${homeDir}/dotfiles/.env"
+ "-${homeDir}/.paperclip/instances/default/.env"
];Alternatively, if these files are strictly required, add assertions or activation scripts to validate their existence.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| EnvironmentFile = [ | |
| "${homeDir}/dotfiles/.env" | |
| "${homeDir}/.paperclip/instances/default/.env" | |
| ]; | |
| EnvironmentFile = [ | |
| "-${homeDir}/dotfiles/.env" | |
| "-${homeDir}/.paperclip/instances/default/.env" | |
| ]; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@home-manager/modules/paperclip/default.nix` around lines 43 - 46, The
EnvironmentFile entries under EnvironmentFile will cause service failure if the
files are missing; update the EnvironmentFile array to mark the entries optional
by prefixing each path with "-" (e.g. "-${homeDir}/dotfiles/.env") so systemd
won't fail when a file is absent, or alternatively add an assertion or an
activation script that creates/validates the files before the service starts;
locate the EnvironmentFile attribute in the Nix service declaration and apply
one of these fixes to ensure the service doesn't fail on missing files.
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service now WorkingDirectorys into ${repoDir}, but this module doesn't ensure the repo exists. If the directory is missing (fresh machine, different ghq root, etc.), systemd will fail with a CHDIR error and keep restarting. Consider adding a ConditionPathIsDirectory= / AssertPathIsDirectory= in the unit, or an ExecStartPre check that exits with a clear log message when the repo isn't present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 173
🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 2337
🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 37004
Add a guard for missing repo directory before service start.
The
paperclipSetupactivation script (lines 15-18) only creates directories—it does not clone the repository. If${repoDir}doesn't exist at service start,WorkingDirectory(line 47) andExecStart(line 33) will cause systemd to hard-fail the unit. AddConditionPathExiststo make the failure explicit rather than flaky.Suggested hardening
systemd.user.services.paperclip = { Unit = { Description = "Paperclip AI agent orchestration platform"; After = [ "network-online.target" ]; Wants = [ "network-online.target" ]; + ConditionPathExists = "${repoDir}/server/src/index.ts"; };🤖 Prompt for AI Agents