nodejs/importNpmLock: init source overrides option

This commit is contained in:
Johannes Kirschbauer 2024-09-02 11:24:50 +02:00
parent 6c32f0a67a
commit 34b7d209bb
No known key found for this signature in database

View File

@ -72,6 +72,10 @@ lib.fix (self: {
# Example: { "node_modules/axios" = { curlOptsList = [ "--verbose" ]; }; } # Example: { "node_modules/axios" = { curlOptsList = [ "--verbose" ]; }; }
# This will download the axios package with curl's verbose option. # This will download the axios package with curl's verbose option.
, fetcherOpts ? {} , 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 let
mapLockDependencies = mapLockDependencies =
@ -94,10 +98,10 @@ lib.fix (self: {
mapAttrs mapAttrs
(modulePath: module: (modulePath: module:
let let
src = fetchModule { src = packageSourceOverrides.${modulePath} or (fetchModule {
inherit module npmRoot; inherit module npmRoot;
fetcherOpts = fetcherOpts.${modulePath} or {}; fetcherOpts = fetcherOpts.${modulePath} or {};
}; });
in in
cleanModule module cleanModule module
// lib.optionalAttrs (src != null) { // lib.optionalAttrs (src != null) {