Specify nodejs executable for Kotlin Gradle plugin instead of downloading it

Is there a way to specify a nodejs executable (i.e. use $PATH to resolve it) in the Kotlin Gradle plugin instead of the downloaded one?

The problem is the following: I use NixOS which doesn’t have a traditional filesystem hierarchy. Binaries won’t find their required libraries if they are not linked with that in mind.

I’ve had a look at the code of the plugin, but I don’t know enough about the more deeper things about Gradle to know if that is a possibility.

I’ve considered re-linking the downloaded binary. This seems like a bit of a hack and I thought I’d try this before I go down this path.

You can disable downloading of Node.JS, in this case plugin will use Node.JS from system (just node command, which will be interpreted by ypur system)

rootProject.plugins.withType(NodeJsRootPlugin::class.java) {
  rootProject.the<NodeJsRootExtension>().download = false
}

I’m using the following function for this (with Kotlin 1.4.0):

Thank you, this works. Do I have to put this in all multiplatform and js projects or can I put it in a subprojects block? I tried that and I couldn’t import NodeJsRootPlugin and NodeJsRootExtension