From 34b7d209bb3c5431971722f9617a246a7061f3c0 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Mon, 2 Sep 2024 11:24:50 +0200 Subject: [PATCH] nodejs/importNpmLock: init source overrides option --- pkgs/build-support/node/import-npm-lock/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/node/import-npm-lock/default.nix b/pkgs/build-support/node/import-npm-lock/default.nix index 48057ec8891e..3c26b98d3992 100644 --- a/pkgs/build-support/node/import-npm-lock/default.nix +++ b/pkgs/build-support/node/import-npm-lock/default.nix @@ -72,6 +72,10 @@ lib.fix (self: { # Example: { "node_modules/axios" = { curlOptsList = [ "--verbose" ]; }; } # This will download the axios package with curl's verbose option. , fetcherOpts ? {} + # A map from node_module path to an alternative package to use instead of fetching the source in package-lock.json. + # Example: { "node_modules/axios" = stdenv.mkDerivation { ... }; } + # This is usefull if you want to inject custom sources for a specific package. + , packageSourceOverrides ? {} }: let mapLockDependencies = @@ -94,10 +98,10 @@ lib.fix (self: { mapAttrs (modulePath: module: let - src = fetchModule { + src = packageSourceOverrides.${modulePath} or (fetchModule { inherit module npmRoot; fetcherOpts = fetcherOpts.${modulePath} or {}; - }; + }); in cleanModule module // lib.optionalAttrs (src != null) {