Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions home-manager/services/cliproxyapi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ let
aws = "${pkgs.awscli2}/bin/aws";
sed = "${pkgs.gnused}/bin/sed";
};

# Bundle all backup scripts together
backupScripts = pkgs.runCommand "backup-scripts" { } ''
mkdir -p $out
cp ${./scripts/backup-and-recover.sh} $out/backup-and-recover.sh
cp ${./scripts/backup-auth.sh} $out/backup-auth.sh
cp ${./scripts/recover-auth.sh} $out/recover-auth.sh
chmod +x $out/*.sh
'';
in
{
# Main cliproxyapi service
Expand Down Expand Up @@ -64,7 +73,7 @@ in
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"${./scripts/backup-and-recover.sh}"
"${backupScripts}/backup-and-recover.sh"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While this correctly points the launchd service to the bundled script, it's missing the necessary PATH environment variable for the commands within the scripts to be found on macOS. The backup scripts use commands like aws, ls, and date, which are provided by pkgs.awscli2 and pkgs.coreutils. Without setting the PATH, this service is likely to fail on macOS, similar to the original problem on Linux.

To fix this, you should add an Environment attribute to the config block for this launchd agent, similar to how you've done for the systemd service. It should set a PATH that includes the binaries from awscli2 and coreutils.

];
StartInterval = 300; # Run every 5 minutes
RunAtLoad = true;
Expand Down Expand Up @@ -93,7 +102,14 @@ in
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash ${./scripts/backup-and-recover.sh}";
ExecStart = "${pkgs.bash}/bin/bash ${backupScripts}/backup-and-recover.sh";
Environment = "PATH=${
lib.makeBinPath [
pkgs.bash
pkgs.awscli2
pkgs.coreutils
Comment on lines +106 to +110

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include bash in backup service PATH

The backup service now overrides PATH to only awscli2/coreutils, but backup-and-recover.sh executes backup-auth.sh and recover-auth.sh directly, which rely on their #!/usr/bin/env bash shebangs to find bash. On NixOS (or any system without /usr/bin/bash), env won’t locate bash in this restricted PATH, so the backup cycle fails with env: bash: No such file or directory. Consider adding pkgs.bash to the PATH or invoking the helper scripts via an explicit ${pkgs.bash}/bin/bash.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot Dec 25, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The PATH environment variable is missing pkgs.bash. The helper scripts (backup-auth.sh and recover-auth.sh) use #!/usr/bin/env bash shebangs, which require bash to be in PATH. On NixOS (or any system without /usr/bin/bash), env won't be able to locate bash with this restricted PATH, causing the backup service to fail with env: bash: No such file or directory.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/cliproxyapi/default.nix, line 109:

<comment>The PATH environment variable is missing `pkgs.bash`. The helper scripts (`backup-auth.sh` and `recover-auth.sh`) use `#!/usr/bin/env bash` shebangs, which require `bash` to be in PATH. On NixOS (or any system without `/usr/bin/bash`), `env` won&#39;t be able to locate bash with this restricted PATH, causing the backup service to fail with `env: bash: No such file or directory`.</comment>

<file context>
@@ -93,7 +102,13 @@ in
+      Environment = &quot;PATH=${
+        lib.makeBinPath [
+          pkgs.awscli2
+          pkgs.coreutils
+        ]
+      }&quot;;
</file context>
Suggested change
pkgs.coreutils
pkgs.coreutils
pkgs.bash

✅ Addressed in 6c1708a

]
}";
};
};
}
Loading