Does yarn add package --build-from-source behave like npm install package --build-from-source when passing node-gyp flags to packages?

This is currently possible by using environment variables on the format npm_config_{snake_case_param}=true/false

For example, npm install --build-from-source=true becomes:

npm_config_build_from_source=true yarn install

It's documented here

Yarn does not automatically expose -- arguments of install command to lifecycle scripts (pre/post/install scripts in package.json of dependencies). Here is the code where Yarn builds Env for the script execution

You can pass specific values via env setting in .yarnrc and also it builds npm_config_* settings based on .yarnrc/.npmrc configuration.