node2nix icon indicating copy to clipboard operation
node2nix copied to clipboard

package.json in subdir

Open jacereda opened this issue 5 years ago • 4 comments

Some projects use a single repository for different modules each with its own package.json file. Could we get some way to specify something like this in the node-packages-x.json file?

{ "baz" : "https://github.com/foo/bar#1.0/baz"}

jacereda avatar Mar 23 '20 23:03 jacereda

I'm not entirely sure if I understand your use case, but I guess what you need is something that generates Nix expressions for all the sub projects in one go?

svanderburg avatar Apr 28 '20 08:04 svanderburg

Sometimes you're only interested in one of the subprojects in a repo, but I guess generating all the expressions could do the trick. The problem is I don't remember the concrete repo I was trying to package :(

jacereda avatar Apr 28 '20 14:04 jacereda

I have a project with multiple modules, one in Haskell and one in Node, both located in sub-directories in the same "monorepository".

Being unable to specify a sub-directory in nixpkgs/pkgs/development/node-packages/node-packages-x.json is problematic in this case for packaging the Node part of the project.

For now I'm just downloading the package.json and package-lock.json files in a separate generate.sh script (see https://github.com/NixOS/nixpkgs/pull/86599/files#r418976982).

pacien avatar May 02 '20 16:05 pacien

Ah I think I now understand what the use case is: you want to be able to directly download and deploy a sub directory from a Git repository and deploy that as a package?

Currently, the JSON specification only supports dependency specifiers that are in NPM's package.json specification. I don't believe the vanilla NPM supports such dependency specifiers, but I might be mistaken?

Anyway, what I believe the real requirement is some way to conveniently deploy mono repositories in which sub parts are NPM projects?

Currently, this is not really possible to do without hacks/workarounds, but providing a solution for this is on my radar. As soon I have implemented my planned refactoring for the node-env.nix module this should become doable.

At the moment, to solve such problems I would suggest to create some kind of "empty shadow project" from a sub project's package json, build that empty project and integrate the resulting Nix expressions into the build environment of the encapsulating project.

I have created a new issue for myself: https://github.com/svanderburg/node2nix/issues/189 to address this requirement. It might take a while to complete this requirement, because it relies on some planned heavy refactorings of the node-env.nix module.

svanderburg avatar Jun 11 '20 19:06 svanderburg