Closed thomashoneyman closed 2 years ago
Actually, setting the environment variable in the shell derivation is working:
{
shell = npmlock2nix.shell {
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1;
shellHook = ''
echo $PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD
'';
}
Starting a Nix shell with the above code, with install scripts disabled, will print out 1
(or whatever you set the env var to) in the console. So clearly this env variable is around, but it doesn't appear to be taking effect when NPM is running the installation. Is it possible that it isn't propagating from the shell to the internal call to the node_modules
function?
Ah! Ok, this is what get_node_modules_attrs
must be for, then:
{
shell = npmlock2nix.shell {
node_modules_attrs = { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1; };
};
}
This behaves the way I would expect: even without install scripts disabled, this properly skips the browser download.
Hi all -- wonderful library!
I'm attempting to use playwright for browser automation on nodejs, but simply installing the library via
npmlock2nix
fails because it has an install script that will download bundled browsers (naturally, this isn't allowed in a Nix environment).I can work around the install script by forking
npmlock2nix
and updating it to pass the--ignore-scripts
flag to the npm install command on ininternal.nix#L401
. However, I'd prefer to use environment variables supported by Playwright to turn off installing browsers.Outside of Nix I can do that like this:
However, I'm struggling with getting this environment variable to take when using
npmlock2nix
. I tried putting it my shell:Most likely this is just my experience, but I'm not seeing how I can set environment variables here that NPM will pick up. Any advice is appreciated!