stephank / yarn-plugin-nixify

Yarn v3/v4 plugin to help with Nix packaging
BSD 2-Clause "Simplified" License
68 stars 7 forks source link

Unexpected lockfile and yarnPath values in yarn-project.nix running yarn from workspace #47

Closed iccicci closed 1 year ago

iccicci commented 1 year ago

Hi all,

using the plugin in a yarn workspace monorepo,

I noticed that running yarn from the root of the repos or from a workspace path, results in generating different values for lockfile and yarnPath in the yarn-project.nix file.

As an example, running yarn from the root of my repos or from the util worspace path, generate yarn-project.nix file with following diff:

 let

-  yarnPath = ./.yarn/releases/yarn-3.2.1.cjs;
-  lockfile = ./yarn.lock;
+  yarnPath = ./packages/util/.yarn/releases/yarn-3.2.1.cjs;
+  lockfile = ./packages/util/yarn.lock;
   cacheFolder = ".yarn/cache";

   # Call overrideAttrs on a derivation if a function is provided.

This seems to be in contrast with yarn workspace specifications which should let us running yarn from anywhere without affecting the result.

Is there some reason I don't know behind this beahvior or could this be considered a bug?

Update

As per #46 , today I run following command.

yarn plugin import "https://raw.githubusercontent.com/stephank/yarn-plugin-nixify/main/dist/yarn-plugin-nixify.js"

I'm sorry but I'm not familiar with yarn plugins so I'm not able to say which version I'm using. I hope that the information "I run this command today" is enough to identify which version I'm using.

After the plugin update, this is the diff from the same use case I described.

diff --git a/yarn-project.nix b/yarn-project.nix
index cf4e5fc41..dc4ca449e 100644
--- a/yarn-project.nix
+++ b/yarn-project.nix
@@ -14,7 +14,7 @@ let

   # Simple stub that provides the global yarn command.
   yarn = writeShellScriptBin "yarn" ''
-    exec '${nodejs}/bin/node' '${./.yarn/releases/yarn-3.2.1.cjs}' "$@"
+    exec '${nodejs}/bin/node' '${./packages/util/.yarn/releases/yarn-3.2.1.cjs}' "$@"
   '';

   # Common attributes between Yarn derivations.
@@ -115,7 +115,7 @@ let
       yarn pack --out package.tgz
       tar xzvf package.tgz --directory "$out/libexec/$name" --strip-components=1

-      cp .yarnrc* 'yarn.lock' "$out/libexec/$name"
+      cp .yarnrc* 'packages/util/yarn.lock' "$out/libexec/$name"
       cp --recursive .yarn "$out/libexec/$name"

       # If the project uses the node-modules linker, then

Thank you

rhyslbw commented 1 year ago

There's a config option that locks the expression path :lotus_position:

rhyslbw commented 1 year ago

I spoke too soon. The behaviour is the same with that option set or not. The above commit was reverted

stephank commented 1 year ago

I think this should be fixed now. Can you try updating?

yarn plugin import https://raw.githubusercontent.com/stephank/yarn-plugin-nixify/main/dist/yarn-plugin-nixify.js
iccicci commented 1 year ago

Hi @stephank , I confirm the new version 😉 fixes. Thank you very much once again for your exceptional quick replies and actions!