···11{
22+ buildNpmPackage,
33+ fetchFromGitHub,
44+ fetchpatch2,
25 lib,
33- node_webkit,
44- pkgs,
55- copyDesktopItems,
66 makeDesktopItem,
77- stdenv,
88- writeShellScript,
99- wrapGAppsHook3,
77+ nix-update-script,
88+ nwjs,
109}:
11101212-let
1313- # parse the version from package.json
1414- version =
1515- let
1616- packageJson = lib.importJSON ./package.json;
1717- splits = builtins.split "^.*#v(.*)$" (builtins.getAttr "onlykey" (builtins.head packageJson));
1818- matches = builtins.elemAt splits 1;
1919- elem = builtins.head matches;
2020- in
2121- elem;
1111+buildNpmPackage (finalAttrs: {
1212+ pname = "onlykey";
1313+ version = "5.5.0";
22142323- # this must be updated anytime this package is updated.
2424- onlykeyPkg = "onlykey-git+https://github.com/trustcrypto/OnlyKey-App.git#v${version}";
1515+ src = fetchFromGitHub {
1616+ owner = "trustcrypto";
1717+ repo = "OnlyKey-App";
1818+ tag = "v${finalAttrs.version}";
1919+ hash = "sha256-8MSdr+ghCBPeGp63Yi1T+gyEwXOEUW3vqi9CrCmozrw=";
2020+ };
25212626- # define a shortcut to get to onlykey.
2727- onlykey = self."${onlykeyPkg}";
2222+ patches = [
2323+ # Provides package-lock.json
2424+ (fetchpatch2 {
2525+ url = "https://github.com/trustcrypto/OnlyKey-App/commit/b8918cec80f5feda50c24a0aec3d6fb914ea8481.patch";
2626+ hash = "sha256-ULMZI7fo5SJGrfCRqZzZVoGOTDQ8q/NG/uXMjNkQ+qk=";
2727+ })
2828+ ];
28292929- super = import ./onlykey.nix {
3030- inherit pkgs;
3131- inherit (stdenv.hostPlatform) system;
3030+ desktopItem = makeDesktopItem {
3131+ name = "onlykey";
3232+ exec = "onlykey";
3333+ icon = "onlykey";
3434+ desktopName = "OnlyKey";
3535+ comment = finalAttrs.meta.description;
3636+ categories = [
3737+ "Utility"
3838+ ];
3939+ terminal = false;
3240 };
33413434- self = super // {
3535- "${onlykeyPkg}" = super."${onlykeyPkg}".override (attrs: {
3636- # when installing packages, nw tries to download nwjs in its postInstall
3737- # script. There are currently no other postInstall scripts, so this
3838- # should not break other things.
3939- npmFlags = attrs.npmFlags or "" + " --ignore-scripts";
4242+ npmDepsHash = "sha256-DpjB95KEHfAc4GBxY40uUjlN7ifBMUncufVTmTXqDo8=";
40434141- # this package requires to be built in order to become runnable.
4242- postInstall = ''
4343- cd $out/lib/node_modules/${attrs.packageName}
4444- npm run build
4545- '';
4646- });
4747- };
4444+ # when installing packages, nw tries to download nwjs in its postInstall
4545+ # script. There are currently no other postInstall scripts, so this
4646+ # should not break other things.
4747+ npmFlags = [ "--ignore-scripts" ];
48484949- script = writeShellScript "${onlykey.packageName}-starter-${onlykey.version}" ''
5050- ${node_webkit}/bin/nw ${onlykey}/lib/node_modules/${onlykey.packageName}/build
5151- '';
5252-in
5353-stdenv.mkDerivation {
5454- pname = "${onlykey.packageName}";
5555- inherit (onlykey) version;
5656- dontUnpack = true;
5757- nativeBuildInputs = [
5858- wrapGAppsHook3
5959- copyDesktopItems
6060- ];
6161- desktopItems = [
6262- (makeDesktopItem {
6363- name = onlykey.packageName;
6464- exec = script;
6565- icon = "${onlykey}/lib/node_modules/${onlykey.packageName}/resources/onlykey_logo_128.png";
6666- desktopName = onlykey.packageName;
6767- genericName = onlykey.packageName;
6868- })
6969- ];
7049 installPhase = ''
7150 runHook preInstall
72517373- mkdir -p $out/bin
7474- ln -s ${script} $out/bin/onlykey
5252+ mkdir -p "$out/share"
5353+ cp -r build "$out/share/onlykey"
5454+5555+ ln -s "${finalAttrs.desktopItem}/share/applications" "$out/share/applications"
5656+5757+ mkdir -p "$out/share/icons/hicolor/128x128/apps"
5858+ install -D resources/onlykey_logo_128.png "$out/share/icons/hicolor/128x128/apps/onlykey.png"
5959+6060+ makeWrapper ${nwjs}/bin/nw "$out/bin/onlykey" \
6161+ --add-flags "$out/share/onlykey"
75627663 runHook postInstall
7764 '';
7878-}
6565+6666+ passthru = {
6767+ updateScript = nix-update-script { };
6868+ };
6969+7070+ meta = {
7171+ description = "Setup and configure OnlyKey";
7272+ homepage = "https://github.com/trustcrypto/OnlyKey-App";
7373+ changelog = "https://github.com/trustcrypto/OnlyKey-App/releases/tag/v${finalAttrs.version}";
7474+ license = lib.licenses.asl20;
7575+ mainProgram = "onlykey";
7676+ };
7777+})
-5
pkgs/tools/security/onlykey/generate.sh
···11-#!/usr/bin/env nix-shell
22-#! nix-shell -i bash -p nodePackages.node2nix
33-44-# XXX: --development is given here because we need access to gulp in order to build OnlyKey.
55-exec node2nix --nodejs-18 --development -i package.json -c onlykey.nix -e ../../../development/node-packages/node-env.nix --no-copy-node-env