Skip to content
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

Example for package that uses npm to build artifacts #65

Open
michaelpj opened this issue Dec 2, 2017 · 5 comments
Open

Example for package that uses npm to build artifacts #65

michaelpj opened this issue Dec 2, 2017 · 5 comments

Comments

@michaelpj
Copy link

I've been struggling all day with a package that uses npm scripts to produce bundled artifacts, rather than being used directly via npm install.

I found it pretty difficult to work out how to use the tooling here for that - an example in the README would go a long way.

@pierrebeaucamp
Copy link

I'm also trying to figure this out at the moment. Would appreciate some directions

@svanderburg
Copy link
Owner

I just briefly checked the package and the NPM deployment seems to work. However, I assume that you also want to create a Zip package with:

npm run package

Can you clarify this a bit?

@michaelpj
Copy link
Author

I'm mainly just struggling to work out how to create a nice nix derivation that produces the artifacts output by npm run package (there are various issues with dependencies, but I can deal with those). It's not clear to me how to say something like "run this command in the source tree having run npm install", or something equivalent.

This may in fact be easy, which is why I'm mainly asking for an example!

@svanderburg
Copy link
Owner

Can't you do something like this? First generate the expressions with node2nix, then add an override expression named override.nix that does something like this:

{ nixpkgs ? <nixpkgs>
, system ? builtins.currentSystem
}:

(import ./default.nix {
  pkgs = import nixpkgs { inherit system; };
  inherit system;
}).package.override {
  postInstall = ''
    patchShebangs node_modules
    npm run package
  '';
}

I was not able to fully deploy the package because for some mysterious reason webpack terminates with exit status 2.

@CMCDragonkai
Copy link

Just a question, are we meant to be using override instead of overrideAttrs or is there a special override just for Node packages like we have with the Python infrastructure overridePythonAttrs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants