2021-08-19 08:09:46 +02:00
|
|
|
{ fetchgit
|
|
|
|
, lib
|
|
|
|
, makeDesktopItem
|
|
|
|
, node_webkit
|
|
|
|
, pkgs
|
|
|
|
, runCommand
|
|
|
|
, stdenv
|
|
|
|
, writeShellScript
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-08-19 23:36:20 +02:00
|
|
|
# parse the version from package.json
|
|
|
|
version =
|
|
|
|
let
|
2021-11-03 13:43:23 +01:00
|
|
|
packageJson = lib.importJSON ./package.json;
|
2021-08-19 23:36:20 +02:00
|
|
|
splits = builtins.split "^.*#v(.*)$" (builtins.getAttr "onlykey" (builtins.head packageJson));
|
|
|
|
matches = builtins.elemAt splits 1;
|
|
|
|
elem = builtins.head matches;
|
|
|
|
in
|
|
|
|
elem;
|
|
|
|
|
2021-08-19 08:09:46 +02:00
|
|
|
# this must be updated anytime this package is updated.
|
2021-08-19 23:36:20 +02:00
|
|
|
onlykeyPkg = "onlykey-git://github.com/trustcrypto/OnlyKey-App.git#v${version}";
|
2021-08-19 08:09:46 +02:00
|
|
|
|
|
|
|
# define a shortcut to get to onlykey.
|
|
|
|
onlykey = self."${onlykeyPkg}";
|
|
|
|
|
|
|
|
super = (import ./onlykey.nix {
|
|
|
|
inherit pkgs;
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
});
|
|
|
|
|
|
|
|
self = super // {
|
|
|
|
"${onlykeyPkg}" = super."${onlykeyPkg}".override (attrs: {
|
2021-08-19 20:20:57 +02:00
|
|
|
# when installing packages, nw tries to download nwjs in its postInstall
|
|
|
|
# script. There are currently no other postInstall scripts, so this
|
|
|
|
# should not break other things.
|
|
|
|
npmFlags = attrs.npmFlags or "" + " --ignore-scripts";
|
2021-08-19 08:09:46 +02:00
|
|
|
|
|
|
|
# this package requires to be built in order to become runnable.
|
|
|
|
postInstall = ''
|
|
|
|
cd $out/lib/node_modules/${attrs.packageName}
|
|
|
|
npm run build
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
script = writeShellScript "${onlykey.packageName}-starter-${onlykey.version}" ''
|
|
|
|
${node_webkit}/bin/nw ${onlykey}/lib/node_modules/${onlykey.packageName}/build
|
|
|
|
'';
|
|
|
|
|
|
|
|
desktop = makeDesktopItem {
|
|
|
|
name = onlykey.packageName;
|
|
|
|
exec = script;
|
|
|
|
icon = "${onlykey}/lib/node_modules/${onlykey.packageName}/resources/onlykey_logo_128.png";
|
|
|
|
desktopName = onlykey.packageName;
|
|
|
|
genericName = onlykey.packageName;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
runCommand "${onlykey.packageName}-${onlykey.version}" { } ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
ln -s ${script} $out/bin/onlykey
|
|
|
|
''
|