Skip to content

profile: Add support for chassic type match#239

Merged
vnepogodin merged 2 commits into
masterfrom
cleanup-profiles-part3
Apr 10, 2026
Merged

profile: Add support for chassic type match#239
vnepogodin merged 2 commits into
masterfrom
cleanup-profiles-part3

Conversation

@ventureoo
Copy link
Copy Markdown
Member

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

@ventureoo ventureoo force-pushed the cleanup-profiles-part3 branch from 5f14a7c to 6143ce6 Compare April 3, 2026 20:10
@ventureoo ventureoo marked this pull request as ready for review April 3, 2026 20:10
@ventureoo ventureoo requested a review from vnepogodin April 3, 2026 20:10
@ventureoo ventureoo force-pushed the cleanup-profiles-part3 branch 2 times, most recently from 4ea9bc7 to 35a56f1 Compare April 3, 2026 20:21
@ptr1337 ptr1337 requested review from Copilot and ptr1337 April 7, 2026 13:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Profile parsing with an optional chassis_types field.
  • Filter profile-device matching by the system’s DMI chassis_type when chassis_types is set.
  • Refactor NVIDIA graphics driver profiles to introduce .prime variants gated by chassis_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.

Comment thread src/profile.rs Outdated
Comment thread src/data.rs Outdated
Comment thread src/data.rs Outdated
Comment thread src/data.rs Outdated
Comment on lines +265 to +271
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![];
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/data.rs Outdated
Comment on lines +265 to +272
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![];
}
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@ventureoo ventureoo force-pushed the cleanup-profiles-part3 branch from 35a56f1 to 7ba7f2d Compare April 8, 2026 19:43
Signed-off-by: Vasiliy Stelmachenok <ventureo@cachyos.org>
Signed-off-by: Vasiliy Stelmachenok <ventureo@cachyos.org>
@ventureoo ventureoo force-pushed the cleanup-profiles-part3 branch from 7ba7f2d to b51a8ce Compare April 8, 2026 19:46
Copy link
Copy Markdown
Member

@vnepogodin vnepogodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vnepogodin vnepogodin merged commit 48bc4e6 into master Apr 10, 2026
1 of 2 checks passed
@vnepogodin vnepogodin deleted the cleanup-profiles-part3 branch April 10, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants