2021-01-23 12:26:19 +00:00
|
|
|
{ lib, stdenv
|
2020-11-17 15:03:53 +00:00
|
|
|
, libXScrnSaver
|
|
|
|
, makeWrapper
|
|
|
|
, fetchurl
|
|
|
|
, wrapGAppsHook
|
|
|
|
, glib
|
|
|
|
, gtk3
|
|
|
|
, unzip
|
|
|
|
, atomEnv
|
|
|
|
, libuuid
|
|
|
|
, at-spi2-atk
|
|
|
|
, at-spi2-core
|
|
|
|
, libdrm
|
|
|
|
, mesa
|
|
|
|
, libxkbcommon
|
2021-01-02 09:51:13 +00:00
|
|
|
, libappindicator-gtk3
|
2021-03-04 20:42:16 +00:00
|
|
|
, libxshmfence
|
2020-11-17 15:03:53 +00:00
|
|
|
}:
|
2019-08-09 17:45:58 +01:00
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
version: hashes:
|
2019-08-09 17:45:58 +01:00
|
|
|
let
|
2022-01-31 09:54:08 +00:00
|
|
|
pname = "electron";
|
2019-08-09 17:45:58 +01:00
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
meta = with lib; {
|
2019-08-09 17:45:58 +01:00
|
|
|
description = "Cross platform desktop application shell";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/electron/electron";
|
2019-08-09 17:45:58 +01:00
|
|
|
license = licenses.mit;
|
2020-05-19 14:01:09 +01:00
|
|
|
maintainers = with maintainers; [ travisbhartwell manveru prusnak ];
|
2021-05-19 11:48:59 +01:00
|
|
|
platforms = [ "x86_64-darwin" "x86_64-linux" "i686-linux" "armv7l-linux" "aarch64-linux" ]
|
|
|
|
++ optionals (versionAtLeast version "11.0.0") [ "aarch64-darwin" ];
|
2022-01-15 05:28:44 +00:00
|
|
|
knownVulnerabilities = optional (versionOlder version "13.0.0") "Electron version ${version} is EOL";
|
2019-08-09 17:45:58 +01:00
|
|
|
};
|
|
|
|
|
2020-02-05 18:27:16 +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-28 15:57:31 +00:00
|
|
|
headersFetcher = vers: hash: fetchurl {
|
|
|
|
url = "https://atom.io/download/electron/v${vers}/node-v${vers}-headers.tar.gz";
|
|
|
|
sha256 = hash;
|
|
|
|
};
|
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
tags = {
|
|
|
|
i686-linux = "linux-ia32";
|
|
|
|
x86_64-linux = "linux-x64";
|
|
|
|
armv7l-linux = "linux-armv7l";
|
|
|
|
aarch64-linux = "linux-arm64";
|
|
|
|
x86_64-darwin = "darwin-x64";
|
2021-05-19 11:48:59 +01:00
|
|
|
aarch64-darwin = "darwin-arm64";
|
2020-02-05 18:27:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
get = as: platform: as.${platform.system} or
|
|
|
|
"Unsupported system: ${platform.system}";
|
|
|
|
|
|
|
|
common = platform: {
|
2022-01-31 09:54:08 +00:00
|
|
|
inherit pname version meta;
|
2020-02-05 18:27:16 +00:00
|
|
|
src = fetcher version (get tags platform) (get hashes platform);
|
2020-11-28 15:57:31 +00:00
|
|
|
passthru.headers = headersFetcher version hashes.headers;
|
2020-02-05 18:27:16 +00:00
|
|
|
};
|
2019-08-09 17:45:58 +01:00
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
electronLibPath = with lib; makeLibraryPath (
|
2021-01-02 09:51:13 +00:00
|
|
|
[ libuuid at-spi2-atk at-spi2-core libappindicator-gtk3 ]
|
2020-11-17 15:03:53 +00:00
|
|
|
++ optionals (! versionOlder version "9.0.0") [ libdrm mesa ]
|
|
|
|
++ optionals (! versionOlder version "11.0.0") [ libxkbcommon ]
|
2021-03-04 20:42:16 +00:00
|
|
|
++ optionals (! versionOlder version "12.0.0") [ libxshmfence ]
|
2020-11-17 15:03:53 +00:00
|
|
|
);
|
2020-05-21 18:41:22 +01:00
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
linux = {
|
2020-04-11 11:25:51 +01:00
|
|
|
buildInputs = [ glib gtk3 ];
|
2019-08-09 17:45:58 +01:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
unzip
|
|
|
|
makeWrapper
|
|
|
|
wrapGAppsHook
|
|
|
|
];
|
|
|
|
|
|
|
|
dontWrapGApps = true; # electron is in lib, we need to wrap it manually
|
|
|
|
|
2020-04-11 11:25:51 +01:00
|
|
|
dontUnpack = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2019-08-09 17:45:58 +01:00
|
|
|
mkdir -p $out/lib/electron $out/bin
|
|
|
|
unzip -d $out/lib/electron $src
|
|
|
|
ln -s $out/lib/electron/electron $out/bin
|
2020-04-11 11:25:51 +01:00
|
|
|
'';
|
2019-08-09 17:45:58 +01:00
|
|
|
|
2020-04-11 11:25:51 +01:00
|
|
|
postFixup = ''
|
2019-08-09 17:45:58 +01:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
2020-05-21 18:41:22 +01:00
|
|
|
--set-rpath "${atomEnv.libPath}:${electronLibPath}:$out/lib/electron" \
|
2019-08-09 17:45:58 +01:00
|
|
|
$out/lib/electron/electron
|
|
|
|
|
|
|
|
wrapProgram $out/lib/electron/electron \
|
2021-01-23 12:26:19 +00:00
|
|
|
--prefix LD_PRELOAD : ${lib.makeLibraryPath [ libXScrnSaver ]}/libXss.so.1 \
|
2019-08-09 17:45:58 +01:00
|
|
|
"''${gappsWrapperArgs[@]}"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
darwin = {
|
2021-02-20 21:01:53 +00:00
|
|
|
nativeBuildInputs = [ unzip ];
|
2019-08-09 17:45:58 +01:00
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/Applications
|
|
|
|
unzip $src
|
|
|
|
mv Electron.app $out/Applications
|
|
|
|
mkdir -p $out/bin
|
2020-02-17 15:50:21 +00:00
|
|
|
ln -s $out/Applications/Electron.app/Contents/MacOS/Electron $out/bin/electron
|
2019-08-09 17:45:58 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2020-02-05 18:27:16 +00:00
|
|
|
stdenv.mkDerivation (
|
|
|
|
(common stdenv.hostPlatform) //
|
|
|
|
(if stdenv.isDarwin then darwin else linux)
|
|
|
|
)
|