Support nodejs modules from github #860

Closed
opened 2022-06-22 16:29:36 +02:00 by dacevedo12 · 7 comments
dacevedo12 commented 2022-06-22 16:29:36 +02:00 (Migrated from github.com)

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

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](https://user-images.githubusercontent.com/29694570/175054281-d72bb174-a653-4e93-ae35-a088ad65e41d.png) ``` 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 commented 2022-06-22 17:03:31 +02:00 (Migrated from github.com)

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

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`
dsalaza4 commented 2024-01-19 22:55:46 +01:00 (Migrated from github.com)

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

@dacevedo12 As we recently migrated to node2nix, it would be nice to tests if this works now.
dacevedo12 commented 2024-01-30 18:22:30 +01:00 (Migrated from github.com)

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://git@github.com/cloudinary-devs/gatsby-source-cloudinary.git'
       >   ]
       > }
       >
       > Node.js v20.10.0
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://git@github.com/cloudinary-devs/gatsby-source-cloudinary.git' > ] > } > > Node.js v20.10.0 ```
dsalaza4 commented 2024-01-30 18:38:30 +01:00 (Migrated from github.com)

@dacevedo12

Maybe by adding buildInputs via packageOverrides as shown here

@dacevedo12 Maybe by adding `buildInputs` via `packageOverrides` as shown [here](https://makes.fluidattacks.com/api/extensions/node.js/?h=node2ni#__codelineno-2-17)
dacevedo12 commented 2024-01-30 19:10:17 +01:00 (Migrated from github.com)

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 https://github.com/svanderburg/node2nix/issues/309

git via https works fine with the aforementioned patch

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 https://github.com/svanderburg/node2nix/issues/309 git via https works fine with the aforementioned patch
dsalaza4 commented 2024-01-30 19:27:49 +01:00 (Migrated from github.com)

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

@dacevedo12 A PR adding git to the builtin is welcome!
dacevedo12 commented 2024-01-30 20:03:09 +01:00 (Migrated from github.com)

Addressed in https://github.com/fluidattacks/makes/pull/1286

Thanks @dsalaza4 node2nix sure was an improvement!

Addressed in https://github.com/fluidattacks/makes/pull/1286 Thanks @dsalaza4 node2nix sure was an improvement!
This discussion has been locked. Commenting is limited to contributors.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
justin/makes#860
No description provided.