GeezerVison is showing github.com — feat(amd): passwordless agent-rebuild-switch from main by dezren39 · Pull Request #11959 · developing-today/code
Conversation
dezren39
commented
Nov 18, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Before: applying a merged change on the amd laptop needs ./rebuild, which runs the whole rebuild script under sudo and asks for the password, so agents can't apply merged fixes themselves.
After: sudo agent-rebuild-switch (no arguments) switches amd to the config on main with no password. Every other sudo, including ./rebuild and nixos-rebuild with any flags, still asks for the password.
How
- New
nixos/hosts/amd-agent-rebuild.nix, imported only by the amd host.
agent-rebuild-switch is a writeShellApplication store path. It takes no arguments, refuses to run unless root, takes a lock so only one rebuild runs at a time, and runs nixos-rebuild switch --refresh --accept-flake-config --flake github:developing-today/code/main#amd.
- It builds from
main on GitHub, not from ~/git/code. That checkout is writable by every agent running as user, so a passwordless switch from it would let any of them reach root. From main, only merged changes can be applied this way.
PATH is fixed to store paths (inheritPath = false), so the caller's PATH can't pick what runs as root.
- If
/home/user/auth exists (the same file lib/auth.sh uses), its first line is read as root and passed as the GitHub access token, only if it is a bare token ([A-Za-z0-9_]+), so the file can't inject other nix.conf settings.
- Start and result go to the journal under the tag
agent-rebuild-switch.
- The sudoers line it generates (checked against current nixos-unstable):
user ALL=(ALL:ALL) NOPASSWD: /nix/store/…-agent-rebuild-switch/bin/agent-rebuild-switch ""
"" means no arguments are allowed. It sorts after the %wheel line, so it wins for this one command.
Not included on purpose: the nix flake update of every input, the pkgs/* rebuilds, stopping tailscaled, and the <hostname> <generation> marker commit that ./rebuild does. Those stay with ./rebuild.
Checks
- A full
nixosConfigurations.amd eval wasn't possible from the cloud sandbox (most of the 82 GitHub inputs are out of reach there), so it still needs one real rebuild on the laptop.
- The module was evaluated standalone against current nixos-unstable: the sudoers text above is what it produces, and the wrapper builds (shellcheck passes).
- Wrapper behaviour: it exits 2 when given any argument and 1 when run as non-root.
nixfmt --check and statix check pass on the changed files.
After merge
- Run one
./rebuild on the laptop yourself (password as usual), so the rule is live.
- Desktop Commander on the laptop blocks
sudo. Remove sudo from its blocked commands if agents should be able to run sudo agent-rebuild-switch through it.
Generated by Claude Code
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by CodeRabbit
- New Features
- Added the
agent-rebuild-switch command to switch the AMD system to its configuration on main.
- The command is available to the designated account through passwordless
sudo, accepts no arguments, and prevents overlapping rebuilds.
- Rebuilds report their outcome and return the rebuild’s exit status when unsuccessful.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
chatgpt-codex-connector[bot] reacted with thumbs up emoji
Add a single sudo NOPASSWD rule on amd for the store-path wrapper
agent-rebuild-switch, which takes no arguments and runs
nixos-rebuild switch --flake github:developing-today/code/main#amd.
Nothing else becomes passwordless; ./rebuild still asks.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
coderabbitai
Bot
commented
Nov 18, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Warning
Review limit reached
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Next included review available in 48 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0e393bd8-fd4d-4753-9635-e39fbc9c5dc3
Commits
-
Reviewing files that changed from the base of the PR and between 2bc4774 and 9c33084.
Files selected for processing: 1
-
nixos/hosts/amd-agent-rebuild.nix
Walkthrough
-
The AMD host adds agent-rebuild-switch. The command restricts invocation, reads an optional token from /home/user/auth, and runs nixos-rebuild switch for the fixed AMD flake target.
Changes: AMD agent rebuild
| Layer / File(s) |
Summary |
Rebuild command and execution checks nixos/hosts/amd-agent-rebuild.nix |
Adds argument and root checks, a nonblocking lock, an open-file limit adjustment, and validation for the auth-file token. The command logs and runs the rebuild for the fixed AMD target, returning the rebuild’s exit status on failure. |
AMD host installation and sudo rule nixos/hosts/amd-agent-rebuild.nix, nixos/hosts/default.nix |
Installs the command, grants user passwordless sudo for its path with no arguments, and imports the module into the AMD host configuration. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
actor User
participant Sudo
participant RebuildCommand as agent-rebuild-switch
participant AuthFile as auth file
participant NixOSRebuild as nixos-rebuild
User->>Sudo: invoke command with no arguments
Sudo->>RebuildCommand: run command as root
RebuildCommand->>AuthFile: read first line if regular non-symlink file
RebuildCommand->>NixOSRebuild: run switch for fixed AMD flake target
NixOSRebuild-->>RebuildCommand: return exit status
RebuildCommand-->>User: report outcome and return status
Loading
Merge Risk: Critical · previous review 2bc47
-
The new passwordless sudo agent-rebuild-switch keeps the caller's working directory. A crafted symlink in that directory can make the rebuild run code the user built instead of the configuration on main. That code runs as root, which breaks the command's main-only guarantee. Changing to / before the rebuild closes this hole and should be done before merging.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title "feat(amd): passwordless agent-rebuild-switch from main" names the main change: a passwordless sudo command for the amd host that switches to the GitHub main configuration. The summary confi… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title "feat(amd): passwordless agent-rebuild-switch from main" names the main change: a passwordless sudo command for the amd host that switches to the GitHub main configuration. The summary confirms the added agent-rebuild-switch command, the sudoers rule, and the main-branch source. The title is specific and concise, and it follows a conventional commit style.
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-18T22:59:40.419641Z |
2bc4774 |
Draft marked ready |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
sudo keeps the caller's cwd, and nix resolves an installable that
contains a slash against the cwd, following symlinks into the store.
Change to / before nixos-rebuild so a caller cannot plant an entry that
replaces the flake reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|