profile: Add support for chassic type match#239
Conversation
5f14a7c to
6143ce6
Compare
4ea9bc7 to
35a56f1
Compare
There was a problem hiding this comment.
Pull request overview
Adds chassis-type based profile matching to reduce reliance on install-time hooks for laptop/desktop quirks, and updates NVIDIA graphics profiles to use this new matching mechanism.
Changes:
- Extend
Profileparsing with an optionalchassis_typesfield. - Filter profile-device matching by the system’s DMI
chassis_typewhenchassis_typesis set. - Refactor NVIDIA graphics driver profiles to introduce
.primevariants gated bychassis_types, removing in-script chassis detection.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/profile.rs | Adds chassis_types to the Profile model and parsing/serialization paths. |
| src/data.rs | Adds chassis type filtering to get_all_devices_of_profile. |
| profiles/pci/graphic_drivers/profiles.toml | Introduces .prime subprofiles with chassis_types and removes shell-based chassis detection logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if let Some(chassic_types) = &profile.chassis_types { | ||
| let chassic_type = fs::read_to_string("/sys/devices/virtual/dmi/id/chassis_type") | ||
| .expect("Failed to read chassic type"); | ||
| let chassic_type = chassic_type.trim(); | ||
| if !chassic_types.iter().any(|x| x == chassic_type) { | ||
| return vec![]; | ||
| } |
There was a problem hiding this comment.
This adds a new unconditional expect(...) in the profile-matching path. If /sys/devices/virtual/dmi/id/chassis_type is missing/unreadable, the process will panic instead of treating the profile as non-matching. Consider handling the I/O error (e.g., return vec![] or log and skip the filter) to keep profile matching non-fatal.
| if let Some(chassic_types) = &profile.chassis_types { | ||
| let chassic_type = fs::read_to_string("/sys/devices/virtual/dmi/id/chassis_type") | ||
| .expect("Failed to read chassic type"); | ||
| let chassic_type = chassic_type.trim(); | ||
| if !chassic_types.iter().any(|x| x == chassic_type) { | ||
| return vec![]; | ||
| } | ||
| } |
There was a problem hiding this comment.
New chassis_types matching logic is introduced here, but there are no unit tests covering match vs. non-match behavior. Adding a small test for this filter (potentially by refactoring the chassis type read into a helper that can be mocked in tests) would prevent regressions.
35a56f1 to
7ba7f2d
Compare
Signed-off-by: Vasiliy Stelmachenok <ventureo@cachyos.org>
Signed-off-by: Vasiliy Stelmachenok <ventureo@cachyos.org>
7ba7f2d to
b51a8ce
Compare
I think we're abusing hooks for adding laptop-specific quirks too much, so profiles for specific chassic type(s) look cleaner.
Based on: #238