-
-
Notifications
You must be signed in to change notification settings - Fork 17.5k
fetchYarnBerryDeps: init #399404
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
fetchYarnBerryDeps: init #399404
Conversation
b80a756 to
3c1f408
Compare
3c1f408 to
c67cc9c
Compare
369d434 to
1d83279
Compare
1d83279 to
8198309
Compare
ebc5ffa to
16d9b39
Compare
16d9b39 to
911dee6
Compare
|
Noise! Isn't there a yarn command to add missing hashes or am I imagining things? I would prefer that over maintaining an extra hashes file. |
|
Another thing that should be addressed IMO: There are certain node modules that cannot be rebuilt without the network, but have an
There should be a way to access this behaviour, maybe there should be a for reference, npm ci --ignore-scripts $npmInstallFlags $npmFlags
patchShebangs node_modules
npm rebuild $npmRebuildFlags $npmFlags(To solve the problem mentioned above, we could add |
|
Yes, the packages attempting to download stuff in prepack (for git deps) or postInstall are very annoying, and have to be handled on a package by package basis. But IMO every one of them we encounter is a win for this type of packaging, because it exposes something that was potentially unsafe with the old method. I noticed the issue of patching shebangs before running rebuilds, and was planning something like this (would have been included in the push to your ytmdesktop branch once you responded): 02e3b55 @Kranzes solved the extra flags in openbao using YARN_ENABLE_SCRIPTS environment variable, but I'd accept a merge request adding |
You can push to that branch. |
|
Okay, another thing I found: Try using the fetcher on The lockfile has some lines with the following resolution value: which the fetcher cannot handle |
|
I implemented the __archiveUrl binding and tagged a new release: #401813 Also: happy to report that nix-update does not require any changes to be able to update the offlineCache hashes of fetchYarnBerryDeps. |
|
Thanks for the work to get this merged, @yuyuyureka, very much appreciated! Unfortunately, one of anki's deps ( I've filed an issue upstream, happy to instead file it over here on the |
|
The fix for the performance issue has also been included in #401813 |
Sorry, I guess I should've been more explicit here: I don't know much about the current state & internals of JS packaging. I looked at this from the perspective of a package maintainer who takes care of a package (grafana) that's affected by this change.
@yuyuyureka if you don't mind, just a question because I'm not sure I fully understand this: the node-gyp is needed for some dependencies, but not for the things in grafana's missing-hashes file (i.e. @rollup/rollup-..., @parcel/watcher-... etc) since we fetch the native versions here already. And this file is needed because these native things aren't locked because of
right? |
|
There is no change in which dependencies are installed into node_modules, including native dependencies whose hashes are missing in the yarn.lock file. I don't know which of grafana's dependencies use node-gyp, but it's the same dependencies that would have used it before. A quick grep on the build logs reveals that The missing-hashes.json file is needed, because yarn requires some cache files whose hashes are missing from yarn.lock to perform a normal |
|
Does this support I am trying to package verdaccio 6.1.2 which uses yarn berry and pnp for node modules resolution but it seems to break. You can reproduce it like this: git apply verdaccio.PATCH
git add pkgs/by-name/ve/verdaccio/package.nix
nix build .#legacyPackages.x86_64-linux.verdaccio
./result/bin/verdaccioThe last command will throw an error about requiring a non-existent dependency |
|
I don't think pnp is supported ATM. Seems like the You should somehow configure it to use If you still want to use the .pnp.cjs method, you'd probably have to copy the cache as well. I have not tried this method yet. |
|
I made it use node_modules by editing .yarnrc.yml via preConfigure = ''
yarn config set nodeLinker node-modules
'';
nativeBuildInputs = [
nodejs
yarn-berry
yarn-berry.yarnBerryConfigHook
npmHooks.npmInstallHook
];
offlineCache = yarn-berry.fetchYarnBerryDeps {
inherit (finalAttrs) src;
hash = "sha256-jzkmDxQtIFMa1LIPcvKKsXIItPntgXTavoWhd5eZWyQ=";
};
buildPhase = ''
runHook preBuild
yarn run build
runHook postBuild
'';
# this would run npm-specific logic that seems to get stuck
dontNpmPrune = true;
|
|
After checking 5 random apps that use The current tooling assumes we have node_modules, so I guess we should probably add |
|
I don't know the install process for applications using the pnp linker, but if it gets up to the yarn install, then I would say the current code supports it and it just needs more tooling to make the installation work? |
|
Okay, I came up with this solution which doesn't even use the yarnBerryConfigHook: {
lib,
stdenv,
fetchFromGitHub,
makeWrapper,
yarn-berry_3,
}:
let
yarn-berry = yarn-berry_3;
in
stdenv.mkDerivation (finalAttrs: {
pname = "verdaccio";
version = "6.1.2";
src = fetchFromGitHub {
owner = "verdaccio";
repo = "verdaccio";
tag = "v${finalAttrs.version}";
hash = "sha256-EssvN5HtGI5Hmw4EXetj5nzrkBZAAJGgOx09dlYJzhI=";
};
strictDeps = true;
nativeBuildInputs = [
makeWrapper
yarn-berry
];
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
yarn config set enableTelemetry false
# all dependencies are vendored in-repo in .yarn/cache
# we still need to run this because "unplugged packages must be fully materialized on disk to work"
yarn install
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
yarn run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/share"
cp -r . "$out/share/verdaccio"
# PnP based pacakges need `yarn node` instead of `node` to run binaries
makeWrapper ${lib.getExe yarn-berry} "$out/bin/verdaccio" \
--chdir "$out/share/verdaccio" \
--add-flags "node ./bin/verdaccio"
runHook postInstall
'';
})seems like the main issue was trying to run the binary using In this, I just copied everything into |
|
What if we update the config hook so that it detects if you're using PnP via So basically it would only do what I did manually in configurePhase. This code-path wouldn't even require the offlineCache variable. We could also make it toggleable via a variable instead of using the yarn config, but IMO the config method is cleaner. |
Closes NixOS#404580 ChangeLog: https://github.com/grafana/grafana/releases/tag/v12.0.0 A few changes were necessary here: * the provision seems to be delayed now, so the `machine.succeed` broke because the result was tested before the provisioning was finished. Using `wait_until_succeeds` to solve this. * Work around a problem that got unnoticed during NixOS#399404: the setup-hook is also run in the `goModules` derivation, but `offlineCache` is missing. As a result, the build breaks. I guess this was unnoticed because everyone had a goModules with the previous hash in their store. Co-authored-by: Emily <git@emilylange.de>
|
Hi! Just to make this explicit, because the manual currently doesn't, are |
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.