7 # Notice: graphs will not sync without matching upstream's major electron version
8 # the specific electron version is set at top-level file to preserve override interface.
9 # whenever updating this package also sync electron version at top-level file.
16 stdenv.mkDerivation (finalAttrs: let
17 inherit (finalAttrs) pname version src;
18 inherit (stdenv.hostPlatform) system;
19 selectSystem = attrs: attrs.${system} or (throw "Unsupported system: ${system}");
20 suffix = selectSystem {
21 x86_64-linux = "linux-x64-${version}.AppImage";
22 x86_64-darwin = "darwin-x64-${version}.zip";
23 aarch64-darwin = "darwin-arm64-${version}.zip";
26 x86_64-linux = "sha256-XROuY2RlKnGvK1VNvzauHuLJiveXVKrIYPppoz8fCmc=";
27 x86_64-darwin = "sha256-0i9ozqBSeV/y8v+YEmQkbY0V6JHOv6tKub4O5Fdx2fQ=";
28 aarch64-darwin = "sha256-Uvv96XWxpFj14wPH0DwPT+mlf3Z2dy1g/z8iBt5Te7Q=";
35 url = "https://github.com/logseq/logseq/releases/download/${version}/logseq-${suffix}";
36 name = lib.optionalString stdenv.hostPlatform.isLinux "logseq-${version}.AppImage";
39 nativeBuildInputs = [ makeWrapper ]
40 ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]
41 ++ lib.optionals stdenv.hostPlatform.isDarwin [ unzip ];
42 buildInputs = [ stdenv.cc.cc.lib ];
44 dontUnpack = stdenv.hostPlatform.isLinux;
50 '' + lib.optionalString stdenv.hostPlatform.isLinux (
52 appimageContents = appimageTools.extract { inherit pname src version; };
55 mkdir -p $out/bin $out/share/logseq $out/share/applications
56 cp -a ${appimageContents}/{locales,resources} $out/share/logseq
57 cp -a ${appimageContents}/Logseq.desktop $out/share/applications/logseq.desktop
59 # remove the `git` in `dugite` because we want the `git` in `nixpkgs`
60 chmod +w -R $out/share/logseq/resources/app/node_modules/dugite/git
61 chmod +w $out/share/logseq/resources/app/node_modules/dugite
62 rm -rf $out/share/logseq/resources/app/node_modules/dugite/git
63 chmod -w $out/share/logseq/resources/app/node_modules/dugite
65 mkdir -p $out/share/pixmaps
66 ln -s $out/share/logseq/resources/app/icons/logseq.png $out/share/pixmaps/logseq.png
68 substituteInPlace $out/share/applications/logseq.desktop \
69 --replace Exec=Logseq Exec=logseq \
70 --replace Icon=Logseq Icon=logseq
71 '') + lib.optionalString stdenv.hostPlatform.isDarwin ''
72 mkdir -p $out/{Applications/Logseq.app,bin}
73 cp -R . $out/Applications/Logseq.app
74 makeWrapper $out/Applications/Logseq.app/Contents/MacOS/Logseq $out/bin/logseq
79 postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
80 # set the env "LOCAL_GIT_DIRECTORY" for dugite so that we can use the git in nixpkgs
81 makeWrapper ${electron}/bin/electron $out/bin/logseq \
82 --set "LOCAL_GIT_DIRECTORY" ${git} \
83 --add-flags $out/share/logseq/resources/app \
84 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
87 passthru.updateScript = nix-update-script { };
90 description = "Local-first, non-linear, outliner notebook for organizing and sharing your personal knowledge base";
91 homepage = "https://github.com/logseq/logseq";
92 changelog = "https://github.com/logseq/logseq/releases/tag/${version}";
93 license = lib.licenses.agpl3Plus;
94 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
95 maintainers = with lib.maintainers; [ cheeseecake ];
96 platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
97 mainProgram = "logseq";