-
Notifications
You must be signed in to change notification settings - Fork 100
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
node2nix ignores package-lock.json on collections of packages when fetching from remote #207
Comments
@kampka Yesterday, I was trying to develop some test cases so that this kind of change is guarded from potential future breakage. I wrote two testcases: one that uses a dependency from a local directory (with lock file), and one referring to a git repository (with lock file). However, what I noticed is that the dependencies in the lock file are ignored. The project simply reevaluates the dependencies provided by the dependency's After studying some NPM docs, I learned that About the matrix-appservice-slack package: I think your modification does seem to fix that package. I believe the incompatibility has a different root cause. Not so long ago, I discovered a subtle flaw in my replicated NPM dependency resolution algorithm -- it tries to mimic NPM's behaviour for reusing dependencies provided by parent However, my implementation only looks at the I believe one of the major reasons that a package may refer to a Git repository for a library dependency (as opposed to the NPM registry) is because that dependency requires some kind of fix/modification. With my current implementation, it may happen that instead of a dependency from Git, a version of a dependency from the NPM registry is used instead (because their I'm bit thorn on how to proceed -- I can of course roll this change back, but this will break the Implementing a revised dependency resolution algorithm (that also takes the origins of the dependencies into account), is not a trivial modification and will take a bit of time. I can also for the time being keep your fix included. It will improve compatibility with some packages, but in other cases it might also break things. |
@kampka I took another look at the Currently, when you write a collections JSON file (a JSON array) then every entry is basically treated the same way as an NPM-dependency and So this explains why after your fix work the package seems to deploy -- because for every local and git dependency the However, the undesired side effect of this change is that also packages with Git dependencies that have a lock file, will have all their "locked dependencies" included. This is not what NPM does, causing differences in the generation process. I have to look into how I can change this -- what matters for the I'm thinking about introducing a replacement feature -- giving Moreover, it will also simplify the codebase. |
@kampka I have created a new experimental branch: https://github.com/svanderburg/node2nix/tree/remote-projects with a proof-of-concept implementation that does what I just explained. I have removed your changes to the Source prototypes that fetch the lock files (because dependencies and transitive dependencies should ignore them). Instead, I made a The idea of this new feature is that you can deploy remote development projects, and for these development projects you can deploy from lock files as well (and in a future revision: also use supplement JSON files etc. if desired). Normally with a (local) development project, you can generate Nix expressions from a $ node2nix -i package.json -l package-lock.json The above command expects that the I have added a new option: $ node2nix -i package.json --git-repository --git-repository git+https://github.com/svanderburg/nijs After generating the Nix expressions, I can deploy the package as follows: $ nix-env -f default.nix -iA package and even spawn a development shell, if desired: $ nix-shell -A shell Let me know if this works for you. You should do something similar for the The implementation still requires more work before it can be merged into master again. |
@kampka let me know if the feature works for you. In the meantime I have reverted the lock file inclusion because I ran into a problem with one of my non-public projects. I intend to release a new version of node2nix very soon. Maybe this feature will go into the next version. |
@svanderburg I tried to play around with your branch, and it seems to generate correct dependencies. |
@svanderburg Any way we can make progress on the |
I have a concrete problem with a package in nixpkgs: https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/matrix-synapse/matrix-appservice-slack
The package currently fetches the sources from github, compiles the tsc sources and installs the package.
However, node2nix ignores the remote
package-lock.json
for packages that are defined as a collection in the nixpkgspackage.json
as per https://github.com/svanderburg/node2nix#deploying-a-collection-of-npm-packages-from-the-npm-registryThis poses a problem when deploying sources that require a correct
package-lock.json
, as in this case, the dependencies of upstream packages are not compatible (typescript compile) with the dependencies required to build the package.Thus, bumping the package to version
1.6.0
(latest stable) will fail duringnpm build
.The text was updated successfully, but these errors were encountered: