forked from mirrors/nixpkgs
yarn2nix: add easy yarn & nodejs pkg overrides
Projects often require a specific major version of NodeJS, and sometimes a specific yarn version. Since yarn2nix utilities are accessed from nixpkgs now, there is no simple way to override versions of nodejs and yarn without complex solutions like an overlay. This adds `yarn` and `nodejs` as optional attribute arguments to `mkYarnModules`, `mkYarnPackage`, and `mkYarnWorkspace`. They default to the same versions that are currently being used, and the nodejs input to yarn is overridden so that it will match if only `nodejs` is overridden by the user. These arguments will also cascade from `mkYarnWorkspace` -> `mkYarnPackage` -> `mkYarnModules`, making per-package overrides very simple.
This commit is contained in:
parent
bdaf0a39fe
commit
31f7acfbb5
|
@ -2,7 +2,7 @@
|
|||
, nodejs ? pkgs.nodejs
|
||||
, yarn ? pkgs.yarn
|
||||
, allowAliases ? pkgs.config.allowAliases
|
||||
}:
|
||||
}@inputs:
|
||||
|
||||
let
|
||||
inherit (pkgs) stdenv lib fetchurl linkFarm callPackage git rsync makeWrapper runCommandLocal;
|
||||
|
@ -70,6 +70,8 @@ in rec {
|
|||
offlineCache ? importOfflineCache yarnNix,
|
||||
yarnFlags ? [ ],
|
||||
ignoreScripts ? true,
|
||||
nodejs ? inputs.nodejs,
|
||||
yarn ? inputs.yarn.override { nodejs = nodejs; },
|
||||
pkgConfig ? {},
|
||||
preBuild ? "",
|
||||
postBuild ? "",
|
||||
|
@ -169,6 +171,8 @@ in rec {
|
|||
src,
|
||||
packageJSON ? src + "/package.json",
|
||||
yarnLock ? src + "/yarn.lock",
|
||||
nodejs ? inputs.nodejs,
|
||||
yarn ? inputs.yarn.override { nodejs = nodejs; },
|
||||
packageOverrides ? {},
|
||||
...
|
||||
}@attrs:
|
||||
|
@ -226,7 +230,7 @@ in rec {
|
|||
inherit name;
|
||||
value = mkYarnPackage (
|
||||
builtins.removeAttrs attrs ["packageOverrides"]
|
||||
// { inherit src packageJSON yarnLock packageResolutions workspaceDependencies; }
|
||||
// { inherit src packageJSON yarnLock nodejs yarn packageResolutions workspaceDependencies; }
|
||||
// lib.attrByPath [name] {} packageOverrides
|
||||
);
|
||||
})
|
||||
|
@ -241,6 +245,8 @@ in rec {
|
|||
yarnLock ? src + "/yarn.lock",
|
||||
yarnNix ? mkYarnNix { inherit yarnLock; },
|
||||
offlineCache ? importOfflineCache yarnNix,
|
||||
nodejs ? inputs.nodejs,
|
||||
yarn ? inputs.yarn.override { nodejs = nodejs; },
|
||||
yarnFlags ? [ ],
|
||||
yarnPreBuild ? "",
|
||||
yarnPostBuild ? "",
|
||||
|
@ -268,7 +274,7 @@ in rec {
|
|||
preBuild = yarnPreBuild;
|
||||
postBuild = yarnPostBuild;
|
||||
workspaceDependencies = workspaceDependenciesTransitive;
|
||||
inherit packageJSON pname version yarnLock offlineCache yarnFlags pkgConfig packageResolutions;
|
||||
inherit packageJSON pname version yarnLock offlineCache nodejs yarn yarnFlags pkgConfig packageResolutions;
|
||||
};
|
||||
|
||||
publishBinsFor_ = unlessNull publishBinsFor [pname];
|
||||
|
|
Loading…
Reference in a new issue