onlykey: migrate to buildNpmPackage (#440092)
This commit is contained in:
@@ -1,78 +1,77 @@
|
||||
{
|
||||
buildNpmPackage,
|
||||
fetchFromGitHub,
|
||||
fetchpatch2,
|
||||
lib,
|
||||
node_webkit,
|
||||
pkgs,
|
||||
copyDesktopItems,
|
||||
makeDesktopItem,
|
||||
stdenv,
|
||||
writeShellScript,
|
||||
wrapGAppsHook3,
|
||||
nix-update-script,
|
||||
nwjs,
|
||||
}:
|
||||
|
||||
let
|
||||
# parse the version from package.json
|
||||
version =
|
||||
let
|
||||
packageJson = lib.importJSON ./package.json;
|
||||
splits = builtins.split "^.*#v(.*)$" (builtins.getAttr "onlykey" (builtins.head packageJson));
|
||||
matches = builtins.elemAt splits 1;
|
||||
elem = builtins.head matches;
|
||||
in
|
||||
elem;
|
||||
buildNpmPackage (finalAttrs: {
|
||||
pname = "onlykey";
|
||||
version = "5.5.0";
|
||||
|
||||
# this must be updated anytime this package is updated.
|
||||
onlykeyPkg = "onlykey-git+https://github.com/trustcrypto/OnlyKey-App.git#v${version}";
|
||||
|
||||
# define a shortcut to get to onlykey.
|
||||
onlykey = self."${onlykeyPkg}";
|
||||
|
||||
super = import ./onlykey.nix {
|
||||
inherit pkgs;
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
src = fetchFromGitHub {
|
||||
owner = "trustcrypto";
|
||||
repo = "OnlyKey-App";
|
||||
tag = "v${finalAttrs.version}";
|
||||
hash = "sha256-8MSdr+ghCBPeGp63Yi1T+gyEwXOEUW3vqi9CrCmozrw=";
|
||||
};
|
||||
|
||||
self = super // {
|
||||
"${onlykeyPkg}" = super."${onlykeyPkg}".override (attrs: {
|
||||
# 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";
|
||||
|
||||
# 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
|
||||
'';
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "${onlykey.packageName}";
|
||||
inherit (onlykey) version;
|
||||
dontUnpack = true;
|
||||
nativeBuildInputs = [
|
||||
wrapGAppsHook3
|
||||
copyDesktopItems
|
||||
];
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = onlykey.packageName;
|
||||
exec = script;
|
||||
icon = "${onlykey}/lib/node_modules/${onlykey.packageName}/resources/onlykey_logo_128.png";
|
||||
desktopName = onlykey.packageName;
|
||||
genericName = onlykey.packageName;
|
||||
patches = [
|
||||
# Provides package-lock.json
|
||||
(fetchpatch2 {
|
||||
url = "https://github.com/trustcrypto/OnlyKey-App/commit/b8918cec80f5feda50c24a0aec3d6fb914ea8481.patch";
|
||||
hash = "sha256-ULMZI7fo5SJGrfCRqZzZVoGOTDQ8q/NG/uXMjNkQ+qk=";
|
||||
})
|
||||
];
|
||||
|
||||
desktopItem = makeDesktopItem {
|
||||
name = "onlykey";
|
||||
exec = "onlykey";
|
||||
icon = "onlykey";
|
||||
desktopName = "OnlyKey";
|
||||
comment = finalAttrs.meta.description;
|
||||
categories = [
|
||||
"Utility"
|
||||
];
|
||||
terminal = false;
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-DpjB95KEHfAc4GBxY40uUjlN7ifBMUncufVTmTXqDo8=";
|
||||
|
||||
# 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 = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
ln -s ${script} $out/bin/onlykey
|
||||
mkdir -p "$out/share"
|
||||
cp -r build "$out/share/onlykey"
|
||||
|
||||
ln -s "${finalAttrs.desktopItem}/share/applications" "$out/share/applications"
|
||||
|
||||
mkdir -p "$out/share/icons/hicolor/128x128/apps"
|
||||
install -D resources/onlykey_logo_128.png "$out/share/icons/hicolor/128x128/apps/onlykey.png"
|
||||
|
||||
makeWrapper ${nwjs}/bin/nw "$out/bin/onlykey" \
|
||||
--add-flags "$out/share/onlykey"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
||||
|
||||
passthru = {
|
||||
updateScript = nix-update-script { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Setup and configure OnlyKey";
|
||||
homepage = "https://github.com/trustcrypto/OnlyKey-App";
|
||||
changelog = "https://github.com/trustcrypto/OnlyKey-App/releases/tag/v${finalAttrs.version}";
|
||||
license = lib.licenses.asl20;
|
||||
mainProgram = "onlykey";
|
||||
};
|
||||
})
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p nodePackages.node2nix
|
||||
|
||||
# XXX: --development is given here because we need access to gulp in order to build OnlyKey.
|
||||
exec node2nix --nodejs-18 --development -i package.json -c onlykey.nix -e ../../../development/node-packages/node-env.nix --no-copy-node-env
|
||||
-6952
File diff suppressed because it is too large
Load Diff
@@ -1,33 +0,0 @@
|
||||
# This file has been generated by node2nix 1.11.1. Do not edit!
|
||||
|
||||
{
|
||||
pkgs ? import <nixpkgs> {
|
||||
inherit system;
|
||||
},
|
||||
system ? builtins.currentSystem,
|
||||
nodejs ? pkgs.nodejs_20,
|
||||
}:
|
||||
|
||||
let
|
||||
nodeEnv = import ../../../development/node-packages/node-env.nix {
|
||||
inherit (pkgs)
|
||||
stdenv
|
||||
lib
|
||||
runCommand
|
||||
writeTextFile
|
||||
writeShellScript
|
||||
;
|
||||
inherit pkgs nodejs;
|
||||
libtool = if pkgs.stdenv.hostPlatform.isDarwin then pkgs.cctools or pkgs.darwin.cctools else null;
|
||||
};
|
||||
in
|
||||
import ./node-packages.nix {
|
||||
inherit (pkgs)
|
||||
fetchurl
|
||||
nix-gitignore
|
||||
stdenv
|
||||
lib
|
||||
fetchgit
|
||||
;
|
||||
inherit nodeEnv;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
[
|
||||
{"onlykey": "git+https://github.com/trustcrypto/OnlyKey-App.git#v5.5.0"}
|
||||
]
|
||||
@@ -3727,7 +3727,7 @@ with pkgs;
|
||||
|
||||
ome_zarr = with python3Packages; toPythonApplication ome-zarr;
|
||||
|
||||
onlykey = callPackage ../tools/security/onlykey { node_webkit = nwjs; };
|
||||
onlykey = callPackage ../tools/security/onlykey { };
|
||||
|
||||
openapi-generator-cli = callPackage ../tools/networking/openapi-generator-cli {
|
||||
jre = pkgs.jre_headless;
|
||||
|
||||
Reference in New Issue
Block a user