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
This commit is contained in:
parent
f9f131ceb2
commit
4a0670748e
|
@ -1,38 +1,45 @@
|
|||
{ callPackage, lib, stdenv, appimageTools, autoPatchelfHook, desktop-file-utils
|
||||
, fetchurl, libsecret }:
|
||||
{ lib, stdenv, fetchurl, dpkg, makeWrapper, electron, libsecret
|
||||
, desktop-file-utils , callPackage }:
|
||||
|
||||
let
|
||||
|
||||
srcjson = builtins.fromJSON (builtins.readFile ./src.json);
|
||||
version = srcjson.version;
|
||||
pname = "standardnotes";
|
||||
name = "${pname}-${version}";
|
||||
|
||||
throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
|
||||
|
||||
src = fetchurl (srcjson.appimage.${stdenv.hostPlatform.system} or throwSystem);
|
||||
in
|
||||
|
||||
appimageContents = appimageTools.extract {
|
||||
inherit name src;
|
||||
};
|
||||
stdenv.mkDerivation rec {
|
||||
|
||||
nativeBuildInputs = [ autoPatchelfHook desktop-file-utils ];
|
||||
pname = "standardnotes";
|
||||
|
||||
in appimageTools.wrapType2 rec {
|
||||
inherit name src;
|
||||
src = fetchurl (srcjson.deb.${stdenv.hostPlatform.system} or throwSystem);
|
||||
|
||||
extraPkgs = pkgs: with pkgs; [
|
||||
libsecret
|
||||
];
|
||||
inherit (srcjson) version;
|
||||
|
||||
extraInstallCommands = ''
|
||||
# directory in /nix/store so readonly
|
||||
cd $out
|
||||
chmod -R +w $out
|
||||
mv $out/bin/${name} $out/bin/${pname}
|
||||
dontConfigure = true;
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper dpkg desktop-file-utils ];
|
||||
|
||||
unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin $out/share/standardnotes
|
||||
cp -R usr/share/{applications,icons} $out/share
|
||||
cp -R opt/Standard\ Notes/resources/app.asar $out/share/standardnotes/
|
||||
|
||||
makeWrapper ${electron}/bin/electron $out/bin/standardnotes \
|
||||
--add-flags $out/share/standardnotes/app.asar \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libsecret stdenv.cc.cc.lib ]}
|
||||
|
||||
# fixup and install desktop file
|
||||
${desktop-file-utils}/bin/desktop-file-install --dir $out/share/applications \
|
||||
--set-key Exec --set-value ${pname} ${appimageContents}/standard-notes.desktop
|
||||
ln -s ${appimageContents}/usr/share/icons share
|
||||
--set-key Exec --set-value standardnotes usr/share/applications/standard-notes.desktop
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.updateScript = callPackage ./update.nix {};
|
||||
|
@ -47,6 +54,6 @@ in appimageTools.wrapType2 rec {
|
|||
license = licenses.agpl3;
|
||||
maintainers = with maintainers; [ mgregoire chuangzhu squalus ];
|
||||
sourceProvenance = [ sourceTypes.binaryNativeCode ];
|
||||
platforms = builtins.attrNames srcjson.appimage;
|
||||
platforms = builtins.attrNames srcjson.deb;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"version": "3.162.8",
|
||||
"appimage": {
|
||||
"deb": {
|
||||
"x86_64-linux": {
|
||||
"url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-x86_64.AppImage",
|
||||
"hash": "sha512-+JoY/x99RDLLjERaFhye0Bsg5FWFAgTPr6tqjXOYjHYuztYhmOZnieIGF8hS0iZsSPoQG9mm2mUVOTEHhXvm8A=="
|
||||
"url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-amd64.deb",
|
||||
"hash": "sha512-XxSz1ZXCVzNBqX5BQ4nytFla1igEttV/pQ40r3HW6BQfy6yprQqmQ94OMJSx7kpfeQpxnwBMOUsA58QM3W7y1w=="
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-arm64.AppImage",
|
||||
"hash": "sha512-7/oHUJQBlTr4mL8ETESW6PC9rWewAUGHLtdCwNmnhh9zTBWxc0jO8fLikDDql5vrlCCGhZqmnmmlvMGNFFLBdw=="
|
||||
"url": "https://github.com/standardnotes/app/releases/download/%40standardnotes/desktop%403.162.8/standard-notes-3.162.8-linux-arm64.deb",
|
||||
"hash": "sha512-Y1+89UaPfB+UKiVg3JWo3zwH1rFnjdKuU1CBwIjMblzf1775gEMXicU0n+6FpWTphcVmEeah9VISoq0oBHNHtg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ writeScript "update-standardnotes" ''
|
|||
fi
|
||||
|
||||
function getDownloadUrl() {
|
||||
jq -r ".assets[] | select(.name==\"standard-notes-$newVersion-$1.AppImage\") | .browser_download_url" < "$jsonPath"
|
||||
jq -r ".assets[] | select(.name==\"standard-notes-$newVersion-$1.deb\") | .browser_download_url" < "$jsonPath"
|
||||
}
|
||||
|
||||
function setJsonKey() {
|
||||
|
@ -44,11 +44,11 @@ writeScript "update-standardnotes" ''
|
|||
url=$(getDownloadUrl "$upstreamPlatform")
|
||||
hash=$(nix-prefetch-url "$url" --type sha512)
|
||||
sriHash=$(nix hash to-sri --type sha512 $hash)
|
||||
setJsonKey .appimage[\""$nixPlatform"\"].url "$url"
|
||||
setJsonKey .appimage[\""$nixPlatform"\"].hash "$sriHash"
|
||||
setJsonKey .deb[\""$nixPlatform"\"].url "$url"
|
||||
setJsonKey .deb[\""$nixPlatform"\"].hash "$sriHash"
|
||||
}
|
||||
|
||||
updatePlatform x86_64-linux linux-x86_64
|
||||
updatePlatform x86_64-linux linux-amd64
|
||||
updatePlatform aarch64-linux linux-arm64
|
||||
setJsonKey .version "$newVersion"
|
||||
''
|
||||
|
|
Loading…
Reference in a new issue