mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-23 22:48:02 +03:00
fix(v1/nodejs): remove electron related code
This commit is contained in:
parent
8042e028bc
commit
3a8bcef617
@ -1,67 +1,9 @@
|
||||
{
|
||||
jq,
|
||||
moreutils,
|
||||
}: let
|
||||
# This is only executed for electron based packages.
|
||||
# Electron ships its own version of node, requiring a rebuild of native
|
||||
# extensions.
|
||||
# Theoretically this requires headers for the exact electron version in use,
|
||||
# but we use the headers from nixpkgs' electron instead which might have a
|
||||
# different minor version.
|
||||
# Alternatively the headers can be specified via `electronHeaders`.
|
||||
# Also a custom electron version can be specified via `electronPackage`
|
||||
electron-rebuild = ''
|
||||
# prepare node headers for electron
|
||||
if [ -n "$electronPackage" ]; then
|
||||
export electronDist="$electronPackage/lib/electron"
|
||||
else
|
||||
export electronDist="$nodeModules/$packageName/node_modules/electron/dist"
|
||||
fi
|
||||
local ver
|
||||
ver="v$(cat $electronDist/version | tr -d '\n')"
|
||||
mkdir $TMP/$ver
|
||||
cp $electronHeaders $TMP/$ver/node-$ver-headers.tar.gz
|
||||
|
||||
# calc checksums
|
||||
cd $TMP/$ver
|
||||
sha256sum ./* > SHASUMS256.txt
|
||||
cd -
|
||||
|
||||
# serve headers via http
|
||||
python -m http.server 45034 --directory $TMP &
|
||||
|
||||
# copy electron distribution
|
||||
cp -r $electronDist $TMP/electron
|
||||
chmod -R +w $TMP/electron
|
||||
|
||||
# configure electron toolchain
|
||||
${jq}/bin/jq ".build.electronDist = \"$TMP/electron\"" package.json \
|
||||
| ${moreutils}/bin/sponge package.json
|
||||
|
||||
${jq}/bin/jq ".build.linux.target = \"dir\"" package.json \
|
||||
| ${moreutils}/bin/sponge package.json
|
||||
|
||||
${jq}/bin/jq ".build.npmRebuild = false" package.json \
|
||||
| ${moreutils}/bin/sponge package.json
|
||||
|
||||
# execute electron-rebuild if available
|
||||
export headers=http://localhost:45034/
|
||||
if command -v electron-rebuild &> /dev/null; then
|
||||
pushd $electronAppDir
|
||||
|
||||
electron-rebuild -d $headers
|
||||
popd
|
||||
fi
|
||||
'';
|
||||
in ''
|
||||
}: ''
|
||||
runHook preBuild
|
||||
|
||||
# execute electron-rebuild
|
||||
if [ -n "$electronHeaders" ]; then
|
||||
echo "executing electron-rebuild"
|
||||
${electron-rebuild}
|
||||
fi
|
||||
|
||||
# execute install command
|
||||
if [ -n "$buildScript" ]; then
|
||||
if [ -f "$buildScript" ]; then
|
||||
|
@ -112,26 +112,6 @@
|
||||
(l.map
|
||||
(dep: lib.nameValuePair dep.name dep.version)
|
||||
deps));
|
||||
|
||||
electronDep =
|
||||
if ! isMainPackage name config.version
|
||||
then null
|
||||
else
|
||||
lib.findFirst
|
||||
(dep: dep.name == "electron")
|
||||
null
|
||||
deps;
|
||||
|
||||
electronVersionMajor =
|
||||
lib.versions.major electronDep.version;
|
||||
|
||||
electronHeaders =
|
||||
if
|
||||
(electronDep == null)
|
||||
# hashes seem unavailable for electron < 4
|
||||
|| ((l.toInt electronVersionMajor) <= 2)
|
||||
then null
|
||||
else config.deps."electron_${electronVersionMajor}".headers;
|
||||
in {
|
||||
deps = {nixpkgs, ...}:
|
||||
l.mapAttrs (_: l.mkDefault) {
|
||||
@ -195,12 +175,8 @@
|
||||
};
|
||||
|
||||
env = {
|
||||
# inherit pname;
|
||||
# electronAppDir = ".";
|
||||
|
||||
inherit
|
||||
dependenciesJson
|
||||
electronHeaders
|
||||
nodeDeps
|
||||
nodeSources
|
||||
;
|
||||
|
@ -3,29 +3,7 @@
|
||||
# this function needs the following arguments via env
|
||||
# packageName,
|
||||
# nodeModules,
|
||||
# electronDist,
|
||||
# electronAppDir,
|
||||
# electronHeaders
|
||||
}: let
|
||||
# Only executed for electron based packages.
|
||||
# Creates an executable script under /bin starting the electron app
|
||||
electronWrap =
|
||||
if stdenv.isLinux
|
||||
then ''
|
||||
mkdir -p $out/bin
|
||||
makeWrapper \
|
||||
$out/lib/node_modules/$packageName/node_modules/electron/dist/electron \
|
||||
$out/bin/$(basename "$packageName") \
|
||||
--add-flags "$(realpath $electronAppDir)"
|
||||
''
|
||||
else ''
|
||||
mkdir -p $out/bin
|
||||
makeWrapper \
|
||||
$out/lib/node_modules/$packageName/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron \
|
||||
$out/bin/$(basename "$packageName") \
|
||||
--add-flags "$(realpath $electronAppDir)"
|
||||
'';
|
||||
in ''
|
||||
}: ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/lib
|
||||
cp -r $nodeModules $out/lib/node_modules
|
||||
@ -49,11 +27,5 @@ in ''
|
||||
done
|
||||
fi
|
||||
|
||||
# wrap electron app
|
||||
if [ -n "$electronHeaders" ]; then
|
||||
echo "Wrapping electron app"
|
||||
${electronWrap}
|
||||
fi
|
||||
|
||||
runHook postInstall
|
||||
''
|
||||
|
Loading…
Reference in New Issue
Block a user