Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 78 lines 2.1 kB view raw
1{ 2 lib, 3 node_webkit, 4 pkgs, 5 copyDesktopItems, 6 makeDesktopItem, 7 stdenv, 8 writeShellScript, 9 wrapGAppsHook3, 10}: 11 12let 13 # parse the version from package.json 14 version = 15 let 16 packageJson = lib.importJSON ./package.json; 17 splits = builtins.split "^.*#v(.*)$" (builtins.getAttr "onlykey" (builtins.head packageJson)); 18 matches = builtins.elemAt splits 1; 19 elem = builtins.head matches; 20 in 21 elem; 22 23 # this must be updated anytime this package is updated. 24 onlykeyPkg = "onlykey-git+https://github.com/trustcrypto/OnlyKey-App.git#v${version}"; 25 26 # define a shortcut to get to onlykey. 27 onlykey = self."${onlykeyPkg}"; 28 29 super = import ./onlykey.nix { 30 inherit pkgs; 31 inherit (stdenv.hostPlatform) system; 32 }; 33 34 self = super // { 35 "${onlykeyPkg}" = super."${onlykeyPkg}".override (attrs: { 36 # when installing packages, nw tries to download nwjs in its postInstall 37 # script. There are currently no other postInstall scripts, so this 38 # should not break other things. 39 npmFlags = attrs.npmFlags or "" + " --ignore-scripts"; 40 41 # this package requires to be built in order to become runnable. 42 postInstall = '' 43 cd $out/lib/node_modules/${attrs.packageName} 44 npm run build 45 ''; 46 }); 47 }; 48 49 script = writeShellScript "${onlykey.packageName}-starter-${onlykey.version}" '' 50 ${node_webkit}/bin/nw ${onlykey}/lib/node_modules/${onlykey.packageName}/build 51 ''; 52in 53stdenv.mkDerivation { 54 pname = "${onlykey.packageName}"; 55 inherit (onlykey) version; 56 dontUnpack = true; 57 nativeBuildInputs = [ 58 wrapGAppsHook3 59 copyDesktopItems 60 ]; 61 desktopItems = [ 62 (makeDesktopItem { 63 name = onlykey.packageName; 64 exec = script; 65 icon = "${onlykey}/lib/node_modules/${onlykey.packageName}/resources/onlykey_logo_128.png"; 66 desktopName = onlykey.packageName; 67 genericName = onlykey.packageName; 68 }) 69 ]; 70 installPhase = '' 71 runHook preInstall 72 73 mkdir -p $out/bin 74 ln -s ${script} $out/bin/onlykey 75 76 runHook postInstall 77 ''; 78}