refactor: replace nix crate with rustix + users#280
Merged
cjp256 merged 2 commits intoAzure:mainfrom Feb 3, 2026
Merged
Conversation
…ions Replace the nix crate dependency with rustix (for chown syscall) and users (for user lookups). Key changes: - Replace nix::unistd::chown with rustix::fs::chown - Replace nix::unistd::User::from_name with users::get_user_by_name - Introduce SshUser struct to hold user info for SSH provisioning - Update error type from nix::Error to rustix::io::Errno The SshUser struct is needed because users::User is immutable (unlike nix::unistd::User which had mutable public fields), requiring a simple wrapper for test flexibility.
Contributor
Author
|
I believe once we merge in #279 , the CI will pass for this PR. |
anhvoms
approved these changes
Feb 3, 2026
Resolved conflicts in libazureinit/Cargo.toml and libazureinit/src/provision/ssh.rs by keeping rustix and users crates instead of nix, which is the purpose of this PR.
81ac31f to
0177623
Compare
cadejacobson
approved these changes
Feb 3, 2026
Contributor
cadejacobson
left a comment
There was a problem hiding this comment.
E2E logs look good!
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.
Summary
This PR replaces the
nixcrate withrustixanduserscrates for user lookups and file ownership operations. This change improves long-term maintainability by moving to more focused, stable dependencies.Motivation
The current
nixdependency is used in a very limited way (user lookups and chown), but introduces several long‑term risks:The replacement crates offer better stability.
Changes
Code Updates
Ssh User
The
nix::unistd::Usertype exposes mutable public fields, which allowed tests to override values such as the home directory. Theusers::User typeis immutable and getter-only.To preserve testability without relying on mutable system structs, this PR introduces a small
SshUserdata holder that can be:users::Userin productionAdvantages:
Disadvantages: