Repository navigation
Add sudoCopy: copy the closure as root through sudo - #414
Open
FlorianFranzen wants to merge 1 commit into
Open
FlorianFranzen wants to merge 1 commit into
FlorianFranzen wants to merge 1 commit into
Conversation
Problem: an sshUser other than root can only copy unsigned paths if the target's Nix daemon trusts it, which makes it root-equivalent. Solution: with `sudoCopy`, `nix copy` runs the target's `nix-store` through the node's sudo command, so root imports the paths.
FlorianFranzen
force-pushed
the
sudo-copy
branch
from
November 4, 2026 06:12
2e50364 to
7f97bfc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Deploying as an
sshUserother than root fails with "cannot add path ... becauseit lacks a signature by a trusted key" unless that user is in the target's
nix.settings.trusted-users(#280, #293). A trusted user can add arbitrary pathsto the store, so that workaround makes the deploy user root-equivalent through
the Nix daemon, even on hosts where root login is off and sudo is the intended
way up.
Solution
A new setting,
sudoCopy(and--sudo-copy), whereverinteractiveSudocan beset. When it is on and
sshUseris not root, the closure is copied withso
nix-store --serve --writeruns as root on the target and imports the pathsitself; the daemon's trusted users stay as they are. The prefix is the node's
sudosetting, sodoas -uand the like work too.Sudo has to succeed without a password (
NOPASSWD, or e.g. pam_rssh against aforwarded agent): the copy protocol runs over the connection's standard input.
sudoCopywithinteractiveSudois therefore an error rather than a hang.Tests
sudo-copy: apusheruser with sudo but not trusted by thedaemon. Without
sudoCopythe deploy fails on the signature check; withinteractiveSudoit is refused; withsudoCopyit succeeds, and sudo'sjournal shows
nix-store --serve --writerun as root.Related
#334 (
--remote-bin-path) also setsremote-programon the copy. The twocompose (
sudo -u root <remote-bin-path>/nix-store); whichever lands second canbuild on the other's helper, and I am happy to rebase.