trilium-{desktop,server}: 0.97.2 -> 0.98.0 | refactor (#434791)

This commit is contained in:
Fernando Rodrigues
2025-08-26 11:44:56 +00:00
committed by GitHub
10 changed files with 50 additions and 349 deletions
@@ -1,72 +0,0 @@
diff --git a/src/services/log.js b/src/services/log.js
index a141eae14..094b9381b 100644
--- a/src/services/log.js
+++ b/src/services/log.js
@@ -1,15 +1,7 @@
"use strict";
-const fs = require('fs');
-const dataDir = require('./data_dir.js');
const cls = require('./cls.js');
-if (!fs.existsSync(dataDir.LOG_DIR)) {
- fs.mkdirSync(dataDir.LOG_DIR, 0o700);
-}
-
-let logFile = null;
-
const SECOND = 1000;
const MINUTE = 60 * SECOND;
const HOUR = 60 * MINUTE;
@@ -17,38 +9,6 @@ const DAY = 24 * HOUR;
const NEW_LINE = process.platform === "win32" ? '\r\n' : '\n';
-let todaysMidnight = null;
-
-initLogFile();
-
-function getTodaysMidnight() {
- const now = new Date();
-
- return new Date(now.getFullYear(), now.getMonth(), now.getDate());
-}
-
-function initLogFile() {
- todaysMidnight = getTodaysMidnight();
-
- const path = `${dataDir.LOG_DIR}/trilium-${formatDate()}.log`;
-
- if (logFile) {
- logFile.end();
- }
-
- logFile = fs.createWriteStream(path, {flags: 'a'});
-}
-
-function checkDate(millisSinceMidnight) {
- if (millisSinceMidnight >= DAY) {
- initLogFile();
-
- millisSinceMidnight -= DAY;
- }
-
- return millisSinceMidnight;
-}
-
function log(str) {
const bundleNoteId = cls.get("bundleNoteId");
@@ -56,12 +16,6 @@ function log(str) {
str = `[Script ${bundleNoteId}] ${str}`;
}
- let millisSinceMidnight = Date.now() - todaysMidnight.getTime();
-
- millisSinceMidnight = checkDate(millisSinceMidnight);
-
- logFile.write(`${formatTime(millisSinceMidnight)} ${str}${NEW_LINE}`);
-
console.log(str);
}
@@ -1,21 +0,0 @@
{ lib, callPackage, ... }:
let
metaCommon = with lib; {
description = "Hierarchical note taking application with focus on building large personal knowledge bases";
homepage = "https://github.com/zadam/trilium";
license = licenses.agpl3Plus;
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [
fliegendewurst
eliandoran
];
};
in
{
trilium-desktop = callPackage ./desktop.nix { metaCommon = metaCommon; };
trilium-server = callPackage ./server.nix { metaCommon = metaCommon; };
}
@@ -1,113 +0,0 @@
{
stdenv,
lib,
unzip,
autoPatchelfHook,
fetchurl,
makeWrapper,
alsa-lib,
libgbm,
nss,
nspr,
systemd,
makeDesktopItem,
copyDesktopItems,
wrapGAppsHook3,
metaCommon,
}:
let
pname = "trilium-desktop";
version = "0.63.6";
linuxSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz";
linuxSource.sha256 = "12kgq5x4f93hxz057zqhz0x1y0rxfxh90fv9fjjs3jrnk0by7f33";
darwinSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-mac-x64-${version}.zip";
darwinSource.sha256 = "0ry512cn622av3nm8rnma2yvqc71rpzax639872ivvc5vm4rsc30";
meta = metaCommon // {
mainProgram = "trilium";
platforms = [
"x86_64-linux"
"x86_64-darwin"
];
};
linux = stdenv.mkDerivation rec {
inherit pname version meta;
src = fetchurl linuxSource;
# TODO: migrate off autoPatchelfHook and use nixpkgs' electron
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
wrapGAppsHook3
copyDesktopItems
];
buildInputs = [
alsa-lib
libgbm
nss
nspr
stdenv.cc.cc
systemd
];
desktopItems = [
(makeDesktopItem {
name = "Trilium";
exec = "trilium";
icon = "trilium";
comment = meta.description;
desktopName = "Trilium Notes";
categories = [ "Office" ];
startupWMClass = "trilium notes";
})
];
# 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
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/share/trilium
mkdir -p $out/share/icons/hicolor/128x128/apps
cp -r ./* $out/share/trilium
ln -s $out/share/trilium/trilium $out/bin/trilium
ln -s $out/share/trilium/icon.png $out/share/icons/hicolor/128x128/apps/trilium.png
runHook postInstall
'';
# LD_LIBRARY_PATH "shouldn't" be needed, remove when possible :)
# Error: libstdc++.so.6: cannot open shared object file: No such file or directory
preFixup = ''
gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs})
'';
dontStrip = true;
passthru.updateScript = ./update.sh;
};
darwin = stdenv.mkDerivation {
inherit pname version meta;
src = fetchurl darwinSource;
nativeBuildInputs = [ unzip ];
installPhase = ''
mkdir -p $out/Applications
cp -r *.app $out/Applications
'';
};
in
if stdenv.hostPlatform.isDarwin then darwin else linux
@@ -1,65 +0,0 @@
{
lib,
stdenv,
autoPatchelfHook,
fetchurl,
nixosTests,
metaCommon,
}:
let
serverSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz";
serverSource.sha256 = "0gwp6h6nvfzq7k1g3233h838nans45jkd5c3pzl6qdhhm19vcs27";
version = "0.63.6";
in
stdenv.mkDerivation {
pname = "trilium-server";
inherit version;
meta = metaCommon // {
platforms = [ "x86_64-linux" ];
mainProgram = "trilium-server";
};
src = fetchurl serverSource;
nativeBuildInputs = [
autoPatchelfHook
];
buildInputs = [
(lib.getLib stdenv.cc.cc)
];
patches = [
# patch logger to use console instead of rolling files
./0001-Use-console-logger-instead-of-rolling-files.patch
];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/share/trilium-server
cp -r ./* $out/share/trilium-server
runHook postInstall
'';
postFixup = ''
cat > $out/bin/trilium-server <<EOF
#!${stdenv.cc.shell}
cd $out/share/trilium-server
exec ./node/bin/node src/www
EOF
chmod a+x $out/bin/trilium-server
# ERROR: noBrokenSymlinks: found 4 dangling symlinks, 0 reflexive symlinks and 0 unreadable symlinks
unlink $out/share/trilium-server/node/bin/npx
unlink $out/share/trilium-server/node/bin/npm
unlink $out/share/trilium-server/node_modules/.bin/electron
unlink $out/share/trilium-server/node_modules/.bin/electron-installer-debian
'';
passthru.tests = {
trilium-server = nixosTests.trilium-server;
};
}
@@ -1,23 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl jq
set -euo pipefail
cd $(dirname "${BASH_SOURCE[0]}")
setKV () {
sed -i "s|$2 = \".*\"|$2 = \"${3:-}\"|" $1
}
version=$(curl -s --show-error "https://api.github.com/repos/zadam/trilium/releases/latest" | jq -r '.tag_name' | tail -c +2)
# Update desktop application
sha256_linux64=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz)
sha256_darwin64=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-mac-x64-${version}.zip)
setKV ./desktop.nix version $version
setKV ./desktop.nix linuxSource.sha256 $sha256_linux64
setKV ./desktop.nix darwinSource.sha256 $sha256_darwin64
# Update server
sha256_linux64_server=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz)
setKV ./server.nix version $version
setKV ./server.nix serverSource.sha256 $sha256_linux64_server
@@ -14,28 +14,28 @@
}:
let
pname = "trilium-next-desktop";
version = "0.97.2";
pname = "trilium-desktop";
version = "0.98.0";
triliumSource = os: arch: sha256: {
triliumSource = os: arch: hash: {
url = "https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-${os}-${arch}.zip";
inherit sha256;
inherit hash;
};
linuxSource = triliumSource "linux";
darwinSource = triliumSource "macos";
# exposed like this for update.sh
x86_64-linux.sha256 = "12ms6knzaawryf7qisfnj5fj7v1icvkq7r0fpw55aajm7y0mpmf0";
aarch64-linux.sha256 = "0qgvasic531crlckwqn8mm9aimm7kliab2y7i264k60pb8h5spmp";
x86_64-darwin.sha256 = "1dam3ig7z21vi6icd4ww46smgn4d7kis3r51h0r5cvi8mc9ahq1i";
aarch64-darwin.sha256 = "0wysa3kacxryv1g1rmqm4ikjv9hfp1bqjcv1yn8drsi80zscm4lj";
x86_64-linux.hash = "sha256-GrREVY6P9L0ymH6QbXdtOm3mNzFD3u8HAOWDI7/x1VU=";
aarch64-linux.hash = "sha256-bLeU2REsKuVRei3WujGJEponiCZAviE8WyofWu2/NPg=";
x86_64-darwin.hash = "sha256-pN+6HapDxL/anMQJ2JeGmtBcRrlLMzJlEpSTo9QBbpg=";
aarch64-darwin.hash = "sha256-9y8NDrwiz9ql1Ia2F0UYF0XWBCyCahHZaAPOsvIJ5l0=";
sources = {
x86_64-linux = linuxSource "x64" x86_64-linux.sha256;
aarch64-linux = linuxSource "arm64" aarch64-linux.sha256;
x86_64-darwin = darwinSource "x64" x86_64-darwin.sha256;
aarch64-darwin = darwinSource "arm64" aarch64-darwin.sha256;
x86_64-linux = linuxSource "x64" x86_64-linux.hash;
aarch64-linux = linuxSource "arm64" aarch64-linux.hash;
x86_64-darwin = darwinSource "x64" x86_64-darwin.hash;
aarch64-darwin = darwinSource "arm64" aarch64-darwin.hash;
};
src = fetchurl sources.${stdenv.hostPlatform.system};
@@ -85,9 +85,9 @@ let
exec = "trilium";
icon = "trilium";
comment = meta.description;
desktopName = "TriliumNext Notes";
desktopName = "Trilium Notes";
categories = [ "Office" ];
startupWMClass = "Trilium Notes Next";
startupWMClass = "Trilium Notes";
})
];
@@ -138,8 +138,8 @@ let
installPhase = ''
runHook preInstall
mkdir -p "$out/Applications/TriliumNext Notes.app"
cp -r * "$out/Applications/TriliumNext Notes.app/"
mkdir -p "$out/Applications/Trilium Notes.app"
cp -r * "$out/Applications/Trilium Notes.app/"
runHook postInstall
'';
};
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl jq
set -euo pipefail
cd $(dirname "${BASH_SOURCE[0]}")
setKV () {
sed -i "s|$2 = \".*\"|$2 = \"${3:-}\"|" $1
}
version=$(curl -s --show-error "https://api.github.com/repos/TriliumNext/Trilium/releases/latest" | jq -r '.tag_name' | tail -c +2)
setKV ./package.nix version $version
# Update desktop application
sha256_linux64=$(nix store prefetch-file --json --hash-type sha256 https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-linux-x64.zip | jq -r .hash)
sha256_linux64_arm=$(nix store prefetch-file --json --hash-type sha256 https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-linux-arm64.zip | jq -r .hash)
sha256_darwin64=$(nix store prefetch-file --json --hash-type sha256 https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-macos-x64.zip | jq -r .hash)
sha256_darwin64_arm=$(nix store prefetch-file --json --hash-type sha256 https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-macos-arm64.zip | jq -r .hash)
setKV ./package.nix x86_64-linux.hash $sha256_linux64
setKV ./package.nix aarch64-linux.hash $sha256_linux64_arm
setKV ./package.nix x86_64-darwin.hash $sha256_darwin64
setKV ./package.nix aarch64-darwin.hash $sha256_darwin64_arm
# Update server
sha256_linux64_server=$(nix store prefetch-file --json --hash-type sha256 https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-x64.tar.xz | jq -r .hash)
sha256_linux64_server_arm=$(nix store prefetch-file --json --hash-type sha256 https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-arm64.tar.xz | jq -r .hash)
setKV ../trilium-server/package.nix version $version
setKV ../trilium-server/package.nix serverSource_x64.hash $sha256_linux64_server
setKV ../trilium-server/package.nix serverSource_arm64.hash $sha256_linux64_server_arm
@@ -1,29 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl jq
set -euo pipefail
cd $(dirname "${BASH_SOURCE[0]}")
setKV () {
sed -i "s|$2 = \".*\"|$2 = \"${3:-}\"|" $1
}
version=$(curl -s --show-error "https://api.github.com/repos/TriliumNext/Trilium/releases/latest" | jq -r '.tag_name' | tail -c +2)
setKV ./package.nix version $version
# Update desktop application
sha256_linux64=$(nix-prefetch-url --quiet https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-linux-x64.zip)
sha256_linux64_arm=$(nix-prefetch-url --quiet https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-linux-arm64.zip)
sha256_darwin64=$(nix-prefetch-url --quiet https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-macos-x64.zip)
sha256_darwin64_arm=$(nix-prefetch-url --quiet https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-v${version}-macos-arm64.zip)
setKV ./package.nix x86_64-linux.sha256 $sha256_linux64
setKV ./package.nix aarch64-linux.sha256 $sha256_linux64_arm
setKV ./package.nix x86_64-darwin.sha256 $sha256_darwin64
setKV ./package.nix aarch64-darwin.sha256 $sha256_darwin64_arm
# Update server
sha256_linux64_server=$(nix-prefetch-url --quiet https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-x64.tar.xz)
sha256_linux64_server_arm=$(nix-prefetch-url --quiet https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-arm64.tar.xz)
setKV ../trilium-next-server/package.nix version $version
setKV ../trilium-next-server/package.nix serverSource_x64.sha256 $sha256_linux64_server
setKV ../trilium-next-server/package.nix serverSource_arm64.sha256 $sha256_linux64_server_arm
@@ -7,12 +7,12 @@
}:
let
version = "0.97.2";
version = "0.98.0";
serverSource_x64.url = "https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-x64.tar.xz";
serverSource_x64.sha256 = "1zbi1jh2iib6wcaab0wdhb2rhslmn06dn22h28h8jjj5qjpbqqz0";
serverSource_x64.hash = "sha256-m5QDm8XOFi5Blbif044WMm/yyRrJx5t9/LjSto/gSL0=";
serverSource_arm64.url = "https://github.com/TriliumNext/Trilium/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-arm64.tar.xz";
serverSource_arm64.sha256 = "1a6gnfprskq0cqvg625dazqq39h89d3g9rssdcyw7w0a7kw8nfrv";
serverSource_arm64.hash = "sha256-1pdQEJIOxDU05z+31gNpsb9K4BpJ3njNsqxJymfD4wg=";
serverSource =
if stdenv.hostPlatform.isx86_64 then
@@ -20,10 +20,10 @@ let
else if stdenv.hostPlatform.isAarch64 then
serverSource_arm64
else
throw "${stdenv.hostPlatform.config} not supported by trilium-next-server";
throw "${stdenv.hostPlatform.config} not supported by trilium-server";
in
stdenv.mkDerivation {
pname = "trilium-next-server";
pname = "trilium-server";
inherit version;
src = fetchurl serverSource;
-5
View File
@@ -4343,11 +4343,6 @@ with pkgs;
translatepy = with python3.pkgs; toPythonApplication translatepy;
inherit (callPackage ../applications/office/trilium { })
trilium-desktop
trilium-server
;
trytond = with python3Packages; toPythonApplication trytond;
ttfautohint = libsForQt5.callPackage ../tools/misc/ttfautohint { };