2023-10-09 19:29:22 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-11-21 19:51:51 +00:00
|
|
|
, libXScrnSaver
|
|
|
|
, makeWrapper
|
|
|
|
, fetchurl
|
2024-05-15 15:35:15 +00:00
|
|
|
, wrapGAppsHook3
|
2020-11-21 19:51:51 +00:00
|
|
|
, glib
|
|
|
|
, gtk3
|
|
|
|
, unzip
|
|
|
|
, at-spi2-atk
|
|
|
|
, libdrm
|
|
|
|
, mesa
|
|
|
|
, libxkbcommon
|
2021-03-09 03:18:52 +00:00
|
|
|
, libxshmfence
|
2024-02-29 20:09:43 +00:00
|
|
|
, libGL
|
2024-04-21 15:54:59 +00:00
|
|
|
, vulkan-loader
|
2023-10-09 19:29:22 +00:00
|
|
|
, alsa-lib
|
|
|
|
, cairo
|
|
|
|
, cups
|
|
|
|
, dbus
|
|
|
|
, expat
|
|
|
|
, gdk-pixbuf
|
|
|
|
, nss
|
|
|
|
, nspr
|
|
|
|
, xorg
|
|
|
|
, pango
|
|
|
|
, systemd
|
2023-11-16 04:20:00 +00:00
|
|
|
, pciutils
|
2020-11-21 19:51:51 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
version: hashes:
|
|
|
|
let
|
2022-02-10 20:34:41 +00:00
|
|
|
pname = "electron";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Cross platform desktop application shell";
|
|
|
|
homepage = "https://github.com/electron/electron";
|
|
|
|
license = licenses.mit;
|
2024-01-02 11:29:13 +00:00
|
|
|
mainProgram = "electron";
|
|
|
|
maintainers = with maintainers; [ travisbhartwell manveru ];
|
2022-07-14 12:49:19 +00:00
|
|
|
platforms = [ "x86_64-darwin" "x86_64-linux" "armv7l-linux" "aarch64-linux" ]
|
|
|
|
++ optionals (versionAtLeast version "11.0.0") [ "aarch64-darwin" ]
|
|
|
|
++ optionals (versionOlder version "19.0.0") [ "i686-linux" ];
|
2022-06-16 17:23:12 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
2024-04-21 15:54:59 +00:00
|
|
|
knownVulnerabilities = optional (versionOlder version "27.0.0") "Electron version ${version} is EOL";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
fetcher = vers: tag: hash: fetchurl {
|
|
|
|
url = "https://github.com/electron/electron/releases/download/v${vers}/electron-v${vers}-${tag}.zip";
|
|
|
|
sha256 = hash;
|
|
|
|
};
|
|
|
|
|
2020-11-30 08:33:03 +00:00
|
|
|
headersFetcher = vers: hash: fetchurl {
|
2022-07-14 12:49:19 +00:00
|
|
|
url = "https://artifacts.electronjs.org/headers/dist/v${vers}/node-v${vers}-headers.tar.gz";
|
2020-11-30 08:33:03 +00:00
|
|
|
sha256 = hash;
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
tags = {
|
|
|
|
x86_64-linux = "linux-x64";
|
|
|
|
armv7l-linux = "linux-armv7l";
|
|
|
|
aarch64-linux = "linux-arm64";
|
|
|
|
x86_64-darwin = "darwin-x64";
|
2022-07-14 12:49:19 +00:00
|
|
|
} // lib.optionalAttrs (lib.versionAtLeast version "11.0.0") {
|
|
|
|
aarch64-darwin = "darwin-arm64";
|
|
|
|
} // lib.optionalAttrs (lib.versionOlder version "19.0.0") {
|
|
|
|
i686-linux = "linux-ia32";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
get = as: platform: as.${platform.system} or (throw "Unsupported system: ${platform.system}");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
common = platform: {
|
2022-02-10 20:34:41 +00:00
|
|
|
inherit pname version meta;
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetcher version (get tags platform) (get hashes platform);
|
2020-11-30 08:33:03 +00:00
|
|
|
passthru.headers = headersFetcher version hashes.headers;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
electronLibPath = lib.makeLibraryPath ([
|
|
|
|
alsa-lib
|
|
|
|
at-spi2-atk
|
|
|
|
cairo
|
|
|
|
cups
|
|
|
|
dbus
|
|
|
|
expat
|
|
|
|
gdk-pixbuf
|
|
|
|
glib
|
|
|
|
gtk3
|
|
|
|
nss
|
|
|
|
nspr
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libxcb
|
|
|
|
xorg.libXcomposite
|
|
|
|
xorg.libXdamage
|
|
|
|
xorg.libXext
|
|
|
|
xorg.libXfixes
|
|
|
|
xorg.libXrandr
|
|
|
|
xorg.libxkbfile
|
|
|
|
pango
|
2023-11-16 04:20:00 +00:00
|
|
|
pciutils
|
2023-10-09 19:29:22 +00:00
|
|
|
stdenv.cc.cc.lib
|
|
|
|
systemd
|
|
|
|
]
|
|
|
|
++ lib.optionals (lib.versionAtLeast version "9.0.0") [ libdrm mesa ]
|
|
|
|
++ lib.optionals (lib.versionOlder version "10.0.0") [ libXScrnSaver ]
|
|
|
|
++ lib.optionals (lib.versionAtLeast version "11.0.0") [ libxkbcommon ]
|
|
|
|
++ lib.optionals (lib.versionAtLeast version "12.0.0") [ libxshmfence ]
|
2024-04-21 15:54:59 +00:00
|
|
|
++ lib.optionals (lib.versionAtLeast version "17.0.0") [ libGL vulkan-loader ]
|
2020-11-21 19:51:51 +00:00
|
|
|
);
|
2020-06-02 18:00:15 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
linux = {
|
|
|
|
buildInputs = [ glib gtk3 ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
unzip
|
|
|
|
makeWrapper
|
2024-05-15 15:35:15 +00:00
|
|
|
wrapGAppsHook3
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2023-10-09 19:29:22 +00:00
|
|
|
mkdir -p $out/libexec/electron $out/bin
|
|
|
|
unzip -d $out/libexec/electron $src
|
|
|
|
ln -s $out/libexec/electron/electron $out/bin
|
|
|
|
chmod u-x $out/libexec/electron/*.so*
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
patchelf \
|
|
|
|
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
2023-10-09 19:29:22 +00:00
|
|
|
--set-rpath "${electronLibPath}:$out/libexec/electron" \
|
|
|
|
$out/libexec/electron/.electron-wrapped \
|
|
|
|
${lib.optionalString (lib.versionAtLeast version "15.0.0") "$out/libexec/electron/.chrome_crashpad_handler-wrapped" }
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
# patch libANGLE
|
|
|
|
patchelf \
|
2024-04-21 15:54:59 +00:00
|
|
|
--set-rpath "${lib.makeLibraryPath [ libGL pciutils vulkan-loader ]}" \
|
2024-02-29 20:09:43 +00:00
|
|
|
$out/libexec/electron/lib*GL*
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
# replace bundled vulkan-loader
|
|
|
|
rm "$out/libexec/electron/libvulkan.so.1"
|
|
|
|
ln -s -t "$out/libexec/electron" "${lib.getLib vulkan-loader}/lib/libvulkan.so.1"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
darwin = {
|
2022-08-12 12:06:08 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
unzip
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/Applications
|
|
|
|
unzip $src
|
|
|
|
mv Electron.app $out/Applications
|
|
|
|
mkdir -p $out/bin
|
2022-08-12 12:06:08 +00:00
|
|
|
makeWrapper $out/Applications/Electron.app/Contents/MacOS/Electron $out/bin/electron
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (
|
|
|
|
(common stdenv.hostPlatform) //
|
|
|
|
(if stdenv.isDarwin then darwin else linux)
|
|
|
|
)
|