Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 98 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 dpkg, 6 makeWrapper, 7 electron, 8 libsecret, 9 asar, 10 python3, 11 glib, 12 desktop-file-utils, 13 callPackage, 14}: 15 16let 17 18 srcjson = builtins.fromJSON (builtins.readFile ./src.json); 19 20 throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}"; 21 22in 23 24stdenv.mkDerivation { 25 26 pname = "standardnotes"; 27 28 src = fetchurl (srcjson.deb.${stdenv.hostPlatform.system} or throwSystem); 29 30 inherit (srcjson) version; 31 32 dontConfigure = true; 33 34 dontBuild = true; 35 36 nativeBuildInputs = [ 37 makeWrapper 38 dpkg 39 desktop-file-utils 40 asar 41 ]; 42 43 installPhase = 44 let 45 libPath = lib.makeLibraryPath [ 46 libsecret 47 glib 48 (lib.getLib stdenv.cc.cc) 49 ]; 50 in 51 '' 52 runHook preInstall 53 54 mkdir -p $out/bin $out/share/standardnotes 55 cp -R usr/share/{applications,icons} $out/share 56 cp -R opt/Standard\ Notes/resources/app.asar $out/share/standardnotes/ 57 cp -R opt/Standard\ Notes/resources/app.asar.unpacked $out/share/standardnotes/ 58 rm $out/share/standardnotes/app.asar.unpacked/node_modules/cbor-extract/build/node_gyp_bins/python3 59 ln -s ${python3.interpreter} $out/share/standardnotes/app.asar.unpacked/node_modules/cbor-extract/build/node_gyp_bins/python3 60 ${lib.optionalString stdenv.hostPlatform.isAarch64 '' 61 rm $out/share/standardnotes/app.asar.unpacked/node_modules/microtime/build/node_gyp_bins/python3 62 ln -s ${python3.interpreter} $out/share/standardnotes/app.asar.unpacked/node_modules/microtime/build/node_gyp_bins/python3 63 ''} 64 asar e $out/share/standardnotes/app.asar asar-unpacked 65 find asar-unpacked -name '*.node' -exec patchelf \ 66 --add-rpath "${libPath}" \ 67 {} \; 68 asar p asar-unpacked $out/share/standardnotes/app.asar 69 70 makeWrapper ${electron}/bin/electron $out/bin/standardnotes \ 71 --add-flags $out/share/standardnotes/app.asar 72 73 ${desktop-file-utils}/bin/desktop-file-install --dir $out/share/applications \ 74 --set-key Exec --set-value standardnotes usr/share/applications/standard-notes.desktop 75 76 runHook postInstall 77 ''; 78 79 passthru.updateScript = callPackage ./update.nix { }; 80 81 meta = with lib; { 82 description = "Simple and private notes app"; 83 longDescription = '' 84 Standard Notes is a private notes app that features unmatched simplicity, 85 end-to-end encryption, powerful extensions, and open-source applications. 86 ''; 87 homepage = "https://standardnotes.org"; 88 license = licenses.agpl3Only; 89 maintainers = with maintainers; [ 90 mgregoire 91 chuangzhu 92 squalus 93 ]; 94 sourceProvenance = [ sourceTypes.binaryNativeCode ]; 95 platforms = builtins.attrNames srcjson.deb; 96 mainProgram = "standardnotes"; 97 }; 98}