Merge pull request #331824 from yzx9/logseq-drawin-support
logseq: add darwin support
This commit is contained in:
commit
5b14f25672
@ -2,6 +2,7 @@
|
|||||||
, stdenv
|
, stdenv
|
||||||
, fetchurl
|
, fetchurl
|
||||||
, appimageTools
|
, appimageTools
|
||||||
|
, unzip
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
# Notice: graphs will not sync without matching upstream's major electron version
|
# 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.
|
# the specific electron version is set at top-level file to preserve override interface.
|
||||||
@ -13,32 +14,44 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation (finalAttrs: let
|
stdenv.mkDerivation (finalAttrs: let
|
||||||
inherit (finalAttrs) pname version src appimageContents;
|
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=";
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
pname = "logseq";
|
pname = "logseq";
|
||||||
version = "0.10.9";
|
version = "0.10.9";
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://github.com/logseq/logseq/releases/download/${version}/logseq-linux-x64-${version}.AppImage";
|
inherit hash;
|
||||||
hash = "sha256-XROuY2RlKnGvK1VNvzauHuLJiveXVKrIYPppoz8fCmc=";
|
url = "https://github.com/logseq/logseq/releases/download/${version}/logseq-${suffix}";
|
||||||
name = "${pname}-${version}.AppImage";
|
name = lib.optionalString stdenv.isLinux "${pname}-${version}.AppImage";
|
||||||
};
|
};
|
||||||
|
|
||||||
appimageContents = appimageTools.extract {
|
nativeBuildInputs = [ makeWrapper ]
|
||||||
inherit pname src version;
|
++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]
|
||||||
};
|
++ lib.optionals stdenv.isDarwin [ unzip ];
|
||||||
|
buildInputs = [ stdenv.cc.cc.lib ];
|
||||||
|
|
||||||
dontUnpack = true;
|
dontUnpack = stdenv.isLinux;
|
||||||
dontConfigure = true;
|
dontConfigure = true;
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper autoPatchelfHook ];
|
|
||||||
buildInputs = [ stdenv.cc.cc.lib ];
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
'' + lib.optionalString stdenv.isLinux (
|
||||||
|
let
|
||||||
|
appimageContents = appimageTools.extract { inherit pname src version; };
|
||||||
|
in
|
||||||
|
''
|
||||||
mkdir -p $out/bin $out/share/${pname} $out/share/applications
|
mkdir -p $out/bin $out/share/${pname} $out/share/applications
|
||||||
cp -a ${appimageContents}/{locales,resources} $out/share/${pname}
|
cp -a ${appimageContents}/{locales,resources} $out/share/${pname}
|
||||||
cp -a ${appimageContents}/Logseq.desktop $out/share/applications/${pname}.desktop
|
cp -a ${appimageContents}/Logseq.desktop $out/share/applications/${pname}.desktop
|
||||||
@ -55,11 +68,15 @@ in {
|
|||||||
substituteInPlace $out/share/applications/${pname}.desktop \
|
substituteInPlace $out/share/applications/${pname}.desktop \
|
||||||
--replace Exec=Logseq Exec=${pname} \
|
--replace Exec=Logseq Exec=${pname} \
|
||||||
--replace Icon=Logseq Icon=${pname}
|
--replace Icon=Logseq Icon=${pname}
|
||||||
|
'') + 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/${pname}
|
||||||
|
'' + ''
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postFixup = ''
|
postFixup = lib.optionalString stdenv.isLinux ''
|
||||||
# set the env "LOCAL_GIT_DIRECTORY" for dugite so that we can use the git in nixpkgs
|
# set the env "LOCAL_GIT_DIRECTORY" for dugite so that we can use the git in nixpkgs
|
||||||
makeWrapper ${electron}/bin/electron $out/bin/${pname} \
|
makeWrapper ${electron}/bin/electron $out/bin/${pname} \
|
||||||
--set "LOCAL_GIT_DIRECTORY" ${git} \
|
--set "LOCAL_GIT_DIRECTORY" ${git} \
|
||||||
@ -76,7 +93,7 @@ in {
|
|||||||
license = lib.licenses.agpl3Plus;
|
license = lib.licenses.agpl3Plus;
|
||||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||||
maintainers = [ ];
|
maintainers = [ ];
|
||||||
platforms = [ "x86_64-linux" ];
|
platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
|
||||||
mainProgram = "logseq";
|
mainProgram = "logseq";
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user