mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-25 07:25:33 +03:00
fix: nodejs: don't build in */node_modules/*
This commit is contained in:
parent
c89f13c5d7
commit
669dbce57f
@ -315,7 +315,7 @@
|
||||
unpackPhase = ''
|
||||
runHook preUnpack
|
||||
|
||||
nodeModules=$out/lib/node_modules
|
||||
nodeModules=$(realpath ./package)
|
||||
|
||||
export sourceRoot="$nodeModules/$packageName"
|
||||
|
||||
@ -336,7 +336,7 @@
|
||||
if [ -f "$src" ]
|
||||
then
|
||||
# Figure out what directory has been unpacked
|
||||
export packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
||||
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
||||
|
||||
# Restore write permissions
|
||||
find "$packageDir" -type d -exec chmod u+x {} \;
|
||||
@ -346,7 +346,7 @@
|
||||
mv -- "$packageDir" "$sourceRoot"
|
||||
elif [ -d "$src" ]
|
||||
then
|
||||
export strippedName="$(stripHash $src)"
|
||||
strippedName="$(stripHash $src)"
|
||||
|
||||
# Restore write permissions
|
||||
chmod -R u+w -- "$strippedName"
|
||||
@ -382,9 +382,9 @@
|
||||
python $fixPackage \
|
||||
|| \
|
||||
# exit code 3 -> the package is incompatible to the current platform
|
||||
# -> Let the build succeed, but don't create lib/node_packages
|
||||
# -> Let the build succeed, but don't create lib/node_modules
|
||||
if [ "$?" == "3" ]; then
|
||||
rm -r $out/*
|
||||
mkdir -p $out
|
||||
echo "Not compatible with system $system" > $out/error
|
||||
exit 0
|
||||
else
|
||||
@ -447,11 +447,6 @@
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
cd $out
|
||||
mv $sourceRoot $out/src
|
||||
ln -s $out/src $sourceRoot
|
||||
cd $out/src
|
||||
|
||||
# execute electron-rebuild
|
||||
if [ -n "$electronHeaders" ]; then
|
||||
echo "executing electron-rebuild"
|
||||
@ -480,15 +475,16 @@
|
||||
fi
|
||||
fi
|
||||
|
||||
rm $sourceRoot
|
||||
mv $out/src $sourceRoot
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
# Symlinks executables and manual pages to correct directories
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/lib
|
||||
cp -r $nodeModules $out/lib/node_modules
|
||||
nodeModules=$out/lib/node_modules
|
||||
cd "$nodeModules/$packageName"
|
||||
|
||||
echo "Symlinking bin entries from package.json"
|
||||
python $linkBins
|
||||
|
@ -10,8 +10,6 @@ with open(os.environ.get('dependenciesJsonPath')) as f:
|
||||
with open('package.json', encoding="utf-8-sig") as f:
|
||||
package_json = json.load(f)
|
||||
|
||||
out = os.environ.get('out')
|
||||
|
||||
changed = False
|
||||
|
||||
# fail if platform incompatible
|
||||
|
@ -127,7 +127,7 @@ def symlink_bin(bin_dir, package_location, package_json, force=False):
|
||||
|
||||
# checks if dependency is already installed in the current or parent dir.
|
||||
def dependency_satisfied(root, pname, version):
|
||||
if root == "/nix/store":
|
||||
if root == "/":
|
||||
return False
|
||||
|
||||
parent = os.path.dirname(root)
|
||||
@ -138,6 +138,7 @@ def dependency_satisfied(root, pname, version):
|
||||
if version == get_package_json(f"{root}/{pname}").get('version'):
|
||||
return True
|
||||
|
||||
print(f"satisfied: parent: {parent}; pname: {pname}; version: {version}")
|
||||
return dependency_satisfied(parent, pname, version)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user