Skip to content

Nix / NixOS support #1899

Description

@fengmk2

We're packaging vp (vite-plus 0.2.1) for nixpkgs (built from source). The core CLI works well, but several features fail or degrade under Nix, especially in "pure" Nix environments (NixOS, Nix build sandboxes, containers) that don't follow the FHS (no /lib64/ld-linux-*.so, no system libs in standard paths). Filing this so the Nix story can be tracked long-term. We are not asking to fix all of this now.

Environment

  • vite-plus 0.2.1; Rust vp built from source, JS toolchain installed from npm.
  • macOS (aarch64-darwin) and Linux (x86_64 / aarch64) on a pure-Nix store.

1. Managed Node.js runtime doesn't execute on pure-Nix Linux (+ misleading success)

vp downloads a prebuilt Node.js from nodejs.org into ~/.vite-plus/js_runtime/node/<version>/bin/node. On pure-Nix Linux this generic glibc/musl binary can't run because its ELF interpreter (/lib64/ld-linux-x86-64.so.2 / ld-linux-aarch64.so.1) doesn't exist:

$ vp env use 26
Installing Node.js v26.3.1...
Using Node.js v26.3.1 (resolved from 26)      # reports success, marks 26 "current"
$ vp env exec node --version
... cannot run: Dynamic loader not found: /lib64/ld-linux-x86-64.so.2   # exit 255
  • macOS is unaffected (the downloaded macOS node runs via dyld).

  • This affects everything that provisions/uses a managed node: vp env use/install/exec/pin, and implicitly vp create, vp run, vp install, vp dev/build/test, etc.

  • Misleading UX: vp env use exits 0 and vp env ls shows the version "current" even though the runtime can't execute; the failure only surfaces later as a raw loader error. A post-install "can this runtime actually exec?" check would help.

  • Workaround that works under Nix: vp env off (system-first) makes vp use a node from PATH (e.g. the Nix-provided nodejs), which runs, but it ignores per-project version requirements:

    $ vp env off && vp env exec node --version
    v24.15.0    # uses the system/Nix node; works
    
  • Possible directions: an opt-in "use the runtime on PATH / bring-your-own-runtime" mode; or detecting a non-FHS environment and preferring a system runtime. (Nix-side mitigations like nix-ld or an FHS env exist, but a vp-native option would be cleaner.)

  • Update (nixpkgs default): the nixpkgs package now defaults to system-first (patches the default ShimMode), so vp uses the Nix-provided node out of the box. Two follow-ups this surfaces: (a) in system-first mode, vp env use <v> / vp env install <v> still report success but are no-ops (the active runtime stays the system node), so the command should signal when switching has no effect; (b) under Nix, vp env use never changes the shell's node regardless (there's no vp shim on PATH), so version management is effectively delegated to the Nix environment.

2. Managed package managers (pnpm, …)

Same download-and-run model. pnpm executes via the managed node, so it inherits the failure above on pure-Nix Linux; any natively-distributed package-manager binary would hit the FHS-loader issue directly.

3. fspy filesystem tracing (LD_PRELOAD) requires nightly Rust

fspy's preload cdylib uses the nightly-only c_variadic feature, so it can't be built with the stable rustc nixpkgs uses. We ship a stub, so fspy's filesystem tracing is non-functional in the Nix build, degrading anything that relies on it (e.g. task input/output tracking).

  • Possible direction: build the preload cdylib on stable Rust (avoid c_variadic / nightly gates), or make fspy optional with graceful degradation.

4. fspy downloads macOS helper binaries during build.rs

On macOS, fspy's build.rs downloads oils-for-unix and coreutils from GitHub releases at build time and embeds them. Hermetic/sandboxed builds (nixpkgs, and generally any offline build) can't fetch during the build, so we stub them, degrading vp's hermetic shell-task execution on macOS.

  • Possible direction: let these helpers be supplied via env/path (point at pre-fetched binaries) instead of downloading inside build.rs.

5. JS toolchain native bindings are prebuilt-only (FYI)

@voidzero-dev/vite-plus-*, @oxlint/binding-*, @oxfmt/binding-*, etc. ship only as prebuilt napi binaries. Under Nix (Linux) they require autoPatchelf to fix the interpreter/rpath; statically-linked ones are skipped. This works but is fragile and offers no source-build path. Mostly an FYI for downstream packaging.

What works vs. not under Nix (vite-plus 0.2.1, nixpkgs build)

  • Works: vp --version/--help, the Rust CLI, JS-command loading; on macOS, the full managed-runtime flow (vp env use, vp create, …).
  • Fails on pure-Nix Linux: executing any downloaded managed runtime/tool (vp env use+run, vp create, vp run, …). Workaround: vp env off.
  • Degraded in the Nix build: fspy tracing (stub) everywhere; fspy macOS shell helpers (stub) on macOS.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Priority

Low

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions