From 7db6808335f5307f94f0f49d73669e565f526f46 Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Thu, 8 Dec 2022 00:05:50 +0100 Subject: [PATCH] logseq: Fix publishing graph Related to https://github.com/logseq/logseq/issues/6880 Logseq publishes graphs by copying application assets into a folder and then the graph files (+/- some operations). In a normal linux distribution the application asset directories are rw but only by root. On nix, the directories are read-only, which leads to the copied directories also being ro and logseq failing to copy the graph files into the target. A fix from the logseq team isn't forthcoming (yet?), so we circumvent the entire ro issue by using run-appimage, which extracts the appimage into a user-writeable directory. --- pkgs/applications/misc/logseq/default.nix | 25 ++++++++--------------- pkgs/top-level/all-packages.nix | 4 +--- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/pkgs/applications/misc/logseq/default.nix b/pkgs/applications/misc/logseq/default.nix index ea855f3d30be..9a9db9d70f94 100644 --- a/pkgs/applications/misc/logseq/default.nix +++ b/pkgs/applications/misc/logseq/default.nix @@ -2,8 +2,8 @@ , stdenv , fetchurl , appimageTools +, appimage-run , makeWrapper -, electron , git }: @@ -30,30 +30,23 @@ stdenv.mkDerivation rec { installPhase = '' runHook preInstall - mkdir -p $out/bin $out/share/${pname} $out/share/applications - cp -a ${appimageContents}/{locales,resources} $out/share/${pname} + mkdir -p $out/bin $out/share/${pname} $out/share/applications $out/share/${pname}/resources/app/icons + cp -a ${appimageContents}/resources/app/icons/logseq.png $out/share/${pname}/resources/app/icons/logseq.png cp -a ${appimageContents}/Logseq.desktop $out/share/applications/${pname}.desktop - # remove the `git` in `dugite` because we want the `git` in `nixpkgs` - chmod +w -R $out/share/${pname}/resources/app/node_modules/dugite/git - chmod +w $out/share/${pname}/resources/app/node_modules/dugite - rm -rf $out/share/${pname}/resources/app/node_modules/dugite/git - chmod -w $out/share/${pname}/resources/app/node_modules/dugite + # set the env "LOCAL_GIT_DIRECTORY" for dugite so that we can use the git in nixpkgs + makeWrapper ${appimage-run}/bin/appimage-run $out/bin/logseq \ + --set "LOCAL_GIT_DIRECTORY" ${git} \ + --add-flags ${src} + # Make the desktop entry run the app using appimage-run substituteInPlace $out/share/applications/${pname}.desktop \ - --replace Exec=Logseq Exec=${pname} \ + --replace Exec=Logseq "Exec=$out/bin/logseq" \ --replace Icon=Logseq Icon=$out/share/${pname}/resources/app/icons/logseq.png runHook postInstall ''; - postFixup = '' - # set the env "LOCAL_GIT_DIRECTORY" for dugite so that we can use the git in nixpkgs - makeWrapper ${electron}/bin/electron $out/bin/${pname} \ - --set "LOCAL_GIT_DIRECTORY" ${git} \ - --add-flags $out/share/${pname}/resources/app - ''; - passthru.updateScript = ./update.sh; meta = with lib; { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bf00bf10fc8b..cf5ea79356d5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2487,9 +2487,7 @@ with pkgs; lilo = callPackage ../tools/misc/lilo { }; - logseq = callPackage ../applications/misc/logseq { - electron = electron_20; - }; + logseq = callPackage ../applications/misc/logseq { }; natls = callPackage ../tools/misc/natls { };