2023-01-11 07:51:40 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, appimageTools
|
2024-09-19 14:19:46 +00:00
|
|
|
, unzip
|
2023-01-11 07:51:40 +00:00
|
|
|
, makeWrapper
|
2024-06-20 14:57:18 +00:00
|
|
|
# Notice: graphs will not sync without matching upstream's major electron version
|
|
|
|
# the specific electron version is set at top-level file to preserve override interface.
|
|
|
|
# whenever updating this package also sync electron version at top-level file.
|
|
|
|
, electron
|
2024-05-15 15:35:15 +00:00
|
|
|
, autoPatchelfHook
|
2023-01-11 07:51:40 +00:00
|
|
|
, git
|
2023-03-30 22:05:00 +00:00
|
|
|
, nix-update-script
|
2023-01-11 07:51:40 +00:00
|
|
|
}:
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: let
|
2024-09-19 14:19:46 +00:00
|
|
|
inherit (finalAttrs) pname version src;
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
selectSystem = attrs: attrs.${system} or (throw "Unsupported system: ${system}");
|
|
|
|
suffix = selectSystem {
|
|
|
|
x86_64-linux = "linux-x64-${version}.AppImage";
|
|
|
|
x86_64-darwin = "darwin-x64-${version}.zip";
|
|
|
|
aarch64-darwin = "darwin-arm64-${version}.zip";
|
|
|
|
};
|
|
|
|
hash = selectSystem {
|
|
|
|
x86_64-linux = "sha256-XROuY2RlKnGvK1VNvzauHuLJiveXVKrIYPppoz8fCmc=";
|
|
|
|
x86_64-darwin = "sha256-0i9ozqBSeV/y8v+YEmQkbY0V6JHOv6tKub4O5Fdx2fQ=";
|
|
|
|
aarch64-darwin = "sha256-Uvv96XWxpFj14wPH0DwPT+mlf3Z2dy1g/z8iBt5Te7Q=";
|
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
in {
|
2021-03-23 19:22:30 +00:00
|
|
|
pname = "logseq";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "0.10.9";
|
2021-03-23 19:22:30 +00:00
|
|
|
src = fetchurl {
|
2024-09-19 14:19:46 +00:00
|
|
|
inherit hash;
|
|
|
|
url = "https://github.com/logseq/logseq/releases/download/${version}/logseq-${suffix}";
|
|
|
|
name = lib.optionalString stdenv.isLinux "logseq-${version}.AppImage";
|
2021-03-23 19:22:30 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ]
|
|
|
|
++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ unzip ];
|
|
|
|
buildInputs = [ stdenv.cc.cc.lib ];
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
dontUnpack = stdenv.isLinux;
|
2021-03-23 19:22:30 +00:00
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2024-09-19 14:19:46 +00:00
|
|
|
'' + lib.optionalString stdenv.isLinux (
|
|
|
|
let
|
|
|
|
appimageContents = appimageTools.extract { inherit pname src version; };
|
|
|
|
in
|
|
|
|
''
|
|
|
|
mkdir -p $out/bin $out/share/logseq $out/share/applications
|
|
|
|
cp -a ${appimageContents}/{locales,resources} $out/share/logseq
|
|
|
|
cp -a ${appimageContents}/Logseq.desktop $out/share/applications/logseq.desktop
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2023-03-27 19:17:25 +00:00
|
|
|
# remove the `git` in `dugite` because we want the `git` in `nixpkgs`
|
2024-09-19 14:19:46 +00:00
|
|
|
chmod +w -R $out/share/logseq/resources/app/node_modules/dugite/git
|
|
|
|
chmod +w $out/share/logseq/resources/app/node_modules/dugite
|
|
|
|
rm -rf $out/share/logseq/resources/app/node_modules/dugite/git
|
|
|
|
chmod -w $out/share/logseq/resources/app/node_modules/dugite
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2023-03-30 22:05:00 +00:00
|
|
|
mkdir -p $out/share/pixmaps
|
2024-09-19 14:19:46 +00:00
|
|
|
ln -s $out/share/logseq/resources/app/icons/logseq.png $out/share/pixmaps/logseq.png
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
substituteInPlace $out/share/applications/logseq.desktop \
|
|
|
|
--replace Exec=Logseq Exec=logseq \
|
|
|
|
--replace Icon=Logseq Icon=logseq
|
|
|
|
'') + lib.optionalString stdenv.isDarwin ''
|
|
|
|
mkdir -p $out/{Applications/Logseq.app,bin}
|
|
|
|
cp -R . $out/Applications/Logseq.app
|
|
|
|
makeWrapper $out/Applications/Logseq.app/Contents/MacOS/Logseq $out/bin/logseq
|
|
|
|
'' + ''
|
2021-03-23 19:22:30 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
2023-03-27 19:17:25 +00:00
|
|
|
# set the env "LOCAL_GIT_DIRECTORY" for dugite so that we can use the git in nixpkgs
|
2024-09-19 14:19:46 +00:00
|
|
|
makeWrapper ${electron}/bin/electron $out/bin/logseq \
|
2023-03-27 19:17:25 +00:00
|
|
|
--set "LOCAL_GIT_DIRECTORY" ${git} \
|
2024-09-19 14:19:46 +00:00
|
|
|
--add-flags $out/share/logseq/resources/app \
|
2024-04-21 15:54:59 +00:00
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
|
2023-03-27 19:17:25 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-30 22:05:00 +00:00
|
|
|
passthru.updateScript = nix-update-script { };
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
meta = {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Local-first, non-linear, outliner notebook for organizing and sharing your personal knowledge base";
|
2021-03-23 19:22:30 +00:00
|
|
|
homepage = "https://github.com/logseq/logseq";
|
2023-01-11 07:51:40 +00:00
|
|
|
changelog = "https://github.com/logseq/logseq/releases/tag/${version}";
|
2024-01-13 08:15:51 +00:00
|
|
|
license = lib.licenses.agpl3Plus;
|
2024-02-07 01:22:34 +00:00
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2024-09-19 14:19:46 +00:00
|
|
|
maintainers = with lib.maintainers; [ cheeseecake ];
|
|
|
|
platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
|
2024-02-29 20:09:43 +00:00
|
|
|
mainProgram = "logseq";
|
2021-03-23 19:22:30 +00:00
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
})
|