134 lines
3.5 KiB
Nix
134 lines
3.5 KiB
Nix
{
|
|
stdenv,
|
|
lib,
|
|
unzip,
|
|
fetchurl,
|
|
fetchzip,
|
|
makeBinaryWrapper,
|
|
# use specific electron since it has to load a compiled module
|
|
electron_34,
|
|
autoPatchelfHook,
|
|
makeDesktopItem,
|
|
copyDesktopItems,
|
|
wrapGAppsHook3,
|
|
asar,
|
|
}:
|
|
|
|
let
|
|
pname = "trilium-next-desktop";
|
|
version = "0.91.5";
|
|
|
|
linuxSource.url = "https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-linux-x64.zip";
|
|
linuxSource.sha256 = "10icng86y0idp7sjm7gzbcldd3gzc4z882d99hq959xiqd5lkcfi";
|
|
|
|
darwinSource.url = "https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-macos-x64.zip";
|
|
darwinSource.sha256 = "0377d12a43q2dmwb8zm22354w7crydj5q8n0g7i60gcyqsqpph8w";
|
|
|
|
meta = {
|
|
description = "Hierarchical note taking application with focus on building large personal knowledge bases";
|
|
homepage = "https://github.com/TriliumNext/Notes";
|
|
license = lib.licenses.agpl3Plus;
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
|
maintainers = with lib.maintainers; [
|
|
eliandoran
|
|
fliegendewurst
|
|
];
|
|
mainProgram = "trilium";
|
|
platforms = [
|
|
"x86_64-linux"
|
|
"x86_64-darwin"
|
|
];
|
|
};
|
|
|
|
linux = stdenv.mkDerivation rec {
|
|
inherit pname version meta;
|
|
|
|
src = fetchurl linuxSource;
|
|
|
|
# Remove trilium-portable.sh, so trilium knows it is packaged making it stop auto generating a desktop item on launch
|
|
postPatch = ''
|
|
rm ./trilium-portable.sh
|
|
'';
|
|
|
|
nativeBuildInputs = [
|
|
unzip
|
|
makeBinaryWrapper
|
|
wrapGAppsHook3
|
|
copyDesktopItems
|
|
autoPatchelfHook
|
|
asar
|
|
];
|
|
|
|
buildInputs = [
|
|
(lib.getLib stdenv.cc.cc)
|
|
];
|
|
|
|
desktopItems = [
|
|
(makeDesktopItem {
|
|
name = "Trilium";
|
|
exec = "trilium";
|
|
icon = "trilium";
|
|
comment = meta.description;
|
|
desktopName = "TriliumNext Notes";
|
|
categories = [ "Office" ];
|
|
startupWMClass = "Trilium Notes Next";
|
|
})
|
|
];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p "$out/bin"
|
|
mkdir -p "$out/share/trilium"
|
|
mkdir -p "$out/share/icons/hicolor/512x512/apps"
|
|
|
|
cp -r ./* "$out/share/trilium/"
|
|
rm $out/share/trilium/{*.so*,trilium,chrome_crashpad_handler,chrome-sandbox}
|
|
|
|
# Rebuild the ASAR archive, hardcoding the resourcesPath
|
|
tmp=$(mktemp -d)
|
|
asar extract $out/share/trilium/resources/app.asar $tmp
|
|
rm $out/share/trilium/resources/app.asar
|
|
|
|
for f in "src/services/utils.ts" "dist/src/services/utils.js"; do
|
|
substituteInPlace $tmp/$f \
|
|
--replace-fail "process.resourcesPath" "'$out/share/trilium/resources'"
|
|
done
|
|
autoPatchelf $tmp
|
|
cp $tmp/src/public/icon.png $out/share/icons/hicolor/512x512/apps/trilium.png
|
|
|
|
asar pack $tmp/ $out/share/trilium/resources/app.asar
|
|
rm -rf $tmp
|
|
|
|
makeWrapper ${lib.getExe electron_34} $out/bin/trilium \
|
|
"''${gappsWrapperArgs[@]}" \
|
|
--set-default ELECTRON_IS_DEV 0 \
|
|
--add-flags $out/share/trilium/resources/app.asar
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
dontWrapGApps = true;
|
|
|
|
passthru.updateScript = ./update.sh;
|
|
};
|
|
|
|
darwin = stdenv.mkDerivation {
|
|
inherit pname version meta;
|
|
|
|
src = fetchurl darwinSource;
|
|
|
|
nativeBuildInputs = [
|
|
unzip
|
|
];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p "$out/Applications/TriliumNext Notes.app"
|
|
cp -r * "$out/Applications/TriliumNext Notes.app/"
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
|
|
in
|
|
if stdenv.hostPlatform.isDarwin then darwin else linux
|