standardnotes: use nixpkgs electron

- Use electron from nixpkgs instead of upstream's binaries
- Pull web assets from upstream deb package
- Continue using architecture specific packages, since the web assets
still contain some native binaries
- Reduce closure size from 2.8GB to 775MB on x86_64-linux

squalus 4a067074 f9f131ce

+40 -33
+31 -24
pkgs/applications/editors/standardnotes/default.nix
··· 1 - { callPackage, lib, stdenv, appimageTools, autoPatchelfHook, desktop-file-utils 2 - , fetchurl, libsecret }: 3 4 let 5 srcjson = builtins.fromJSON (builtins.readFile ./src.json); 6 - version = srcjson.version; 7 - pname = "standardnotes"; 8 - name = "${pname}-${version}"; 9 throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}"; 10 11 - src = fetchurl (srcjson.appimage.${stdenv.hostPlatform.system} or throwSystem); 12 13 - appimageContents = appimageTools.extract { 14 - inherit name src; 15 - }; 16 17 - nativeBuildInputs = [ autoPatchelfHook desktop-file-utils ]; 18 19 - in appimageTools.wrapType2 rec { 20 - inherit name src; 21 22 - extraPkgs = pkgs: with pkgs; [ 23 - libsecret 24 - ]; 25 26 - extraInstallCommands = '' 27 - # directory in /nix/store so readonly 28 - cd $out 29 - chmod -R +w $out 30 - mv $out/bin/${name} $out/bin/${pname} 31 32 - # fixup and install desktop file 33 ${desktop-file-utils}/bin/desktop-file-install --dir $out/share/applications \ 34 - --set-key Exec --set-value ${pname} ${appimageContents}/standard-notes.desktop 35 - ln -s ${appimageContents}/usr/share/icons share 36 ''; 37 38 passthru.updateScript = callPackage ./update.nix {}; ··· 47 license = licenses.agpl3; 48 maintainers = with maintainers; [ mgregoire chuangzhu squalus ]; 49 sourceProvenance = [ sourceTypes.binaryNativeCode ]; 50 - platforms = builtins.attrNames srcjson.appimage; 51 }; 52 }
··· 1 + { lib, stdenv, fetchurl, dpkg, makeWrapper, electron, libsecret 2 + , desktop-file-utils , callPackage }: 3 4 let 5 + 6 srcjson = builtins.fromJSON (builtins.readFile ./src.json); 7 + 8 throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}"; 9 10 + in 11 12 + stdenv.mkDerivation rec { 13 14 + pname = "standardnotes"; 15 + 16 + src = fetchurl (srcjson.deb.${stdenv.hostPlatform.system} or throwSystem); 17 + 18 + inherit (srcjson) version; 19 + 20 + dontConfigure = true; 21 + 22 + dontBuild = true; 23 + 24 + nativeBuildInputs = [ makeWrapper dpkg desktop-file-utils ]; 25 + 26 + unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner"; 27 28 + installPhase = '' 29 + runHook preInstall 30 31 + mkdir -p $out/bin $out/share/standardnotes 32 + cp -R usr/share/{applications,icons} $out/share 33 + cp -R opt/Standard\ Notes/resources/app.asar $out/share/standardnotes/ 34 35 + makeWrapper ${electron}/bin/electron $out/bin/standardnotes \ 36 + --add-flags $out/share/standardnotes/app.asar \ 37 + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libsecret stdenv.cc.cc.lib ]} 38 39 ${desktop-file-utils}/bin/desktop-file-install --dir $out/share/applications \ 40 + --set-key Exec --set-value standardnotes usr/share/applications/standard-notes.desktop 41 + 42 + runHook postInstall 43 ''; 44 45 passthru.updateScript = callPackage ./update.nix {}; ··· 54 license = licenses.agpl3; 55 maintainers = with maintainers; [ mgregoire chuangzhu squalus ]; 56 sourceProvenance = [ sourceTypes.binaryNativeCode ]; 57 + platforms = builtins.attrNames srcjson.deb; 58 }; 59 }
+5 -5
pkgs/applications/editors/standardnotes/src.json
··· 1 { 2 "version": "3.162.8", 3 - "appimage": { 4 "x86_64-linux": { 5 - "url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-x86_64.AppImage", 6 - "hash": "sha512-+JoY/x99RDLLjERaFhye0Bsg5FWFAgTPr6tqjXOYjHYuztYhmOZnieIGF8hS0iZsSPoQG9mm2mUVOTEHhXvm8A==" 7 }, 8 "aarch64-linux": { 9 - "url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-arm64.AppImage", 10 - "hash": "sha512-7/oHUJQBlTr4mL8ETESW6PC9rWewAUGHLtdCwNmnhh9zTBWxc0jO8fLikDDql5vrlCCGhZqmnmmlvMGNFFLBdw==" 11 } 12 } 13 }
··· 1 { 2 "version": "3.162.8", 3 + "deb": { 4 "x86_64-linux": { 5 + "url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-amd64.deb", 6 + "hash": "sha512-XxSz1ZXCVzNBqX5BQ4nytFla1igEttV/pQ40r3HW6BQfy6yprQqmQ94OMJSx7kpfeQpxnwBMOUsA58QM3W7y1w==" 7 }, 8 "aarch64-linux": { 9 + "url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-arm64.deb", 10 + "hash": "sha512-Y1+89UaPfB+UKiVg3JWo3zwH1rFnjdKuU1CBwIjMblzf1775gEMXicU0n+6FpWTphcVmEeah9VISoq0oBHNHtg==" 11 } 12 } 13 }
+4 -4
pkgs/applications/editors/standardnotes/update.nix
··· 31 fi 32 33 function getDownloadUrl() { 34 - jq -r ".assets[] | select(.name==\"standard-notes-$newVersion-$1.AppImage\") | .browser_download_url" < "$jsonPath" 35 } 36 37 function setJsonKey() { ··· 44 url=$(getDownloadUrl "$upstreamPlatform") 45 hash=$(nix-prefetch-url "$url" --type sha512) 46 sriHash=$(nix hash to-sri --type sha512 $hash) 47 - setJsonKey .appimage[\""$nixPlatform"\"].url "$url" 48 - setJsonKey .appimage[\""$nixPlatform"\"].hash "$sriHash" 49 } 50 51 - updatePlatform x86_64-linux linux-x86_64 52 updatePlatform aarch64-linux linux-arm64 53 setJsonKey .version "$newVersion" 54 ''
··· 31 fi 32 33 function getDownloadUrl() { 34 + jq -r ".assets[] | select(.name==\"standard-notes-$newVersion-$1.deb\") | .browser_download_url" < "$jsonPath" 35 } 36 37 function setJsonKey() { ··· 44 url=$(getDownloadUrl "$upstreamPlatform") 45 hash=$(nix-prefetch-url "$url" --type sha512) 46 sriHash=$(nix hash to-sri --type sha512 $hash) 47 + setJsonKey .deb[\""$nixPlatform"\"].url "$url" 48 + setJsonKey .deb[\""$nixPlatform"\"].hash "$sriHash" 49 } 50 51 + updatePlatform x86_64-linux linux-amd64 52 updatePlatform aarch64-linux linux-arm64 53 setJsonKey .version "$newVersion" 54 ''