Comments (8)
There's one other issue, the format of dependencies github:owner/name produces different directory layout in node_packages(owner/name instead of only name), i also have to handle this in nix.
from npm2nix.
Ouch, I wonder how this works for npm ls
.
from npm2nix.
So I dug a little again, but isn't npm shrinkwrap
what we want?
For instance:
cd popcorntime
npm install
npm shrinkwrap
cp npm-shrinkwrap.json nixpkgs/pkgs/applications/video/popcorntime/
Inside fetchnpm.nix:
stdenv.mkDerivation {
builder = ''
cp ${./npm-shrinkwrap.json} ./
npm install
cp -r node_modules $out
'';
outputHash = "...";
}
In default.nix link node_modules to the result of fetchnpm.
EDIT: I'm also wondering whether the result of installing shrinkwrapped dependencies will always result in the same node_modules (same hash). Do you know, or is this something to just try?
It's just an example, but is this a viable direction?
from npm2nix.
I did an experiment with npm-shrinkwrap. I ran npm shrinkwrap
in popcorntime's repository and used the resulting file in a nix-expression where it runs npm install
. There was some hackery, but it seems to be creating the same node_modules directory each time it is called here.
See here: https://gist.github.com/bobvanderlinden/05cb8e4b4400618ee487
from npm2nix.
The problem with shrinkwrap is that it uses the currently installed modules. If you run it against a fresh source without node_modules, it is empty.
Basically we need something that gets a package.json and dumps out the resolution. This resolution is the description nix needs to build the packages.
Then each of the packages in the resolution can be built, using the resolved dependencies. To get around the symlinked-dependencies-use-real-location-for-dependencies problem simply symlink one level down.
from npm2nix.
It might be a side-effect, but isn't the result of npm install && npm shrinkwrap
the resolution you're looking for? It outputs a shrinkwrap file that contains the package names and versions of that time. Npm knows where to get those exact files. If that ran when you're packaging an application and include the shrinkwrap file in the nix package, it'll result in the exact same node_modules contents. A hash for the resulting node_modules
directory will assert it is indeed always the same (it should be because that is what shrinkwrap is meant for).
Additionally, in an ideal situation the devs of an application itself include their version of the shrinkwrap file upon releasing stable versions. This can be reused, so that the package will include the exact packages the developers intended the application to use.
It's probably less space efficient and cost more time building than using npm2nix, but it might be more practical for maintaining some huge and complex packages.
from npm2nix.
may be it can be closed?
from npm2nix.
I haven't used npm2nix for quite a while, I'll close it. 👍
from npm2nix.
Related Issues (20)
- Relative file paths in package.json are treated as github URLs HOT 2
- generated file is incomplete HOT 16
- Generates incorrect default.nix for iojs
- The devDependencies are ignored HOT 1
- npm pack doesn't work on optimised store
- handle deps with git+ssh locations HOT 1
- #tree references not working
- There is no `file` variable HOT 1
- Disable npm user config HOT 2
- npm-registry-client 0.2.27 can't handle scoped packages. HOT 1
- Cannot rebuild nix-packages-generated.nix HOT 2
- git rev-parse's stdout ended before 64 characters were read HOT 9
- Problem of "postinstall"
- ETIMEDOUT and ECONNRESET
- scoped packages still fail HOT 1
- "not a valid repository name" error HOT 1
- Make clear that this project is unmaintained HOT 1
- Error during fetch: Could not find version matching
- Status of the repository? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from npm2nix.