ArdanaLabs / DanaSwapUI

Other
3 stars 3 forks source link

nixifying this repo. #14

Closed nixinator closed 2 years ago

nixinator commented 2 years ago

The way npm works, with it's many many dependence, versions, it's habit of download compiled binaries on to your system, or in fact building C/C++ source code is not very nix friendly (at all)

Node2nix does it best to parse the package.json and create a nix derivation from that.

> node-gyp-build

sh: /nix/store/pf5dl9n7hsrfzamm16wpzjbf65ic471i-application-0.1.0/lib/node_modules/application/node_modules/.bin/node-gyp-build: /usr/bin/env: bad interpreter: No such file or directory
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! bufferutil@4.0.5 install: `node-gyp-build`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the bufferutil@4.0.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I'm going to rewind nixpkgs to an early revision as i've got a feeling this is a regression.

nixinator commented 2 years ago

Yeah, it's seems no matter what nixpkgs revision i try, this has never worked. So it's going to need to be packaged manually. Currently node2nix is generating a node-packages.nix file containing.

cat node-packages.nix | grep name | wc -l

2284

so if the above package is fixed, anyone on of the other 2284 packages that this repo needs might not build. So it's hard to estimate how much time this is going to take.

nixinator commented 2 years ago

so, conversing with @MatthewCroughan , it's quite possible bufferutil@4.0.5 , because it's needs 'node-gyp-build' as a build dependency. This is even stated in the node2nix documentation. Here's a reminder.

A few exotic NPM packages may have dependencies on native libraries that reside somewhere on the user's host system. Unfortunately, NPM's metadata does not specify them, and as a consequence, it may result in failing Nix builds due to missing dependencies.

I'm hoping/wishing/praying that dream2nix can pick stuff like this up, but if it's not in the node package metadata then i can't see how that would work. What package manager doesn't declare all it's deps in the first place.. Absolutely shocking that this is use by millions of node developers around the world!. I'm guess I've just been spoilt with derivations, the clearly state there build and run time dependencies.

nixinator commented 2 years ago

ok, no joy with node2nix , or in fact with a nix-shell (npm install/npm start) outside if a nix-build.

However, some joy with yarn within a nix-shell. I'll commit a branch for testing. Experimenting with yarn2nix may prove fruitful and get a working deployment with nix-build before going the 'star trek' route, with dream2nix.

nixinator commented 2 years ago

@MatthewCroughan which branch has the dream2nix build in it? I'd like to give it a whirl.

MatthewCroughan commented 2 years ago

@nixinator It's now in the main branch thanks to the following commits: