nix-community / npmlock2nix

nixify npm based packages [maintainer=@andir]
Apache License 2.0
130 stars 42 forks source link

Parameterize the command that install dependencies #111

Open ilkecan opened 3 years ago

ilkecan commented 3 years ago

Basically I want to be able to pass the --ignore-scripts flag. Normally just parameterizing npm flags would be better but one might want to use npm ci instead of npm install. One possibility is to replace npm install with npm ci, hard code the latter and take the flags with a parameter like npmFlags.

I also left --nodedir=${nodeSource nodejs} hardcoded since it is not possible to pass it otherwise since nodeSource is an internal function.

ilkecan commented 3 years ago

It seems npm ci doesn't run hook scripts, so it is not an option to make it replace npm install before resolving https://github.com/nix-community/npmlock2nix/issues/110.

ilkecan commented 3 years ago

Actually I just realized even with the proposed changes the interface is not expressive enough for me. Ideally there should be a parameter named installCommands that defaults to [ "npm install --offline --nodedir=${nodeSource nodejs}" ], similar to buildCommands in npmlock2nix.build. But the problem is again, one can't reuse the --nodedir=${nodeSource nodejs}" part if they want to define the parameter themselves.

ilkecan commented 3 years ago

I just realized npmlock2nix has internal attribute, so it is actually possible to reuse nodeSource function. With this in mind, I think introducing installCommands is the better solution.