diff options
| author | zzbaron <[email protected]> | 2026-01-04 19:05:54 -0500 |
|---|---|---|
| committer | zzbaron <[email protected]> | 2026-01-04 19:05:54 -0500 |
| commit | 39a23c1aaa484683e87f13c81c1dd410bc6a0b68 (patch) | |
| tree | 78484b597d4e533fd4ac5c80d648c6c69b51c9e3 | |
| parent | ee19fb3a6327c2289f4cdf8fc68595ab52ba4e22 (diff) | |
nix: fixed semver logic
| -rw-r--r-- | xmake/modules/package/manager/nix/find_package.lua | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/xmake/modules/package/manager/nix/find_package.lua b/xmake/modules/package/manager/nix/find_package.lua index 9e8b72ee4..505ac1923 100644 --- a/xmake/modules/package/manager/nix/find_package.lua +++ b/xmake/modules/package/manager/nix/find_package.lua @@ -343,9 +343,6 @@ local function follow_propagated_inputs(store_paths, opt) if cached_props then prop_paths = cached_props - if opt and (opt.verbose or option.get("verbose")) then - print("Nix: Using cached propagated inputs for: " .. store_path) - end else -- Read from filesystem prop_paths = {} @@ -1016,16 +1013,15 @@ local function select_best_version(packages, package_name, require_version, opt) if not require_version or require_version == "latest" then satisfies = true else - -- Use xmake's semver to check constraint satisfaction - local ok, result = pcall(function() - return semver.satisfies(pkg_version, require_version) - end) - if ok then - satisfies = result - else - -- If semver parsing fails, try exact match - satisfies = (pkg_version == require_version) - end + satisfies = try { + function() + return semver.satisfies(pkg_version, require_version) + end, + catch = function() + -- If semver parsing fails, try exact match + return (pkg_version == require_version) + end + } end if satisfies then @@ -1111,11 +1107,16 @@ function main(name, opt) local pkgconfig_result = find_with_pkgconfig(name, store_paths, opt) if pkgconfig_result then if require_version and pkgconfig_result.version then - local ok, satisfies = pcall(function() + local satisfies = try { + function() return semver.satisfies(pkgconfig_result.version, require_version) - end) + end, + catch = function() + return false + end + } - if ok and satisfies then + if satisfies then if opt and (opt.verbose or option.get("verbose")) then print("Nix: Found package via pkg-config: " .. name .. " " .. pkgconfig_result.version) end |
