stephank / yarn-plugin-nixify

Yarn v3/v4 plugin to help with Nix packaging
BSD 2-Clause "Simplified" License
68 stars 7 forks source link

Add to buildVars #60

Open goldsborough opened 1 year ago

goldsborough commented 1 year ago

I need to set an environment variable (npm auth token) required to fetch dependencies of my project. Is there a way for me to add to buildVars here to accomplish this?

stephank commented 1 year ago

This is tricky, because simply placing them in the environment via buildVars or similar results in Nix placing those credentials in /nix/store with world-readable permissions.

What might work is an option to set impureEnvVars for the fetch steps. That'd cause Nix to simply forward those environment variables. Downside is that most Nix installs are likely using nix-daemon to run builds, so the environment variables would have to be set on nix-daemon.

adrian-gierakowski commented 1 year ago

I’ve added support for private npm registry and GitHub repos in my fork

it works with nix daemon You’ll need to put the required credentials into files accessible to the daemon and add them to extra-sandbox-paths

The only other way I know is to run a proxy and inject the credentials into the requests made by the daemon