From 8cdb1859e3fb132fbc14209831f37fa0330318af Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Sun, 15 Jun 2025 23:32:02 +0200 Subject: [PATCH 1/5] fix(flake): use same Electron version as normal build Also fix the source filtering logic to work properly. --- flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 3b3736081..7513dcd48 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ system: let pkgs = import nixpkgs { inherit system; }; - electron = pkgs.electron_35; + electron = pkgs."electron_${lib.versions.major packageJsonDesktop.devDependencies.electron}"; nodejs = pkgs.nodejs_22; pnpm = pkgs.pnpm_10; inherit (pkgs) @@ -40,13 +40,13 @@ fullCleanSourceFilter = name: type: (lib.cleanSourceFilter name type) - || ( + && ( let baseName = baseNameOf (toString name); in # No need to copy the flake. # Don't copy local development instance of NX cache. - baseName == "flake.nix" || baseName == "flake.lock" || baseName == ".nx" + baseName != "flake.nix" && baseName != "flake.lock" && baseName != ".nx" ); fullCleanSource = src: @@ -55,6 +55,7 @@ src = src; }; packageJson = builtins.fromJSON (builtins.readFile ./package.json); + packageJsonDesktop = builtins.fromJSON (builtins.readFile ./apps/desktop/package.json); makeApp = { From f56ba7295ab2311248e6abf04556f05f95f232a3 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Mon, 16 Jun 2025 07:46:31 +0200 Subject: [PATCH 2/5] chore(flake): note differences to electron-forge build --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 7513dcd48..125992fa5 100644 --- a/flake.nix +++ b/flake.nix @@ -163,7 +163,9 @@ comment = meta.description; desktopName = "TriliumNext Notes"; categories = [ "Office" ]; - startupWMClass = "Trilium Notes Next"; + # TODO: electron-forge build has this set to PRODUCT_NAME (forge.config.cjs) + # But the plain build doesn't set this (or the app icon). + startupWMClass = "TriliumNext Notes"; }) ]; From e8f2f0f5778d1893f0423d1e48895501647eecd7 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Mon, 16 Jun 2025 08:05:12 +0200 Subject: [PATCH 3/5] feat(flake): Wayland support --- flake.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 125992fa5..318d6e830 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,7 @@ lib makeBinaryWrapper makeDesktopItem + makeShellWrapper moreutils removeReferencesTo stdenv @@ -102,15 +103,20 @@ extraNativeBuildInputs = [ - makeBinaryWrapper moreutils # sponge nodejs.python removeReferencesTo ] ++ lib.optionals (app == "desktop") [ copyDesktopItems + # required for NIXOS_OZONE_WL expansion + # https://github.com/NixOS/nixpkgs/issues/172583 + makeShellWrapper wrapGAppsHook3 ] + ++ lib.optionals (app == "server") [ + makeBinaryWrapper + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcodebuild darwin.cctools @@ -187,8 +193,9 @@ mkdir -p $out/{bin,share/icons/hicolor/512x512/apps,opt/trilium} cp --archive apps/desktop/dist/* $out/opt/trilium cp apps/client/src/assets/icon.png $out/share/icons/hicolor/512x512/apps/trilium.png - makeWrapper ${lib.getExe electron} $out/bin/trilium \ + makeShellWrapper ${lib.getExe electron} $out/bin/trilium \ "''${gappsWrapperArgs[@]}" \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ --set-default ELECTRON_IS_DEV 0 \ --add-flags $out/opt/trilium/main.cjs ''; From a13e4d5d796c98563d7009afa496fe982fc6fd37 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Mon, 16 Jun 2025 08:08:22 +0200 Subject: [PATCH 4/5] fix(flake): set resourceDir explicitly --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 318d6e830..53cf37765 100644 --- a/flake.nix +++ b/flake.nix @@ -197,6 +197,7 @@ "''${gappsWrapperArgs[@]}" \ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ --set-default ELECTRON_IS_DEV 0 \ + --set TRILIUM_RESOURCE_DIR $out/opt/trilium \ --add-flags $out/opt/trilium/main.cjs ''; }; From c0b746e03faa08e9e04616af3d3270da98e4a80d Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Mon, 16 Jun 2025 08:29:21 +0200 Subject: [PATCH 5/5] fix(desktop): proper icon path The previous value points to a file that no longer exists in the release builds. This file also only exists in the flake build. --- apps/server/src/services/window.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/src/services/window.ts b/apps/server/src/services/window.ts index a803e150d..42969cf39 100644 --- a/apps/server/src/services/window.ts +++ b/apps/server/src/services/window.ts @@ -257,7 +257,7 @@ async function configureWebContents(webContents: WebContents, spellcheckEnabled: } function getIcon() { - return path.join(RESOURCE_DIR, "images/app-icons/png/256x256" + (isDev ? "-dev" : "") + ".png"); + return path.join(RESOURCE_DIR, "../public/assets/icon.png"); } async function createSetupWindow() {