Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

An experiment in improving node packaging for nix. Dead simple.

Notifications You must be signed in to change notification settings

adisbladis/buildNodeModules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

buildNodeModules

The dumbest node to Nix packaging solution yet!

Status: This project has been integrated into nixpkgs as importNpmLock.

How it works

How node_modules is built

  • Map over package-lock.json packages, invoke correct fetcher

  • Update package.json & package-lock.lock to point to store paths URLs are rewritten to file:... dependencies that link to the Nix store.

  • Run npm install

How node_modules is linked

Our configure/shell hook links individual directories inside the Nix built node_modules directory. This is to work around issues like nix-community/npmlock2nix#86 and that tools like vite expects a writable node_modules.

Usage

  • default.nix
stdenv.mkDerivation {
  pname = "my-website";
  version = "0.1.0";

  src = ./.;

  nativeBuildInputs = [
    buildNodeModules.hooks.npmConfigHook
    nodejs
    nodejs.passthru.python # for node-gyp
    npmHooks.npmBuildHook
    npmHooks.npmInstallHook
  ];

  npmDeps = buildNodeModules.fetchNodeModules {
    npmRoot = ./.;
  };
}
  • shell.nix
pkgs.mkShell {
  packages = [
    buildNodeModules.hooks.linkNodeModulesHook
    nodejs
  ];

  npmDeps = buildNodeModules.buildNodeModules {
    npmRoot = ./.;
    inherit nodejs;
  };
}

About

An experiment in improving node packaging for nix. Dead simple.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published