Skip to content

Node2nix uses nodejs.src for --nodedir when it can just use the nodejs #295

@CMCDragonkai

Description

@CMCDragonkai

I've started using node2nix with native addon projects where I'm compiling from C/C++ source in MatrixAI/TypeScript-Demo-Lib#38.

I noticed that inside node-env.nix, it's doing:

  # Extract the Node.js source code which is used to compile packages with
  # native bindings
  nodeSources = runCommand "node-sources" {} ''
    tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
    mv node-* $out
  '';

node2nix/nix/node-env.nix

Lines 204 to 209 in 68f5735

# Extract the Node.js source code which is used to compile packages with
# native bindings
nodeSources = runCommand "node-sources" {} ''
tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
mv node-* $out
'';

Which is later used in --nodedir options for npm rebuild and npm install.

I've found that just using nodejs is a better option than nodejs.src.

Firstly because you don't need to extract from any tar archive, and secondly because nodejs actually contains all the relevant configuration. Right now nodejs.src doesn't have the config.gypi file that does in fact exist in the nodejs store path.

This warning message is shown when using node-gyp against nodejs.src while the warning message doesn't show when just using nodejs store output.

gyp WARN read config.gypi ENOENT: no such file or directory, open '/nix/store/9av58jhvx76lqysgrzc0kixg9f210r2x-node-sources/include/node/config.gypi'

I think it can be entirely removed, and replaced with just --nodedir=${nodejs}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions