Merged
Conversation
waruqi
reviewed
Sep 11, 2025
| if not opt.program then | ||
| opt.paths = opt.paths or {} | ||
| local nix_paths = { | ||
| "/nix/var/nix/profiles/default/bin", -- multi-user installation |
waruqi
reviewed
Sep 11, 2025
| "/nix/var/nix/profiles/default/bin", -- multi-user installation | ||
| "/home/" .. (os.getenv("USER") or "user") .. "/.nix-profile/bin", -- single user installation | ||
| "/run/current-system/sw/bin", -- only on nixos, maybe separate nix logic from nixos logic? | ||
| "/usr/local/bin", -- default path of nix when compiling nix from source |
Member
There was a problem hiding this comment.
you can improve linuxos.name() to check nixos.
xmake/xmake/core/base/linuxos.lua
Line 80 in e641d13
then add paths for nixos
if linuxos.name() == "nixos" then
table.insert(nix_paths, "xxx")
end
waruqi
reviewed
Sep 11, 2025
|
|
||
| -- add common nix installation paths if no specific program is given | ||
| if not opt.program then | ||
| opt.paths = opt.paths or {} |
waruqi
reviewed
Sep 11, 2025
| -- Also check for manifest (generation info) | ||
| local manifest = path.join(location, "manifest.nix") | ||
| if os.isfile(manifest) then | ||
| local manifest_content = try {function() |
waruqi
reviewed
Sep 11, 2025
| if #pcfiles > 0 then | ||
| -- Use pkg-config to get proper info | ||
| local old_path = os.getenv("PKG_CONFIG_PATH") | ||
| os.setenv("PKG_CONFIG_PATH", pcdir .. (old_path and (":" .. old_path) or "")) |
Member
There was a problem hiding this comment.
please do not set envs globals, you can pass configdirs arguments to find_package_from_pkgconfig
Member
There was a problem hiding this comment.
waruqi
reviewed
Sep 11, 2025
| if old_path then | ||
| os.setenv("PKG_CONFIG_PATH", old_path) | ||
| else | ||
| os.setenv("PKG_CONFIG_PATH", nil) |
waruqi
reviewed
Sep 11, 2025
| raise("nix not found!") | ||
| end | ||
|
|
||
| -- check architecture (nix supports cross compilation but for simplicity...) |
Member
There was a problem hiding this comment.
but you used is_cross in find_package.
waruqi
reviewed
Sep 11, 2025
| } | ||
|
|
||
| -- NixOS-specific paths | ||
| if linuxos.name() == "nixos" then |
Member
There was a problem hiding this comment.
you need to improve linuxos.name() to check nixos, it is not implemented now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces comprehensive support for the Nix package manager in XMake, enabling users to find, install, and use packages from the Nixpkgs ecosystem.
Note: This is a re-submission of #6790 with a clean commit history. The previous PR accidentally included upstream commits during sync attempts, making the git history messy. Rather than continuing to troubleshoot the rebase issues, I've created a fresh branch with only the Nix package manager implementation to make review easier.
This PR contains the same Nix integration functionality as before, with the adjustments requested during the initial review.
Core Functionality
Package Detection: Automatically detects Nix installations in common locations
Package Finding: Searches through available Nix store paths and can build packages on-demand
Package Installation: Supports both modern Nix (with flakes) and legacy nix-env workflows
Package Search: Comprehensive search functionality with JSON parsing for modern Nix
used like:
add_requires("nix::zlib.dev", {alias = "zlib"})
add_requires("nix::openssl")
add_requires("nix::boost.dev")
Key Components
find_nix.lua: Tool detection module that handles various Nix installation scenarios
nix/find_package.lua: Main package resolution logic with intelligent path scanning
nix/install_package.lua: Package installation using both modern and legacy Nix commands
nix/search_package.lua: Package search functionality with fallback support
Smart Package Resolution
Scans existing Nix store paths from environment ($PATH, $NIX_PROFILES, etc.)
Falls back to building packages on-demand if not found in available paths
Supports both modern Nix flakes (nix build nixpkgs#package) and legacy (nix-build -A package)
Integrates with pkg-config when available for better metadata extraction