diff options
author | Richard Wallace <richard.wallace@simspace.com> | 2022-01-05 13:09:34 -0700 |
---|---|---|
committer | Richard Wallace <rwallace@thewallacepack.net> | 2022-03-23 14:34:01 -0700 |
commit | 9801e6e53dc321e860c822f7f3c370e76d218a42 (patch) | |
tree | 7a5270bcfd4181038d7807ad0316ffb5af663b2d /pkgs/development/tools/yarn2nix-moretea/yarn2nix | |
parent | 2f8299f32199cbb0a8049bd422fd98842781dced (diff) |
yarn2nix: preserve top-level package.json resolutions field in workspace
The `package.json` produced when building node_modules for a workspace ignores the `resolutions` from the project `package.json`. This results in dependencies being resolved in a way that conflicts with the `yarn.lock` file. To fix this, we need to preserve the `resolutions`.
Diffstat (limited to 'pkgs/development/tools/yarn2nix-moretea/yarn2nix')
-rw-r--r-- | pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix b/pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix index b0bf715e66e87..01b9e44623af6 100644 --- a/pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix +++ b/pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix @@ -74,6 +74,7 @@ in rec { preBuild ? "", postBuild ? "", workspaceDependencies ? [], # List of yarn packages + packageResolutions ? {}, }: let extraBuildInputs = (lib.flatten (builtins.map (key: @@ -93,7 +94,7 @@ in rec { workspaceJSON = pkgs.writeText "${name}-workspace-package.json" - (builtins.toJSON { private = true; workspaces = ["deps/**"]; }); # scoped packages need second splat + (builtins.toJSON { private = true; workspaces = ["deps/**"]; resolutions = packageResolutions; }); # scoped packages need second splat workspaceDependencyLinks = lib.concatMapStringsSep "\n" (dep: '' @@ -170,6 +171,8 @@ in rec { packageGlobs = package.workspaces; + packageResolutions = package.resolutions or {}; + globElemToRegex = lib.replaceStrings ["*"] [".*"]; # PathGlob -> [PathGlobElem] @@ -217,7 +220,7 @@ in rec { inherit name; value = mkYarnPackage ( builtins.removeAttrs attrs ["packageOverrides"] - // { inherit src packageJSON yarnLock workspaceDependencies; } + // { inherit src packageJSON yarnLock packageResolutions workspaceDependencies; } // lib.attrByPath [name] {} packageOverrides ); }) @@ -239,6 +242,7 @@ in rec { extraBuildInputs ? [], publishBinsFor ? null, workspaceDependencies ? [], # List of yarnPackages + packageResolutions ? {}, ... }@attrs: let @@ -258,7 +262,7 @@ in rec { preBuild = yarnPreBuild; postBuild = yarnPostBuild; workspaceDependencies = workspaceDependenciesTransitive; - inherit packageJSON pname version yarnLock offlineCache yarnFlags pkgConfig; + inherit packageJSON pname version yarnLock offlineCache yarnFlags pkgConfig packageResolutions; }; publishBinsFor_ = unlessNull publishBinsFor [pname]; @@ -292,7 +296,7 @@ in rec { '') workspaceDependenciesTransitive; - in stdenv.mkDerivation (builtins.removeAttrs attrs ["yarnNix" "pkgConfig" "workspaceDependencies"] // { + in stdenv.mkDerivation (builtins.removeAttrs attrs ["yarnNix" "pkgConfig" "workspaceDependencies" "packageResolutions"] // { inherit src pname; name = baseName; |