-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
yarn2nix doesn't use .npmrc settings #139227
Comments
Hey, thanks for reporting this! Are you using mkYarnPackage with a yarn.nix file ? Or are you trying to use the I think yarn.nix will try to just fetch that dependendency without any secrets. This seems to be a case where you need to override the definition for that dependency with your own. |
@happysalada Thanks for the quick response. I'm using yarn.lock directly, no intermediate yarn.nix. I read the doc you sent, and I've tried adding preBuild to the pkgConfig for the fontawesome packages where I copy in the .npmrc. I also tried adding yarnPreBuild to do the same. Here's the gist of it: yarnPreBuild = ''
cp ${./.npmrc} ./.npmrc
''; Neither worked. Maybe I'm putting it in the wrong place, or maybe I need to tweak a different setting to get the build to use the auth token header rather than .npmrc here? How would you configure one package to use an auth token header when fetching it? It's fine if it's in the derivation for now, I can figure out how to manage the secret after I just get something to work. |
I realise now my explanation wasn't super clear, sorry about that! :-) yarn2nix without a yarn.nix will basically try to create a yarn.nix from the yarn.lock. It won't however respect the .npmrc, even if it is added. What I had in mind was using the Here is what I think would be the easiest way (even if it's not exactly ideal).
I'm not the one who wrote the original yarn2nix and we are currently trying to make the next version of this tool. @loafofpiecrust let me know if any of this doesn't make sense or if you struggle with anything. |
Thanks for the elaboration! I'll try generating a |
You're definitely right here. The idea would be to enable an override of a particular dependency with a path to read the secret. I think that use case has never been envisioned yet. Hopefully designing the next version of the tool, we can try to make this possible. |
I think authentication for fetching is nothing that can be implemented nicely in any nix library. Authentication must be supported by builtin fetchers directly, as it is already by |
So I read a little bit more about this issue in general. @DavHau I don't think the answer is "avoid fetching that requires authentication" because that basically rules out any business use, and we can't expect all dependencies to be free all the time. @happysalada It looks like Edit: related issue |
I'd assume that It is interesting so see that different fetchers are preferred in different situations. This will help the development of dream2nix. There is already an |
I thought I like the idea of dream2nix, thanks for linking the project. |
I actually found an alternate solution to this issue than using {
name = "https___npm.fontawesome.com__fortawesome_free_brands_svg_icons___5.15.4_free_brands_svg_icons_5.15.4.tgz";
path = fetchurl {
name = "https___npm.fontawesome.com__fortawesome_free_brands_svg_icons___5.15.4_free_brands_svg_icons_5.15.4.tgz";
url = "https://npm.fontawesome.com/@fortawesome/free-brands-svg-icons/-/5.15.4/free-brands-svg-icons-5.15.4.tgz";
sha1 = "ec8a44dd383bcdd58aa7d1c96f38251e6fec9733";
curlOpts = ''-K ${./.fontawesome}'';
};
} And my
With this method, I can either encrypt the file with agenix or live with it being in the store, but at least I can do it. Now, to make this particular solution work directly from |
nice find! |
Yeah so I am passing a path to curl, ultimately. I just started here with putting it directly in the store for a test. Like you said, in production I might use a secret solution like agenix to put the encrypted file at a fixed path that I can reference instead. I think my PR should allow this use case. |
I marked this as stale due to inactivity. → More info |
yarn2nix does not support .npmrc yet <NixOS/nixpkgs#139227>.
yarn2nix does not support .npmrc yet <NixOS/nixpkgs#139227>.
yarn2nix does not support .npmrc yet <NixOS/nixpkgs#139227>.
Describe the bug
The
mkYarnPackage
function doesn't apply settings from.npmrc
. I use font awesome pro, which requires setting an authentication token in.npmrc
. When I try to build a package depending on it, I get a 401 because the auth token isn't included in the request.Edit: Looks like the real issue is actually getting Nix to include the auth token header when downloading packages to the nix store.
Steps To Reproduce
Steps to reproduce the behavior:
.npmrc
to your repo with similar contents:mkYarnPackage
I know reproducing this exact situation may be unreasonable since it's a paid package, so there's probably a similar test you could run.
Expected behavior
All settings in
.npmrc
applied when building a yarn package.Additional context
In the code, looks like yarn2nix may just need to copy over
.npmrc
during the buildPhase.Notify maintainers
@Stunkymonkey @happysalada
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Maintainer information:
The text was updated successfully, but these errors were encountered: