feat(system): add NixOS support and nix package manager integration#975
feat(system): add NixOS support and nix package manager integration#975decode2 wants to merge 3 commits into
Conversation
Adds detection for NixOS via /etc/os-release (ID=nixos) and support for the nix package manager across Linux distros, resolving issue Gentleman-Programming#110. Key changes: - Added LinuxDistroNixOS constant and nix package manager resolution - Added nix binary detection in system tools scan - Added nix-env installation hints and commands for git, curl, node, and go - Added full unit test coverage for NixOS detection and dependency installation matrix Closes Gentleman-Programming#110
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds NixOS support to Linux detection and dependency installation. It recognizes NixOS from ChangesNixOS Platform Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/system/detect.go (1)
135-147: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPrefer
nixbeforebrewin the Linux resolver.This branch still returns
"brew"whenever both tools are installed, so the new"nix"path and theLinuxDistroNixOSfallback never apply on those hosts.Suggested fix
- // Check if brew is available on Linux - if brew, ok := tools["brew"]; ok && brew.Installed { - profile.PackageManager = "brew" - profile.Supported = true - return profile - } - // Check if nix is available on Linux if nix, ok := tools["nix"]; ok && nix.Installed { profile.PackageManager = "nix" profile.Supported = true return profile } + + // Check if brew is available on Linux + if brew, ok := tools["brew"]; ok && brew.Installed { + profile.PackageManager = "brew" + profile.Supported = true + return profile + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/system/detect.go` around lines 135 - 147, In the Linux resolver inside the detection logic, the current tool-preference order still returns brew first, which prevents the nix path and LinuxDistroNixOS fallback from being used on hosts where both are installed. Update the checks in the Linux branch of the detection flow so nix is evaluated before brew, keeping the profile.PackageManager and profile.Supported assignment behavior the same; use the existing tools map and profile handling in the resolver to preserve the rest of the detection logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/system/detect_test.go`:
- Around line 93-108: The current NixOS test coverage only exercises the
ID=nixos case in TestDetectFromInputsMarksNixOSSupported, so the new detection
helper and precedence paths can still regress. Add tests alongside this one for
Linux inputs with ID_LIKE=nixos and for cases where nix is found on PATH, using
detectFromInputs to verify the resulting LinuxDistro, PackageManager, and
Supported values. Keep the assertions aligned with the existing detection
behavior so the new Nix path logic is covered without relying on line-specific
checks.
---
Outside diff comments:
In `@internal/system/detect.go`:
- Around line 135-147: In the Linux resolver inside the detection logic, the
current tool-preference order still returns brew first, which prevents the nix
path and LinuxDistroNixOS fallback from being used on hosts where both are
installed. Update the checks in the Linux branch of the detection flow so nix is
evaluated before brew, keeping the profile.PackageManager and profile.Supported
assignment behavior the same; use the existing tools map and profile handling in
the resolver to preserve the rest of the detection logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 646c5cd9-088a-4fba-894d-9c8436b7106a
📒 Files selected for processing (4)
internal/system/detect.gointernal/system/detect_test.gointernal/system/install_deps.gointernal/system/install_deps_test.go
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/system/detect_test.go`:
- Around line 123-133: The Linux detection logic in detectFromInputs still
prefers brew before the LinuxDistroNixOS fallback, which can misclassify NixOS
hosts that also have Homebrew on PATH. Update the Linux branch so the
NixOS-specific path wins before any brew-based selection, and add a regression
test alongside TestDetectFromInputsPrefersNixOverBrewOnLinux covering a NixOS +
Homebrew case with no nix tool entry to verify the package manager resolves to
NixOS rather than brew.
In `@internal/system/detect.go`:
- Around line 135-145: The Linux detection in detect.go lets the Homebrew
fast-path in the system profile logic override the NixOS case, causing NixOS to
be labeled as "brew" when Homebrew is installed. Update the branching around the
profile selection in the Linux path so LinuxDistroNixOS always wins over the
brew check, either by moving the NixOS-specific case before the brew fast-path
or by guarding the brew branch to exclude NixOS. Make sure the logic in
detectSystemProfile (and the Linux distro handling near it) preserves the
contract that NixOS always maps to "nix".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8aa61234-e9d2-46bd-a544-3fc56f34c173
📒 Files selected for processing (2)
internal/system/detect.gointernal/system/detect_test.go
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/system/detect_test.go`:
- Around line 123-133: The Linux detection logic in detectFromInputs still
prefers brew before the LinuxDistroNixOS fallback, which can misclassify NixOS
hosts that also have Homebrew on PATH. Update the Linux branch so the
NixOS-specific path wins before any brew-based selection, and add a regression
test alongside TestDetectFromInputsPrefersNixOverBrewOnLinux covering a NixOS +
Homebrew case with no nix tool entry to verify the package manager resolves to
NixOS rather than brew.
In `@internal/system/detect.go`:
- Around line 135-145: The Linux detection in detect.go lets the Homebrew
fast-path in the system profile logic override the NixOS case, causing NixOS to
be labeled as "brew" when Homebrew is installed. Update the branching around the
profile selection in the Linux path so LinuxDistroNixOS always wins over the
brew check, either by moving the NixOS-specific case before the brew fast-path
or by guarding the brew branch to exclude NixOS. Make sure the logic in
detectSystemProfile (and the Linux distro handling near it) preserves the
contract that NixOS always maps to "nix".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8aa61234-e9d2-46bd-a544-3fc56f34c173
📒 Files selected for processing (2)
internal/system/detect.gointernal/system/detect_test.go
🛑 Comments failed to post (2)
internal/system/detect_test.go (1)
123-133: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash fd detect_test.go . -x sed -n '1,220p' {} fd detect.go . -x sed -n '118,170p' {}Repository: Gentleman-Programming/gentle-ai
Length of output: 9980
Add a NixOS + Homebrew regression case. The Linux branch still falls through to
brewbefore theLinuxDistroNixOSfallback, so a NixOS host with Homebrew on PATH and nonixentry would resolve to the wrong package manager.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/system/detect_test.go` around lines 123 - 133, The Linux detection logic in detectFromInputs still prefers brew before the LinuxDistroNixOS fallback, which can misclassify NixOS hosts that also have Homebrew on PATH. Update the Linux branch so the NixOS-specific path wins before any brew-based selection, and add a regression test alongside TestDetectFromInputsPrefersNixOverBrewOnLinux covering a NixOS + Homebrew case with no nix tool entry to verify the package manager resolves to NixOS rather than brew.internal/system/detect.go (1)
135-145: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Don't let the Homebrew fast-path override NixOS.
On NixOS, this returns
"brew"whenever Homebrew is installed buttools["nix"]is missing/false, because the earlybrewbranch runs before theLinuxDistroNixOScase at Line 159. That breaks the PR contract (NixOS => "nix") and downstreaminstall_depswill emit Homebrew commands instead ofnix-envcommands.Proposed fix
- // Check if brew is available on Linux - if brew, ok := tools["brew"]; ok && brew.Installed { + // NixOS should always resolve to nix, even if Homebrew is also installed. + if distro == LinuxDistroNixOS { + profile.PackageManager = "nix" + profile.Supported = true + return profile + } + + // Check if brew is available on Linux + if brew, ok := tools["brew"]; ok && brew.Installed { profile.PackageManager = "brew" profile.Supported = true return profile }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.// Check if nix is available on Linux if nix, ok := tools["nix"]; ok && nix.Installed { profile.PackageManager = "nix" profile.Supported = true return profile } // NixOS should always resolve to nix, even if Homebrew is also installed. if distro == LinuxDistroNixOS { profile.PackageManager = "nix" profile.Supported = true return profile } // Check if brew is available on Linux if brew, ok := tools["brew"]; ok && brew.Installed { profile.PackageManager = "brew" profile.Supported = true🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/system/detect.go` around lines 135 - 145, The Linux detection in detect.go lets the Homebrew fast-path in the system profile logic override the NixOS case, causing NixOS to be labeled as "brew" when Homebrew is installed. Update the branching around the profile selection in the Linux path so LinuxDistroNixOS always wins over the brew check, either by moving the NixOS-specific case before the brew fast-path or by guarding the brew branch to exclude NixOS. Make sure the logic in detectSystemProfile (and the Linux distro handling near it) preserves the contract that NixOS always maps to "nix".
Summary
Closes #110
Adds native support for NixOS Linux distribution and the
nixpackage manager across Linux environments.Problem
Gentle AI installer currently did not detect NixOS systems or recognize
nixas a package manager, preventing users on NixOS or usingnixon Linux from installing prerequisites smoothly.Solution
/etc/os-release(ID=nixosorID_LIKE=nixos). AddedLinuxDistroNixOS = "nixos"constant.nixas the platform package manager when running on NixOS or whennixtool is detected on Linux.nix-env -iA nixpkgs.<package>hints and execution commands for prerequisites (git,curl,node,go).nix.Test Plan
go test ./internal/system/...— all tests pass including full package manager matrix.go build ./...— builds cleanly across workspace.Summary by CodeRabbit