Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nodejs modules from github #860

Closed
dacevedo12 opened this issue Jun 22, 2022 · 7 comments
Closed

Support nodejs modules from github #860

dacevedo12 opened this issue Jun 22, 2022 · 7 comments
Labels
difficulty::medium help wanted Will be solved only if someone contributes it

Comments

@dacevedo12
Copy link
Collaborator

dacevedo12 commented Jun 22, 2022

npm supports installing directly from github repos, which comes in handy as sometimes, maintainers take a long time to publish new versions to npm

https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies
https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls

perhaps the structure in the package-lock changes a bit, causing makes to fail when installing the deps

image

error: attribute 'integrity' missing

       at /nix/store/hawaw7ivjjrq228iak21lvcjq7nxpax2-source/src/args/make-node-js-modules/default.nix:77:34:

           76|               value = {
           77|                 dist.integrity = versionAttrs.integrity;
             |                                  ^
           78|                 dist.tarball = versionAttrs.resolvedName;

       … while evaluating anonymous lambda

       at /nix/store/hawaw7ivjjrq228iak21lvcjq7nxpax2-source/src/args/make-derivation/default.nix:27:9:

           26|     builtins.mapAttrs
           27|     (k: v: (
             |         ^
           28|       if (hasPrefix "__" k) || (hasPrefix "env" k)

       … from call site

       … while evaluating the attribute 'envAll' of the derivation 'gatsby-source-cloudinary.json'

       at /nix/store/hawaw7ivjjrq228iak21lvcjq7nxpax2-source/src/args/make-derivation/default.nix:92:7:

           91|       builder = "${__nixpkgs__.bash}/bin/bash";
           92|       name = toDerivationName name;
             |       ^
           93|       outputs = ["out"];

       … while evaluating 'escapeShellArg'

Tested with npm i --save https://github.com/cloudinary-devs/gatsby-source-cloudinary#19a2115fdf876c55ff74756e6dfd8d775bad636c

@dacevedo12 dacevedo12 changed the title Support nodejs module from github Support nodejs modules from github Jun 22, 2022
@dacevedo12
Copy link
Collaborator Author

note: It works well using the tar.gz npm i --save https://github.com/cloudinary-devs/gatsby-source-cloudinary/archive/19a2115fdf876c55ff74756e6dfd8d775bad636c.tar.gz

npm supports both, so it would be worth documenting this behavior in case this becomes a won't fix

@kamadorueda kamadorueda added the help wanted Will be solved only if someone contributes it label Sep 24, 2022
@dsalaza4
Copy link
Contributor

@dacevedo12 As we recently migrated to node2nix, it would be nice to tests if this works now.

@dacevedo12
Copy link
Collaborator Author

Seems node2nix is capable of it, but it doesn't find the git binary


error: builder for '...' failed with exit code 1;
       last 10 log lines:
       >   code: 'ENOENT',
       >   syscall: 'spawn git',
       >   path: 'git',
       >   spawnargs: [
       >     'clone',
       >     'ssh://[email protected]/cloudinary-devs/gatsby-source-cloudinary.git'
       >   ]
       > }
       >
       > Node.js v20.10.0

@dsalaza4
Copy link
Contributor

@dacevedo12

Maybe by adding buildInputs via packageOverrides as shown here

@dacevedo12
Copy link
Collaborator Author

dacevedo12 commented Jan 30, 2024

It only worked at makes level (make-node-js-modules/default.nix), by adding __nixpkgs__.git

git via ssh doesn't work but that's a limitation from node2nix svanderburg/node2nix#309

git via https works fine with the aforementioned patch

@dsalaza4
Copy link
Contributor

@dacevedo12 A PR adding git to the builtin is welcome!

dacevedo12 pushed a commit to dacevedo12/makes that referenced this issue Jan 30, 2024
- added git binary to enable node2nix to fetch deps from git repos
dacevedo12 added a commit to dacevedo12/makes that referenced this issue Jan 30, 2024
- added git binary to enable node2nix to fetch deps from git repos

Signed-off-by: David Acevedo <[email protected]>
dsalaza4 added a commit that referenced this issue Jan 30, 2024
feat(build): #860 node2nix from git repos
@dacevedo12
Copy link
Collaborator Author

Addressed in #1286

Thanks @dsalaza4 node2nix sure was an improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty::medium help wanted Will be solved only if someone contributes it
Projects
Status: Done
Development

No branches or pull requests

3 participants