Skip to content

Add Nix Package Manager Support#6790

Closed
ZZBaron wants to merge 6 commits intoxmake-io:devfrom
ZZBaron:feature/nix-support
Closed

Add Nix Package Manager Support#6790
ZZBaron wants to merge 6 commits intoxmake-io:devfrom
ZZBaron:feature/nix-support

Conversation

@ZZBaron
Copy link
Contributor

@ZZBaron ZZBaron commented Sep 10, 2025

This PR introduces comprehensive support for the Nix package manager in XMake, enabling users to find, install, and use packages from the Nixpkgs ecosystem.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, that was unintended.

-- validate that nix is working
if program then
local ok = try {function ()
return os.iorunv(program, {"--version"}, {stdout = os.nuldev()})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove it, find_program will check it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see the new commit

-- nix might be installed in different locations
if not program and not opt.program then
-- check common nix installation paths
local paths = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can pass paths to find_program

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table.insert(opt.paths, path.join(logical_drive, "iverilog", "bin"))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, thanks. is it good now?

sudo apt install -y dh-make rng-tools devscripts lintian
echo "$PPA_GPG_PRIKEY_2C0C68C9" > ppa_gpg.key
gpg --import ppa_gpg.key
scripts/makeppa plucky # 25.04
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not motify others

## Plugins

#### Generate IDE project file plugin(makefile, vs2002 - vs2026 .. )
#### Generate IDE project file plugin(makefile, vs2002 - vs2022 .. )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@waruqi
Copy link
Member

waruqi commented Sep 11, 2025

please rebase to dev , you merged some others patches.

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


please rebase to dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants