Repository navigation
pnpm.fetchDeps: Add workspace and custom pnpm config commands support - #323493
Conversation
ada805a to
b410759
Compare
There was a problem hiding this comment.
i think it would be much better to just use a built in phase here
i.e., if someone wants to set specific options or run arbitrary commands, they can just use postConfigure/postInstall/etc from mkDerivation rather than this (single) unique phase
this would require splitting up some of the internal phases here, namely when HOME, store-dir, and other defaults are applied - they should probably in the configurePhase
There was a problem hiding this comment.
i think it would be much better to just use a built in phase here
i.e., if someone wants to set specific options or run arbitrary commands, they can just use
postConfigure/postInstall/etc frommkDerivationrather than this (single) unique phasethis would require splitting up some of the internal phases here, namely when
HOME,store-dir, and other defaults are applied - they should probably in theconfigurePhase
Hmm you have a point, but still though, even if I'd simply move the runHook preInstall line after HOME is set, which would allow to perform such an override, I'd have to do something like this:
stdenv.mkDerivation (finalAttrs: {
# ...
pnpmDeps = (pnpm_8.fetchDeps {
inherit (finalAttrs) pname version src pnpmWorkspace;
hash = "sha256-n7HTd/rKxJdQKnty5TeOcyvBU9j/EClQ9IHqbBaEwQE=";
}).overrideAttrs(_: {
preInstall = finalAttrs.prePnpmInstall;
});
prePnpmInstall = ''
pnpm config set dedupe-peer-dependents false
'';
# ...
})Seems much more ugly. Even if we'll just rename the argument to preInstall, such that the interface would look like this:
stdenv.mkDerivation (finalAttrs: {
# ...
pnpmDeps = pnpm_8.fetchDeps {
inherit (finalAttrs) pname version src pnpmWorkspace;
preInstall = finalAttrs.prePnpmInstall;
hash = "sha256-n7HTd/rKxJdQKnty5TeOcyvBU9j/EClQ9IHqbBaEwQE=";
};
prePnpmInstall = ''
pnpm config set dedupe-peer-dependents false
'';
# ...
})It is still a bit weird IMO how these arguments are named differently, since they serve exactly the same purpose.
If you weren't thinking of either of these interfaces, I didn't fully understand you.
There was a problem hiding this comment.
| extraPnpmInstallFlags = | |
| if pnpmWorkspace != "" then "--filter=${pnpmWorkspace}" | |
| else ""; | |
| installFlags = lib.optional (pnpmWorkspace != "") "--filter=${pnpmWorkspace}"; |
this would also be nice as similar to above, callers would be able to use standard mkDerivation variables rather than unique ones found here
There was a problem hiding this comment.
this would also be nice as similar to above, this would also be nice as similar to above, callers would be able to use standard
mkDerivationvariables rather than unique ones found here
I agree that installFlags is a better variable name (pushed this change), but I'm not sure how that helps someone override this variable with an interface similar to mkDerivation...
There was a problem hiding this comment.
| # Run any additional pnpm configuration commands that users provide. | |
| ${prePnpmInstall} |
see above. this wouldn't be required anymore
There was a problem hiding this comment.
Another option would be to runHook prePnpmInstall here.
There was a problem hiding this comment.
Why can't we detect pnpmWorkspace and set that automatically in the hook?
There was a problem hiding this comment.
Why can't we detect pnpmWorkspace and set that automatically in the hook?
See my comment regarding the pnpm.buildHook idea below.
There was a problem hiding this comment.
If we set this already, why are we doing the buildPhases above by hand? I am confused
There was a problem hiding this comment.
If we set this already, why are we doing the buildPhases above by hand? I am confused
You are confused because (surprisingly) we don't have a pnpm.buildHook. If the project you try to package doesn't have a specific workspace you are interested in, using npmHooks.npmBuildHook probably will do the job. With a specific workspace you pretty much have to use pnpm --filter=.. build. Perhaps we should add pnpm.buildHook.
|
@doronbehar would this be something we could use for wrangler in #322573 ? should we wait for this to possibly merge in and then update the pr with these new commands? the pr builds and works fine, but uses quite a bit of disk and needs a bit more testing. |
b410759 to
036d922
Compare
036d922 to
a21e1c5
Compare
a21e1c5 to
4334aaa
Compare
9871fba to
5ed4fad
Compare
|
There are a few unresolved review conversations above, so I let @SuperSandro2000 and @getchoo a chance to reply to them for a few days. |
5ed4fad to
4fefd63
Compare
|
Thanks for the suggestions @gepbird! Both of them fixed. |
Co-authored-by: Niklas Korz <[email protected]>
…nfiguration commands Solves NixOS#316908
Close NixOS#309100 . Co-authored-by: Pyrox <[email protected]>
4fefd63 to
d128948
Compare
|
Thanks @niklaskorz for the review :) I fixed that in separate commits before the main commits of the PR. I will merge this when CI is green. |
|
This PR broke the package bash-language-server, which has been fixed with #333701. |
|
The resulting dependencies for the packages |
Thanks for noticing that. I suspect that what me and @pyrox0 experienced back when we initially worked on this PR, was a related to this upstream pnpm issue. Perhaps indeed now the workspace support could be simplified. I'm pretty sure though, that for Hence for now, I think we'll have to wait for more packages that use pnpm workspaces to aggregate in Nixpkgs, and we can revise this topic. |
Description of changes
Adds
pnpmWorkspaceandextraPnpmCommandsoptions for pnpm.fetchDeps callsThese can be used to either use a specific pnpm workspace for installation, and to run custom pnpm config commands during dependency fetching. Some packages may need a setting such as
dedupe-peer-dependentsset to a non-default value, and so this allows them to set those when needed.See the discussion in #309100 (starting at #309100 (comment)) as to why these are useful.
I've also updated the documentation appropriately.
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.