mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-26 09:46:04 +03:00
feat(nodejs-node-modules): ensure the .bin also exists in the local node_modules
This change allows to re-locate the node_modules directory via a single copy operation. The current builder installs the .bin directory one level above the top-level package which isn't what we want for the node-modules output. This change ensures that the .bin also exists within the local node_modules directory of the current package. It also ensures that all symlinks are relative and don't point to store paths
This commit is contained in:
parent
d67e213ed3
commit
ff71cd8e18
@ -19,7 +19,6 @@
|
||||
};
|
||||
|
||||
nodeModulesDir = "${nodeModulesDrv}/lib/node_modules/${config.name}/node_modules";
|
||||
binDir = "${nodeModulesDrv}/lib/node_modules/.bin";
|
||||
in {
|
||||
imports = [
|
||||
dream2nix.modules.drv-parts.mkDerivation
|
||||
@ -43,13 +42,6 @@ in {
|
||||
if [[ "$ID" != "$currID" || ! -d "node_modules" ]];
|
||||
then
|
||||
${config.deps.rsync}/bin/rsync -a --chmod=ug+w --delete ${nodeModulesDir}/ ./node_modules/
|
||||
mkdir -p ./node_modules/.bin
|
||||
for executablePath in ${binDir}/*; do
|
||||
binaryName=$(basename $executablePath)
|
||||
target=$(realpath $executablePath)
|
||||
echo linking binary $binaryName to nix store: $target
|
||||
ln -s $target ./node_modules/.bin/$binaryName
|
||||
done
|
||||
echo -n $ID > .dream2nix/.node_modules_id
|
||||
echo "Ok: node_modules updated"
|
||||
fi
|
||||
|
@ -21,7 +21,7 @@ in {
|
||||
dontInstall = true;
|
||||
dontFixup = true;
|
||||
preBuildPhases = l.mkForce [];
|
||||
preInstallPhases = l.mkForce [];
|
||||
preInstallPhases = l.mkForce ["installPhaseNodejsNodeModules"];
|
||||
};
|
||||
|
||||
env = {
|
||||
@ -31,6 +31,20 @@ in {
|
||||
mkdir -p $nodeModules/$packageName
|
||||
cd $nodeModules/$packageName
|
||||
'';
|
||||
|
||||
# copy .bin entries
|
||||
# from $out/lib/node_modules/.bin
|
||||
# to $out/lib/node_modules/<package-name>/node_modules/.bin
|
||||
installPhaseNodejsNodeModules = ''
|
||||
mkdir -p ./node_modules/.bin
|
||||
localNodeModules=$nodeModules/$packageName/node_modules
|
||||
for executablePath in $out/lib/node_modules/.bin/*; do
|
||||
binaryName=$(basename $executablePath)
|
||||
target=$(realpath --relative-to=$localNodeModules/.bin $executablePath)
|
||||
echo linking binary $binaryName to nix store: $target
|
||||
ln -s $target $localNodeModules/.bin/$binaryName
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
||||
nodejs-granular = {
|
||||
|
Loading…
Reference in New Issue
Block a user