Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit c6c48d8

Browse files
authored
flake: fix Electron version, fix Wayland support, fix source filter (#2329)
2 parents 2c87721 + c0b746e commit c6c48d8

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

apps/server/src/services/window.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async function configureWebContents(webContents: WebContents, spellcheckEnabled:
257257
}
258258

259259
function getIcon() {
260-
return path.join(RESOURCE_DIR, "images/app-icons/png/256x256" + (isDev ? "-dev" : "") + ".png");
260+
return path.join(RESOURCE_DIR, "../public/assets/icon.png");
261261
}
262262

263263
async function createSetupWindow() {

flake.nix

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
system:
2222
let
2323
pkgs = import nixpkgs { inherit system; };
24-
electron = pkgs.electron_35;
24+
electron = pkgs."electron_${lib.versions.major packageJsonDesktop.devDependencies.electron}";
2525
nodejs = pkgs.nodejs_22;
2626
pnpm = pkgs.pnpm_10;
2727
inherit (pkgs)
@@ -30,6 +30,7 @@
3030
lib
3131
makeBinaryWrapper
3232
makeDesktopItem
33+
makeShellWrapper
3334
moreutils
3435
removeReferencesTo
3536
stdenv
@@ -40,13 +41,13 @@
4041
fullCleanSourceFilter =
4142
name: type:
4243
(lib.cleanSourceFilter name type)
43-
|| (
44+
&& (
4445
let
4546
baseName = baseNameOf (toString name);
4647
in
4748
# No need to copy the flake.
4849
# Don't copy local development instance of NX cache.
49-
baseName == "flake.nix" || baseName == "flake.lock" || baseName == ".nx"
50+
baseName != "flake.nix" && baseName != "flake.lock" && baseName != ".nx"
5051
);
5152
fullCleanSource =
5253
src:
@@ -55,6 +56,7 @@
5556
src = src;
5657
};
5758
packageJson = builtins.fromJSON (builtins.readFile ./package.json);
59+
packageJsonDesktop = builtins.fromJSON (builtins.readFile ./apps/desktop/package.json);
5860

5961
makeApp =
6062
{
@@ -101,15 +103,20 @@
101103

102104
extraNativeBuildInputs =
103105
[
104-
makeBinaryWrapper
105106
moreutils # sponge
106107
nodejs.python
107108
removeReferencesTo
108109
]
109110
++ lib.optionals (app == "desktop") [
110111
copyDesktopItems
112+
# required for NIXOS_OZONE_WL expansion
113+
# https://github.com/NixOS/nixpkgs/issues/172583
114+
makeShellWrapper
111115
wrapGAppsHook3
112116
]
117+
++ lib.optionals (app == "server") [
118+
makeBinaryWrapper
119+
]
113120
++ lib.optionals stdenv.hostPlatform.isDarwin [
114121
xcodebuild
115122
darwin.cctools
@@ -162,7 +169,9 @@
162169
comment = meta.description;
163170
desktopName = "TriliumNext Notes";
164171
categories = [ "Office" ];
165-
startupWMClass = "Trilium Notes Next";
172+
# TODO: electron-forge build has this set to PRODUCT_NAME (forge.config.cjs)
173+
# But the plain build doesn't set this (or the app icon).
174+
startupWMClass = "TriliumNext Notes";
166175
})
167176
];
168177

@@ -184,9 +193,11 @@
184193
mkdir -p $out/{bin,share/icons/hicolor/512x512/apps,opt/trilium}
185194
cp --archive apps/desktop/dist/* $out/opt/trilium
186195
cp apps/client/src/assets/icon.png $out/share/icons/hicolor/512x512/apps/trilium.png
187-
makeWrapper ${lib.getExe electron} $out/bin/trilium \
196+
makeShellWrapper ${lib.getExe electron} $out/bin/trilium \
188197
"''${gappsWrapperArgs[@]}" \
198+
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
189199
--set-default ELECTRON_IS_DEV 0 \
200+
--set TRILIUM_RESOURCE_DIR $out/opt/trilium \
190201
--add-flags $out/opt/trilium/main.cjs
191202
'';
192203
};

0 commit comments

Comments
 (0)