svanderburg / node2nix

Generate Nix expressions to build NPM packages
MIT License
526 stars 100 forks source link

Add documentation for support for web frameworks #212

Closed happysalada closed 3 years ago

happysalada commented 3 years ago

Thanks for the project!

I'm currently trying to make a builder for the Elixir web framework called Phoenix (What rails is to ruby). I've seen in the documentation how to use node2nix for a webpack project (which is what Phoenix is using), however I think there is one more step that I am still missing. Phoenix's directory layout is that it has all the frontend assets in an ./assets folder. That includes the package.json and the webpack configuration. When webpack is run those assets will be compiled and sent to ./priv/assets/*.

Should node2nix be run inside the ./assets folder where the package.json file is? Or should it be run inside the main directory? The problem I see with running it in the main directory is that there will be some nix expressions to handle Elixir files building as well, and those might conflict.

In figuring it out here is where I am

let
  mixDeps = fetchMixDeps { inherit src name mixEnv sha256; };

  nodeDependencies =
    (callPackage NOT_SURE_WHAT_TO_PUT_HERE { }).nodeDependencies;

the mixDeps part is already figured out. However for the nodeDependencies, I'm not sure what argument should be called in front of callPackage.

Before I've tried creating a script a little like this one https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/version-management/sourcehut/fetchNodeModules.nix However it seems a little simple, and I'm afraid to not benefit from the experience that this project has.

I would be happy to make a PR on the doc once this is figured out (if you think it's necessary of course)

sephii commented 3 years ago

@happysalada please check the updated docs (https://github.com/svanderburg/node2nix/pull/218). I hope they’ll help you get it to work!

happysalada commented 3 years ago

Thanks a lot, it is looking good. I'll try it as soon as I get a chance!

svanderburg commented 3 years ago

@happysalada Please let me know if this works for you! And if so, then this issue can be closed.

In the future, I intend to make integrations of NPM deployments in other projects more convenient. I'm already working on a prototype that makes this possible, but it will take a bit of time to complete this.

happysalada commented 3 years ago

I've just managed to test. Thanks a lot!

happysalada commented 3 years ago

When you have something new, feel free to tag me and I will be glad to test it!