yarnConfigHook: prevent yarn from resolving dependencies using git

Fixes #483500. Tested with the following:

```diff
diff --git i/pkgs/by-name/gr/graphest/package.nix w/pkgs/by-name/gr/graphest/package.nix
index 2c6093b385d2..d8f54103a8fc 100644
--- i/pkgs/by-name/gr/graphest/package.nix
+++ w/pkgs/by-name/gr/graphest/package.nix
@@ -23,14 +23,13 @@

 stdenv.mkDerivation (finalAttrs: {
   pname = "graphest";
-  # 1.8.2 cannot build due to https://github.com/NixOS/nixpkgs/issues/483500
-  version = "1.8.2-unstable-2026-01-21";
+  version = "1.8.2";

   src = fetchFromGitHub {
     owner = "unageek";
     repo = "graphest";
-    rev = "2bcb478acd40a1174606e51f4affeca56446c9f6";
-    hash = "sha256-+onb21xb8nhEKIL/B8sNufWaPVhABnpU3uIyRn4ISWQ=";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-cFcakTi2SRogz3pge4gxhfowjNwhS1G3QT32N7MFIdw=";
   };

   patches = [
@@ -65,7 +64,7 @@ stdenv.mkDerivation (finalAttrs: {

   yarnOfflineCache = fetchYarnDeps {
     yarnLock = finalAttrs.src + "/yarn.lock";
-    hash = "sha256-krpJflsoUPIzhdtyQu3WmapM4C63adwOq2Q6inUa3Xk=";
+    hash = "sha256-3lh1yx2wJyYKkSGx1zMzHBdAZzMj+k0VcKBa4Mf8DAU=";
   };
   env.ELECTRON_SKIP_BINARY_DOWNLOAD = 1;

```
This commit is contained in:
Doron Behar
2026-02-08 01:00:31 +02:00
parent f5fb7f6782
commit 366191a9d1
@@ -33,7 +33,9 @@ const fixupYarnLock = async (lockContents, verbose) => {
if (hash)
pkg.resolved += `#${hash}`
return [dep, pkg]
// Rewrite key to remove git+ prefix and .git suffix to prevent yarn git resolver
let fixedDep = dep.replace(/@git\+/, '@').replace(/\.git(#|$)/, '$1')
return [fixedDep, pkg]
})
)