mkYarnPackage: fix uncopied resolutions field
Yarn only uses the "resolutions" field in the top-level package.json
file of a workspace. While it has been taken into account for
mkYarnWorkspace (9801e6e53d
), it has not
been fixed for mkYarnPackage yet, which also uses the yarn workspace
mechanism under the hood.
A bit of care was needed because we don't want to introduce any IFD.
This commit is contained in:
parent
747927516e
commit
6bf78d8d3d
|
@ -99,9 +99,17 @@ in rec {
|
||||||
""
|
""
|
||||||
) (builtins.attrNames pkgConfig));
|
) (builtins.attrNames pkgConfig));
|
||||||
|
|
||||||
workspaceJSON = pkgs.writeText
|
# build-time JSON generation to avoid IFD
|
||||||
"${name}-workspace-package.json"
|
# see https://nixos.wiki/wiki/Import_From_Derivation
|
||||||
(builtins.toJSON { private = true; workspaces = ["deps/**"]; resolutions = packageResolutions; }); # scoped packages need second splat
|
workspaceJSON = pkgs.runCommand "${name}-workspace-package.json"
|
||||||
|
{
|
||||||
|
nativeBuildInputs = [ pkgs.jq ];
|
||||||
|
inherit packageJSON;
|
||||||
|
passAsFile = [ "baseJSON" ];
|
||||||
|
baseJSON = builtins.toJSON { private = true; workspaces = [ "deps/**" ]; resolutions = packageResolutions; };
|
||||||
|
} ''
|
||||||
|
jq --slurpfile packageJSON "$packageJSON" '.resolutions = $packageJSON[0].resolutions + .resolutions' <"$baseJSONPath" >$out
|
||||||
|
'';
|
||||||
|
|
||||||
workspaceDependencyLinks = lib.concatMapStringsSep "\n"
|
workspaceDependencyLinks = lib.concatMapStringsSep "\n"
|
||||||
(dep: ''
|
(dep: ''
|
||||||
|
|
Loading…
Reference in a new issue