Skip to content

Build your personal knowledge base with Trilium Notes

fix(scripts): use flake when rebuilding Electron in postinstall script

Elian Doran788e867a6cdf
diff --git a/scripts/utils.mts b/scripts/utils.mts
index 8490b50fd2..02883db106 100644
--- a/scripts/utils.mts
+++ b/scripts/utils.mts
@@ -28,7 +28,7 @@ function resetPath() {
export function getElectronPath() {
if (isNixOS()) {
- resetPath();
+ resetPath();
try {
const path = execSync("which electron").toString("utf-8").trimEnd();
@@ -37,8 +37,16 @@ export function getElectronPath() {
// Nothing to do, since we have a fallback below.
}
- console.log("Using default since no Electron is available in path.");
- return execSync("nix eval --raw nixpkgs#electron_37").toString("utf-8") + "/bin/electron";
+ console.log("No Electron in PATH, using 'nix develop' to get it...");
+
+ try {
+ const path = execSync("nix develop -c which electron", { stdio: ["pipe", "pipe", "pipe"] }).toString("utf-8").trimEnd();
+ return path;
+ } catch (e) {
+ console.error("\nFailed to get Electron from 'nix develop'.");
+ console.error("Please ensure you have a valid flake.nix with electron in devShells.default.");
+ process.exit(1);
+ }
} else {
return "electron";
}