-
Notifications
You must be signed in to change notification settings - Fork 49
nix flake + clippy fixes (and sd_try! removal) #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Pull Request Overview
This PR introduces a Nix flake development environment configuration and performs code improvements primarily focused on modernizing Rust code patterns. The changes include removing the deprecated sd_try! macro in favor of direct ffi_result calls and updating string formatting to use modern Rust syntax.
- Adds Nix flake configuration for consistent development environment setup
- Removes the deprecated
sd_try!macro and replaces all usages with explicitffi_resultfunction calls - Updates string formatting from older
format!("{}", var)syntax to modernformat!("{var}")syntax
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| flake.nix | Adds Nix flake configuration with Rust toolchain and systemd dependencies |
| .envrc | Enables direnv integration with the Nix flake |
| src/lib.rs | Removes the deprecated sd_try! macro definition |
| src/unit.rs | Updates string formatting to modern syntax |
| src/login.rs | Replaces sd_try! macro calls with ffi_result function calls |
| src/journal.rs | Updates string formatting and replaces sd_try! macro usage |
| src/id128.rs | Replaces sd_try! macro calls with ffi_result function calls |
| src/daemon.rs | Replaces sd_try! macro calls with ffi_result function calls |
| src/bus/types.rs | Removes unnecessary lifetime parameters from trait implementations |
| src/bus/mod.rs | Replaces sd_try! macro calls with ffi_result function calls |
src/id128.rs
Outdated
| pub fn from_cstr(s: &CStr) -> Result<Id128> { | ||
| let mut r = Id128::default(); | ||
| sd_try!(ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner)); | ||
| ffi_result(unsafe {ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner)})?; |
Copilot
AI
Jul 17, 2025
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.
[nitpick] Missing space after opening brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner) } for consistency with other unsafe blocks in the codebase.
| ffi_result(unsafe {ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner)})?; | |
| ffi_result(unsafe { ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner) })?; |
src/id128.rs
Outdated
| pub fn from_random() -> Result<Id128> { | ||
| let mut r = Id128::default(); | ||
| sd_try!(ffi::id128::sd_id128_randomize(&mut r.inner)); | ||
| ffi_result(unsafe { ffi::id128::sd_id128_randomize(&mut r.inner)})?; |
Copilot
AI
Jul 17, 2025
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.
[nitpick] Missing space before closing brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_randomize(&mut r.inner) } for consistency with other unsafe blocks in the codebase.
| ffi_result(unsafe { ffi::id128::sd_id128_randomize(&mut r.inner)})?; | |
| ffi_result(unsafe { ffi::id128::sd_id128_randomize(&mut r.inner) })?; |
src/id128.rs
Outdated
| pub fn from_machine() -> Result<Id128> { | ||
| let mut r = Id128::default(); | ||
| sd_try!(ffi::id128::sd_id128_get_machine(&mut r.inner)); | ||
| ffi_result(unsafe {ffi::id128::sd_id128_get_machine(&mut r.inner)})?; |
Copilot
AI
Jul 17, 2025
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.
[nitpick] Missing space after opening brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_get_machine(&mut r.inner) } for consistency with other unsafe blocks in the codebase.
| ffi_result(unsafe {ffi::id128::sd_id128_get_machine(&mut r.inner)})?; | |
| ffi_result(unsafe { ffi::id128::sd_id128_get_machine(&mut r.inner) })?; |
src/id128.rs
Outdated
| pub fn from_boot() -> Result<Id128> { | ||
| let mut r = Id128::default(); | ||
| sd_try!(ffi::id128::sd_id128_get_boot(&mut r.inner)); | ||
| ffi_result(unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner)})?; |
Copilot
AI
Jul 17, 2025
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.
[nitpick] Missing space before closing brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner) } for consistency with other unsafe blocks in the codebase.
| ffi_result(unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner)})?; | |
| ffi_result(unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner) })?; |
src/daemon.rs
Outdated
| fn new(unset_environment: bool) -> Result<Self> { | ||
| // in order to use rust's locking of the environment, do the env var unsetting ourselves | ||
| let num_fds = sd_try!(ffi::sd_listen_fds(0)); | ||
| let num_fds = ffi_result(unsafe {ffi::sd_listen_fds(0)})?; |
Copilot
AI
Jul 17, 2025
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.
[nitpick] Missing space after opening brace in unsafe block. Should be unsafe { ffi::sd_listen_fds(0) } for consistency with other unsafe blocks in the codebase.
| let num_fds = ffi_result(unsafe {ffi::sd_listen_fds(0)})?; | |
| let num_fds = ffi_result(unsafe { ffi::sd_listen_fds(0) })?; |
No description provided.