node2nix

Convert npm packages into declarative Nix expressions for reproducible builds.

21|Updated Jan 5, 2024
One-click install
npx skills add https://github.com/olafkfreund/nixos_config --skill node2nix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: node2nix
Source: https://github.com/olafkfreund/nixos_config/tree/main/.gemini/skills/node2nix
Command: npx skills add https://github.com/olafkfreund/nixos_config --skill node2nix

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Converts npm-based Node.js projects into declarative Nix expressions, enabling reproducible builds and consistent deployments.

Core Features & Use Cases

  • Generate node-packages.nix, node-env.nix, and default.nix from a Node.js project.
  • Declarative dependency management with Nix to replace ad-hoc npm installs.
  • Use Case: Ideal for CI pipelines and multi-host environments to guarantee identical environments.

Quick Start

Use the tool in a Node.js project directory to generate Nix expressions. For example: node2nix -l package-lock.json Then build with nix-build -A package or install with nix-env -f default.nix -iA package.

Frequently Asked Questions about node2nix

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert npm packages to reproducible Nix expressions?

Generate reproducible Nix expressions from npm packages by running node2nix in your Node.js project directory to produce node-packages.nix, node-env.nix, and default.nix configuration files.

What is the best way to make Node.js builds reproducible across CI pipelines?

The best way to make Node.js builds reproducible across CI pipelines is converting npm dependencies into declarative Nix expressions, guaranteeing identical environments on multi-host setups without ad-hoc npm installs.

Can I use package-lock.json to generate Nix expressions for a Node.js project?

Yes, you can use package-lock.json to generate Nix expressions by executing node2nix -l package-lock.json, which translates your locked npm dependencies into declarative Nix configuration files.

Do I need Nix and Nixpkgs installed to build Node.js projects with node2nix?

Yes, you need Nix and Nixpkgs installed to build Node.js projects, as node2nix requires them to generate the expressions and build packages using nix-build or install them with nix-env.

How does declarative Nix dependency management differ from standard npm installs?

Declarative Nix dependency management replaces ad-hoc npm installs by generating static Nix expressions, ensuring that builds are fully reproducible and environments remain consistent across different hosts and CI pipelines.