onlykey: npm install ignore scripts instead of hacking nw urlbase

(cherry picked from commit 5a1a8df251242a1730bf298d715883742ae44100)
This commit is contained in:
Wael M. Nasreddine 2021-08-19 11:20:57 -07:00 committed by github-actions[bot]
parent 8582286fa0
commit e9bc98c9cb

View File

@ -20,41 +20,12 @@ let
inherit (stdenv.hostPlatform) system; inherit (stdenv.hostPlatform) system;
}); });
# extract the nw dependency out of the computed
nwDependency = builtins.head (builtins.filter (d: d.packageName == "nw") onlykey.dependencies);
# In order to satisfy nw's installation of nwjs, create a directory that
# includes the tarball or zipfile and place it at a location the installation
# script will look for it.
#
# Reference:
# https://github.com/nwjs/npm-installer/blob/4e65f25c5c1f119ab2c79aefea1020db7be38bc7/scripts/install.js#L37-L52
#
nwjsBase =
let
name =
if stdenv.isLinux then "nwjs-v${nwDependency.version}-linux-x64"
else if stdenv.isDarwin then "nwjs-v${nwDependency.version}-osx-x64"
else throw "platform not supported";
command =
if stdenv.isLinux then "${pkgs.gnutar}/bin/tar --dereference -czf $out/${nwDependency.version}/${name}.tar.gz ${name}"
else if stdenv.isDarwin then ""
else throw "platform not supported";
in
runCommand "nwjs-base" { } ''
mkdir -p $out/${nwDependency.version}
ln -s ${pkgs.nwjs}/share/nwjs ${name}
${command}
'';
self = super // { self = super // {
"${onlykeyPkg}" = super."${onlykeyPkg}".override (attrs: { "${onlykeyPkg}" = super."${onlykeyPkg}".override (attrs: {
# See explanation above regarding the nwjsBase. # when installing packages, nw tries to download nwjs in its postInstall
NWJS_URLBASE = "file://${nwjsBase}/"; # script. There are currently no other postInstall scripts, so this
# should not break other things.
# this is needed to allow us to parse the version of the nw dependency npmFlags = attrs.npmFlags or "" + " --ignore-scripts";
passthru = { inherit (attrs) dependencies; };
# this package requires to be built in order to become runnable. # this package requires to be built in order to become runnable.
postInstall = '' postInstall = ''