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

Introduce preInstallCustomCommands attribute for node modules #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AleksanderGondek
Copy link

Fixes #70 - introduce new node_modules attribute: preInstallCustomCommands.
It allows for execution of arbitrary shell scripts, running per node module pinned to given version - such approach, allows for fixing node modules which would otherwise be unfit for running on NixOS

preInstallCustomCommands allows to run arbitrary shell scripts, running per node module pinned to given version - such approach, allows for fixing node modules which would otherwise be unfit for running on NixOS
@AleksanderGondek AleksanderGondek force-pushed the feature/pre-install-custom-commands branch from ef41aa8 to 525b97c Compare May 14, 2021 12:45
@AleksanderGondek AleksanderGondek requested a review from gilligan May 14, 2021 12:49
@andir
Copy link
Collaborator

andir commented May 14, 2021

Proposal: Make preInstallCustomCommands a function instead. This would be more flexible in terms of what a user wants to execute.

Example:

preInstallCustomCommands = package_name: version: if package_name = "foo" && version == "bar" then "exit 123" else null;

@gilligan
Copy link
Collaborator

In addition to @andir 's suggestion there would also have to be some tests for this new feature. Please have a look at the existing ones and see if you can figure out how to write one in the same way.

This change modifies preInstallCustomCommands attribute, allowing the end-user to fully customize behaviour
@AleksanderGondek
Copy link
Author

I have made the preInstallCustomCommands a function.
However, I have not followed the suggested signature, as to the best of my understanding, the node module name & version are not available during the nix expression evaluation. Keeping the function as generic as possible, also helps in retaining the flexibility for the end user.

@RaitoBezarius
Copy link
Member

I am very interested into this solution as esbuild seems to be ~broken (cf #128)

@infinisil
Copy link
Contributor

With NPM 7, hook scripts, which this PR relies on, are not supported anymore, see also #110. However with #151 it will become possible to patch the sources of arbitrary packages, which should cover mostly the same use cases as hook scripts. @AleksanderGondek Could you try out #151 and see if that can be used for your use cases?

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

Successfully merging this pull request may close these issues.

Allow running custom commands in preinstall_node_modules prepare script.
5 participants