Merge pull request #128119 from Simspace/yarn2nix-preserve-resolutions

yarn2nix: preserve top-level package.json resolutions field in workspace

authored by

Silvan Mosberger and committed by
GitHub
c7b52869 79fc85e9

+8 -4
+8 -4
pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix
··· 74 74 preBuild ? "", 75 75 postBuild ? "", 76 76 workspaceDependencies ? [], # List of yarn packages 77 + packageResolutions ? {}, 77 78 }: 78 79 let 79 80 extraNativeBuildInputs = ··· 98 99 99 100 workspaceJSON = pkgs.writeText 100 101 "${name}-workspace-package.json" 101 - (builtins.toJSON { private = true; workspaces = ["deps/**"]; }); # scoped packages need second splat 102 + (builtins.toJSON { private = true; workspaces = ["deps/**"]; resolutions = packageResolutions; }); # scoped packages need second splat 102 103 103 104 workspaceDependencyLinks = lib.concatMapStringsSep "\n" 104 105 (dep: '' ··· 176 177 177 178 packageGlobs = if lib.isList package.workspaces then package.workspaces else package.workspaces.packages; 178 179 180 + packageResolutions = package.resolutions or {}; 181 + 179 182 globElemToRegex = lib.replaceStrings ["*"] [".*"]; 180 183 181 184 # PathGlob -> [PathGlobElem] ··· 223 226 inherit name; 224 227 value = mkYarnPackage ( 225 228 builtins.removeAttrs attrs ["packageOverrides"] 226 - // { inherit src packageJSON yarnLock workspaceDependencies; } 229 + // { inherit src packageJSON yarnLock packageResolutions workspaceDependencies; } 227 230 // lib.attrByPath [name] {} packageOverrides 228 231 ); 229 232 }) ··· 245 248 extraBuildInputs ? [], 246 249 publishBinsFor ? null, 247 250 workspaceDependencies ? [], # List of yarnPackages 251 + packageResolutions ? {}, 248 252 ... 249 253 }@attrs: 250 254 let ··· 264 268 preBuild = yarnPreBuild; 265 269 postBuild = yarnPostBuild; 266 270 workspaceDependencies = workspaceDependenciesTransitive; 267 - inherit packageJSON pname version yarnLock offlineCache yarnFlags pkgConfig; 271 + inherit packageJSON pname version yarnLock offlineCache yarnFlags pkgConfig packageResolutions; 268 272 }; 269 273 270 274 publishBinsFor_ = unlessNull publishBinsFor [pname]; ··· 298 302 '') 299 303 workspaceDependenciesTransitive; 300 304 301 - in stdenv.mkDerivation (builtins.removeAttrs attrs ["yarnNix" "pkgConfig" "workspaceDependencies"] // { 305 + in stdenv.mkDerivation (builtins.removeAttrs attrs ["yarnNix" "pkgConfig" "workspaceDependencies" "packageResolutions"] // { 302 306 inherit src pname; 303 307 304 308 name = baseName;