nodePackages: enable overriding src and name attrs

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2024-05-05 11:33:00 +02:00
parent 8bd9ff0f78
commit 4549773edf
No known key found for this signature in database
GPG Key ID: E13DFD4B47127951

View File

@ -109,7 +109,7 @@ let
); );
# Recursively composes the dependencies of a package # Recursively composes the dependencies of a package
composePackage = { name, packageName, src, dependencies ? [], ... }@args: composePackage = { name, packageName, src, dependencies ? [], ... }:
builtins.addErrorContext "while evaluating node package '${packageName}'" '' builtins.addErrorContext "while evaluating node package '${packageName}'" ''
installPackage "${packageName}" "${src}" installPackage "${packageName}" "${src}"
${includeDependencies { inherit dependencies; }} ${includeDependencies { inherit dependencies; }}
@ -194,7 +194,7 @@ let
# dependencies in the package.json file to the versions that are actually # dependencies in the package.json file to the versions that are actually
# being used. # being used.
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args: pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }:
'' ''
if [ -d "${packageName}" ] if [ -d "${packageName}" ]
then then
@ -496,7 +496,7 @@ let
let let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ]; extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
in in
stdenv.mkDerivation ({ stdenv.mkDerivation (finalAttrs: {
name = "${name}${if version == null then "" else "-${version}"}"; name = "${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ] buildInputs = [ tarWrapper python nodejs ]
++ lib.optional (stdenv.isLinux) utillinux ++ lib.optional (stdenv.isLinux) utillinux
@ -508,8 +508,9 @@ let
inherit dontStrip; # Stripping may fail a build for some package deployments inherit dontStrip; # Stripping may fail a build for some package deployments
inherit dontNpmInstall preRebuild unpackPhase buildPhase; inherit dontNpmInstall preRebuild unpackPhase buildPhase;
compositionScript = composePackage args; # TODO: enable overriding dependencies too?
pinpointDependenciesScript = pinpointDependenciesOfPackage args; compositionScript = composePackage { inherit packageName dependencies; inherit (finalAttrs) name src; };
pinpointDependenciesScript = pinpointDependenciesOfPackage { inherit packageName dependencies production; };
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ]; passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];