Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions home-manager/services/brew-upgrader/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ pkgs, ... }:
{
launchd.agents.brew-upgrader = pkgs.lib.mkIf pkgs.stdenv.isDarwin {
enable = true;
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"${./upgrade.sh}"
];

Copilot AI Nov 21, 2025

Copy link

Choose a reason for hiding this comment

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

The brew command is not in the PATH. The script will fail with "brew: command not found" unless brew is already in the user's default environment. Add an Environment.PATH configuration similar to the code-syncer service to ensure brew can be found. For Homebrew on macOS, you likely need to include paths like /opt/homebrew/bin (Apple Silicon) or /usr/local/bin (Intel).

Suggested change
];
];
EnvironmentVariables = {
PATH = "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
};

Copilot uses AI. Check for mistakes.
RunAtLoad = true;

@cubic-dev-ai cubic-dev-ai Bot Nov 21, 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.

Setting RunAtLoad to true forces the upgrade script to execute immediately when the agent loads, violating the requirement that it should only run on the three-hour StartInterval.

Prompt for AI agents
Address the following comment on home-manager/services/brew-upgrader/default.nix at line 10:

<comment>Setting RunAtLoad to true forces the upgrade script to execute immediately when the agent loads, violating the requirement that it should only run on the three-hour StartInterval.</comment>

<file context>
@@ -0,0 +1,17 @@
+        &quot;${pkgs.bash}/bin/bash&quot;
+        &quot;${./upgrade.sh}&quot;
+      ];
+      RunAtLoad = true;
+      KeepAlive = true;
+      StartInterval = 10800;
</file context>
Suggested change
RunAtLoad = true;
RunAtLoad = false;
Fix with Cubic

KeepAlive = true;
Comment on lines +10 to +11

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.

critical

The launchd agent is configured with RunAtLoad = true and KeepAlive = true. This contradicts the PR description ("No RunAtLoad or KeepAlive to avoid immediate or persistent runs") and will cause incorrect behavior.

  • KeepAlive = true will cause launchd to restart the script immediately after it finishes, leading to a continuous loop of brew upgrade commands. This will consume significant system resources. For a periodic job controlled by StartInterval, KeepAlive should be false or omitted.
  • RunAtLoad = true will run the job on startup/login. The PR description implies this is not desired.

To ensure the service runs strictly every 3 hours as intended by StartInterval, these options should be removed.

Comment on lines +10 to +11

Copilot AI Nov 21, 2025

Copy link

Choose a reason for hiding this comment

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

The PR description states "No RunAtLoad or KeepAlive to avoid immediate or persistent runs", but both RunAtLoad = true and KeepAlive = true are set here. This contradicts the stated design. With KeepAlive = true, the service will restart immediately if it exits, causing brew upgrade to run continuously in a loop, which is not the intended behavior for a periodic upgrade service. Remove both lines or set them to false to match the design intent of running only every 3 hours via StartInterval.

Suggested change
RunAtLoad = true;
KeepAlive = true;

Copilot uses AI. Check for mistakes.

@cubic-dev-ai cubic-dev-ai Bot Nov 21, 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.

KeepAlive=true makes launchd restart the brew-upgrader as soon as it exits, which prevents the StartInterval from spacing runs and effectively causes a continuous loop instead of one execution every three hours.

Prompt for AI agents
Address the following comment on home-manager/services/brew-upgrader/default.nix at line 11:

<comment>KeepAlive=true makes launchd restart the brew-upgrader as soon as it exits, which prevents the StartInterval from spacing runs and effectively causes a continuous loop instead of one execution every three hours.</comment>

<file context>
@@ -0,0 +1,17 @@
+        &quot;${./upgrade.sh}&quot;
+      ];
+      RunAtLoad = true;
+      KeepAlive = true;
+      StartInterval = 10800;
+      StandardOutPath = &quot;/tmp/brew-upgrader.log&quot;;
</file context>
Suggested change
KeepAlive = true;
KeepAlive = false;
Fix with Cubic

StartInterval = 10800;
Comment on lines +10 to +12

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 KeepAlive causes nonstop brew upgrades

The launchd agent is configured with RunAtLoad = true; KeepAlive = true; StartInterval = 10800;, but launchd restarts a KeepAlive job immediately after it exits, so the three‑hour interval is effectively ignored. On macOS this agent will loop brew upgrade continuously instead of once every three hours, causing repeated upgrade attempts and log churn rather than the intended scheduled run.

Useful? React with 👍 / 👎.

StandardOutPath = "/tmp/brew-upgrader.log";
StandardErrorPath = "/tmp/brew-upgrader.error.log";
};
};
}
5 changes: 5 additions & 0 deletions home-manager/services/brew-upgrader/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

brew upgrade

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

The script calls brew directly, assuming it's in the PATH. launchd agents run with a minimal environment and a default PATH that likely does not include the location of the Homebrew executable (e.g., /opt/homebrew/bin on Apple Silicon or /usr/local/bin on Intel Macs). This can cause the script to fail.

To make the script more robust, you should prepend the common Homebrew binary directories to the PATH for the command.

Suggested change
brew upgrade
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" brew upgrade

@cubic-dev-ai cubic-dev-ai Bot Nov 21, 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.

brew upgrade is executed without ensuring the Homebrew binary is on PATH, so the launchd job will fail with brew: command not found when PATH defaults to /usr/bin:/bin:/usr/sbin:/sbin.

Prompt for AI agents
Address the following comment on home-manager/services/brew-upgrader/upgrade.sh at line 5:

<comment>`brew upgrade` is executed without ensuring the Homebrew binary is on PATH, so the launchd job will fail with `brew: command not found` when PATH defaults to /usr/bin:/bin:/usr/sbin:/sbin.</comment>

<file context>
@@ -0,0 +1,5 @@
+
+set -euo pipefail
+
+brew upgrade
</file context>
Suggested change
brew upgrade
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" brew upgrade
Fix with Cubic

2 changes: 2 additions & 0 deletions home-manager/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ let
dotfilesUpdater = import ./dotfiles-updater { inherit pkgs; };
neversslKeepalive = import ./neverssl-keepalive { inherit pkgs; };
# ollama = import ./ollama { inherit pkgs; }; # FIXME: ollama 0.12.11 has build issues with UI assets, uncomment when fixed
brewUpgrader = import ./brew-upgrader { inherit pkgs; };
in
[
brewUpgrader

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.

critical

There's a typo in the service name. The service was defined as brewUpgrader in the let block on line 7, but it's being added to the list as brewUpgrade. This will cause a Nix evaluation error: error: undefined variable 'brewUpgrade'.

  brewUpgrader

Copilot AI Nov 21, 2025

Copy link

Choose a reason for hiding this comment

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

Variable name mismatch: brewUpgrade is referenced here but the variable is declared as brewUpgrader on line 7. This will cause a runtime error when trying to evaluate this file. Change this to brewUpgrader to match the variable declaration.

Copilot uses AI. Check for mistakes.
codeSyncer
dotfilesUpdater
neversslKeepalive
Expand Down
Loading