feature: Flake check for detSys installed nix#473
Conversation
|
For minimal changes diff, I guess we can drop the test cases that I got implemented by llm juspay/vertex in commit e6648a3 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for detecting Determinate Systems Nix installations in the flake enabled health check. It automatically considers flakes enabled for DetSys Nix installations without requiring explicit configuration.
- Modified flake enabled check to detect DetSys installations and treat them as having flakes enabled by default
- Updated NixVersion struct to include an
is_detsysfield and enhanced version parsing to detect DetSys installations - Added comprehensive tests covering both DetSys and regular Nix scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/omnix-health/src/check/flake_enabled.rs | Enhanced flake enabled check logic to handle DetSys installations and added comprehensive test coverage |
| crates/nix_rs/src/version.rs | Added is_detsys field to NixVersion struct and updated parsing logic to detect Determinate Systems installations |
| crates/nix_rs/src/version_spec.rs | Updated NixVersionSpec tests to include the new is_detsys field |
| crates/nix_rs/src/config.rs | Updated static NixVersion constant to include the new is_detsys field |
| pub patch: u32, | ||
| /// Nix installation type | ||
| pub installation_type: NixInstallationType, | ||
| } |
There was a problem hiding this comment.
What effect does this have on comparing two NixVersion with same version but different installation type?
There was a problem hiding this comment.
For example:
- NixVersion { major: 2, minor: 13, patch: 0, installation_type: Official }
- NixVersion { major: 2, minor: 13, patch: 0, installation_type: DeterminateSystems }The above two are no longer equal because their installation_type values differ.
For ordering (>, >=, <, <=):
- Rust’s derived
PartialOrdcompares fields in declaration order. - It compares
major, thenminor, thenpatch, and finallyinstallation_type. - Since
Officialis declared beforeDeterminateSystemsin the enum,Official < DeterminateSystems.
I believe this behavior is fine, which is why I haven’t implemented custom PartialOrd or Eq for NixVersion comparisons. If you think it’s necessary, I can implement them as well.
There was a problem hiding this comment.
@srid: What effect does this have [..]
...
@niksingh710 [..] The above two are no longer equal because theirinstallation_typevalues differ.
Does it not have the effect of breaking the nix_version check?
There was a problem hiding this comment.
I tested this on both a virtual device and my personal system with different versions in the yaml file, and confirmed that the nix_version check works correctly, since Rust’s PartialOrd handles it well.
There was a problem hiding this comment.
How exhaustive was your test? Can you read the code around:
omnix/crates/nix_rs/src/version_spec.rs
Line 75 in 99ddd5a
And see how the > check can fail or pass depending on the installation_type field?
The presence of installation_type seems quite problematic to me in this regard. NixVersion means just that ... nix version (conceptually, it says nothing about the provider of that installation).
There was a problem hiding this comment.
Perhaps the installer info should go in NixInfo
omnix/crates/nix_rs/src/info.rs
Lines 9 to 16 in d692e74
There was a problem hiding this comment.
Is it possible to disable flakes on DetSys installer? And if so, does the PR behave correctly?
There was a problem hiding this comment.
I did a bit of searching and will be doing a more thorough check on how to disable flakes in DetSys. So far, I haven’t seen any option in the installer to disable flakes. In the configuration, extra-experimental-features is being used to enable flakes.
However, removing flakes from there still kept flakes enabled.
does the PR behave correctly?
For now, if the installed nix is from Determinate Systems the health output is green for flakes.
There was a problem hiding this comment.
Having two similar matches in the same function here sounds like a code smell
There was a problem hiding this comment.
Why do you need all these irrelevant settings in the mock config? KISS and as small a code as possible.
|
@niksingh710 For future reference, please do not use non-standard characters in your branch name (i.e.,
EDIT: |
| let flakes_enabled = | ||
| val.contains(&"flakes".to_string()) && val.contains(&"nix-command".to_string()); | ||
| if flakes_enabled { | ||
| ( | ||
| flakes_enabled, | ||
| format!("experimental-features = {}", val.join(" ")), | ||
| CheckResult::Green, | ||
| ) | ||
| } else { | ||
| ( | ||
| flakes_enabled, | ||
| format!("experimental-features = {}", val.join(" ")), | ||
| CheckResult::Red { | ||
| msg: "Nix flakes are not enabled".into(), | ||
| suggestion: "See https://nixos.wiki/wiki/Flakes#Enable_flakes".into(), | ||
| }, | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
Too verbose for my taste. Just mock the nix.conf file itself (keep it 1 line; for experimental-features), and then parse it.
The more code you introduce, the more PITA it can be to maintain.
There was a problem hiding this comment.
Test only what matters. Why do we care about title equality here, for instance? Tests should be minimal.
| let config_json = format!( | ||
| r#"{{ | ||
| "experimental-features": {{ "value": [{}], "defaultValue": [], "description": "" }}, | ||
| "cores": {{ "value": 1, "defaultValue": 1, "description": "" }}, | ||
| "extra-platforms": {{ "value": [], "defaultValue": [], "description": "" }}, | ||
| "flake-registry": {{ "value": "", "defaultValue": "", "description": "" }}, | ||
| "max-jobs": {{ "value": 1, "defaultValue": 1, "description": "" }}, | ||
| "substituters": {{ "value": [], "defaultValue": [], "description": "" }}, | ||
| "system": {{ "value": "x86_64-linux", "defaultValue": "x86_64-linux", "description": "" }}, | ||
| "trusted-users": {{ "value": [], "defaultValue": [], "description": "" }} | ||
| }}"#, |
There was a problem hiding this comment.
Just mock the nix.conf file itself (keep it 1 line; for experimental-features), and then parse it.
nix.conf is in INI format, not JSON, as you are mocking here.
|
Closing in favour of #478 |


Resolves: #472 (based on the approach
2mentioned in #472)On MacOs virtual Machine
On Ubuntu virtual Machine (Simple Nix installation)
Commands used to test the package for backward compatibility.
cargo test --package nix_rs test_parse_nix_versioncargo test --package omnix-health flake_enabledcargo test --package nix_rs --package omnix-healthcargo build --bin om./target/debug/om health --jsonBackward Compatibility
✅ No breaking changes - all existing functionality preserved
✅ Regular Nix installations continue to work as before
✅ Adds new capability without removing existing features
Expected Behavior
experimental-featuresconfig