summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzzbaron <[email protected]>2025-09-11 10:58:06 -0400
committerzzbaron <[email protected]>2025-09-11 10:58:06 -0400
commit3d600264dc2ffab5deffc04237dba407deff6245 (patch)
tree8477394b7a524ccbb6044dbffcdbfb618b0be5a8
parenta5223dbe4e7c2eef1592b36d9450e5044b8c17b6 (diff)
nix support: adjustments pointed out by ruki
-rw-r--r--xmake/modules/detect/tools/find_nix.lua7
-rw-r--r--xmake/modules/package/manager/nix/find_package.lua17
-rw-r--r--xmake/modules/package/manager/nix/install_package.lua7
3 files changed, 13 insertions, 18 deletions
diff --git a/xmake/modules/detect/tools/find_nix.lua b/xmake/modules/detect/tools/find_nix.lua
index 33a056320..52531e029 100644
--- a/xmake/modules/detect/tools/find_nix.lua
+++ b/xmake/modules/detect/tools/find_nix.lua
@@ -45,10 +45,15 @@ function main(opt)
local nix_paths = {
"/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
}
+
+ -- NixOS-specific paths
+ if linuxos.name() == "nixos" then
+ table.insert(nix_paths, "/run/current-system/sw/bin")
+ end
+ opt.paths = table.wrap(opt.paths)
for _, nixpath in ipairs(nix_paths) do
table.insert(opt.paths, nixpath)
end
diff --git a/xmake/modules/package/manager/nix/find_package.lua b/xmake/modules/package/manager/nix/find_package.lua
index 8c876e411..579156153 100644
--- a/xmake/modules/package/manager/nix/find_package.lua
+++ b/xmake/modules/package/manager/nix/find_package.lua
@@ -67,9 +67,7 @@ function _get_available_nix_paths()
-- Also check for manifest (generation info)
local manifest = path.join(location, "manifest.nix")
if os.isfile(manifest) then
- local manifest_content = try {function()
- return io.readfile(manifest)
- end}
+ local manifest_content = io.readfile(manifest)
if manifest_content then
-- Extract store paths from manifest
@@ -142,17 +140,8 @@ function _find_in_store_path(store_path, name)
if os.isdir(pcdir) then
local pcfiles = os.files(path.join(pcdir, name .. ".pc"))
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 ""))
-
- local pcresult = find_package_from_pkgconfig(name)
-
- if old_path then
- os.setenv("PKG_CONFIG_PATH", old_path)
- else
- os.setenv("PKG_CONFIG_PATH", nil)
- end
+ -- Use pkg-config with configdirs
+ local pcresult = find_package_from_pkgconfig(name, {configdirs = pcdir})
if pcresult then
return pcresult
diff --git a/xmake/modules/package/manager/nix/install_package.lua b/xmake/modules/package/manager/nix/install_package.lua
index 8350d3c9d..507cf6d13 100644
--- a/xmake/modules/package/manager/nix/install_package.lua
+++ b/xmake/modules/package/manager/nix/install_package.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("lib.detect.find_tool")
+import("private.core.base.is_cross")
-- install package
--
@@ -39,9 +40,9 @@ function main(name, opt)
raise("nix not found!")
end
- -- check architecture (nix supports cross compilation but for simplicity...)
- if opt.arch ~= os.arch() then
- raise("cannot install package(%s) for arch(%s)!", name, opt.arch)
+ -- check architecture
+ if is_cross(opt.plat, opt.arch) then
+ raise("cannot install package(%s) for cross compilation!", name)
end
local success = false