Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildYarnPackage: Add support for packageOverrides
This is similar to b5cd694, which added the attribute to mkNodeModule and buildNpmPackage but didn't do it for the buildYarnPackage flavour. However, we're using lib.extends instead of a plain attribute set, since we want to tread the original package set as a fixed point to be compasable with multiple levels of overrides, similar to how it's done with nixpkgs overlays. In my case it's to quickly override a dependency fetched from GitHub, eg. like this: let mydep = "https://github.com/someowner/somerepo.git"; newMydep = pkgs.fetchFromGitHub { owner = "someowner"; repo = "somerepo"; rev = "..."; sha256 = "..."; fetchSubmodules = true; leaveDotGit = true; }; in buildYarnPackage { # ... nativeBuildInputs = lib.singleton (pkgs.writeScriptBin "git" '' #!${pkgs.python3.interpreter} import sys, os for n, arg in enumerate(sys.argv): if arg == '${mydep}': sys.argv[n] = '${newMydep}' os.execv('${pkgs.git}/bin/git', sys.argv) ''); packageOverrides = lib.singleton (self: super: { ${mydep} = super.${mydep} // { path = "dummy"; }; }); # ... } I know that the way I've done the above is probably winning the first price for "the ugliest override" but since I'm not particularly invested in anything related to node.js, I'm usually pretty cruel when it comes to it. So the above example is just to have a complete almost-real-world example for reference and in this case it's to work around serokell#7. Signed-off-by: aszlig <[email protected]>
- Loading branch information