svanderburg / node2nix

Generate Nix expressions to build NPM packages
MIT License
508 stars 97 forks source link

Using node2nix to package an electron app #125

Open markus1189 opened 5 years ago

markus1189 commented 5 years ago

Hi,

I am currently building the APL IDE ride from https://github.com/Dyalog/ride/

The node2nix command works perfectly in a local clone of the package, I can nix-build the generated default.nix and inside of the result, I can run the electron app using npm start.

So far so good, I am now wondering, how I could wrap this whole process up in a single nix file that generates the built electron app and adds an wrapper that just calls npm start, but I don't know how to do this.

I guess it would help, if there is a way to set the src directory for the derivation generated by node2nix, could this be done?

svanderburg commented 5 years ago

Hi,

I assume that you want to create an executable for an NPM package that executes the appropriate commands to start the app?

You can also create an override, then use the postInstall hook to populate a the bin/ directory with a shell script executable that executes the start process. The README.md file of node2nix describes how this hook can be used.

If you are looking for examples, in the Nixpkgs repository, the pkgs/development/node-packages/default-v8.nix creates wrapped executables for node2nix and pnpm2nix. You can do something similar -- instead of wrapping the executable, generate a shell script from scratch.