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