-
-
Notifications
You must be signed in to change notification settings - Fork 59
Move fetching into Nix and allow custom fetching #97
base: master
Are you sure you want to change the base?
Move fetching into Nix and allow custom fetching #97
Conversation
Introduces a `yarnFetch` argument that can be used to specify a custom fetcher. This is useful to weave in calls to fetchgitPrivate, or fetchurl with authentication via `netrcPhase` and `netrcImpureEnvVars`. Implementations of yarnFetch must return the resulting path, and can chain to the default behavior by calling `defaultYarnFetch`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I guess the next evolution of this PR will be to write a yarn.lock parser in nix :)
@@ -15,7 +15,7 @@ function urlToName(url) { | |||
|
|||
return url | |||
.replace('https://registry.yarnpkg.com/', '') // prevents having long directory names | |||
.replace(/[@/:-]/g, '_') // replace @ and : and - characters with underscore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to add a test-case that reproduces the issue?
I think this happens when the URL contains %2f
for example which might mean the URL has to be url-decoded instead.
# Loads the generated offline cache. This will be used by yarn as | ||
# the package source. | ||
importOfflineCache = yarnNix: | ||
let | ||
pkg = callPackage yarnNix { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's nice that callPackage is not needed anymore
ref = "${branch}"; | ||
rev = "${rev}"; | ||
}; | ||
}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an opportunity to return JSON data here and process the result with a JSON2nix converter function higher in the call stack
The idea here is to make
yarn2nix
(the program) emit pure data instead of code, and then interpret that on the Nix side. For the case of tarring up git dependencies, it means not having to embed the tar call in the generated file. It also allows custom fetchers which can embed authentication for access to private registries.While I'm here, remove instances of
%
in names. I observed this in a url escaped slash (%2f
).This is is a breaking change to the generated dependency file format. All consumers will have to regenerate their yarn.nix files.