mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 02:36:07 +02:00
Merge remote-tracking branch 'origin/main' into standalone
; Conflicts: ; CLAUDE.md ; apps/client/src/widgets/collections/board/data.spec.ts ; apps/server/package.json ; apps/server/src/routes/routes.ts ; apps/server/src/services/app_info.ts ; apps/server/src/services/blob-interface.ts ; apps/server/src/services/entity_changes.ts ; apps/server/src/services/handlers.ts ; apps/server/src/services/hidden_subtree.ts ; apps/server/src/services/image.ts ; apps/server/src/services/options_init.ts ; apps/server/src/services/search/services/search.ts ; packages/trilium-core/src/services/blob.ts ; packages/trilium-core/src/services/import/markdown.ts ; packages/trilium-core/src/services/import/markdown/wikilink_internal_link.ts ; packages/trilium-core/src/services/import/markdown/wikilink_transclusion.ts ; packages/trilium-core/src/services/search/expressions/ocr_content.ts ; packages/trilium-core/src/services/search/search_result.ts ; packages/trilium-core/src/services/search/services/parse.ts ; pnpm-lock.yaml
This commit is contained in:
@@ -51,6 +51,7 @@ export default class BuildHelper {
|
||||
"electron",
|
||||
"@electron/remote",
|
||||
"better-sqlite3",
|
||||
"pdfjs-dist",
|
||||
"./xhr-sync-worker.js",
|
||||
"vite"
|
||||
],
|
||||
|
||||
@@ -1,11 +1,27 @@
|
||||
import { join, resolve } from "path";
|
||||
import { cpSync, exists, existsSync, mkdirSync, readFileSync, rmSync } from "fs";
|
||||
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync } from "fs";
|
||||
import { execSync } from "child_process";
|
||||
import { rebuild } from "@electron/rebuild"
|
||||
import { getElectronPath, isNixOS } from "./utils.mjs";
|
||||
import { isNixOS } from "./utils.mjs";
|
||||
|
||||
const workspaceRoot = join(import.meta.dirname, "..");
|
||||
|
||||
// On NixOS, re-execute this script inside `nix develop` to get access to Python and other build tools
|
||||
if (isNixOS() && !process.env.IN_NIX_SHELL) {
|
||||
console.log("Detected NixOS, re-running electron-rebuild inside 'nix develop'...");
|
||||
try {
|
||||
execSync("nix develop -c pnpm exec tsx scripts/electron-rebuild.mts", {
|
||||
cwd: workspaceRoot,
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, IN_NIX_SHELL: "1" }
|
||||
});
|
||||
process.exit(0);
|
||||
} catch (e) {
|
||||
console.error("Failed to run electron-rebuild inside 'nix develop'.");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function copyNativeDependencies(projectRoot: string) {
|
||||
const destPath = join(projectRoot, "node_modules/better-sqlite3");
|
||||
|
||||
@@ -46,20 +62,8 @@ async function rebuildNativeDependencies(projectRoot: string) {
|
||||
|
||||
function determineElectronVersion(projectRoot: string) {
|
||||
const packageJson = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf-8"));
|
||||
|
||||
if (isNixOS()) {
|
||||
console.log("Detected NixOS, reading Electron version from PATH");
|
||||
|
||||
try {
|
||||
return execSync(`${getElectronPath()} --version`, { }).toString("utf-8");
|
||||
} catch (e) {
|
||||
console.error("Got error while trying to read the Electron version from shell. Make sure that an Electron version is in the PATH (e.g. `nix-shell -p electron`)");
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
console.log("Using Electron version from package.json");
|
||||
return packageJson.devDependencies.electron;
|
||||
}
|
||||
console.log("Using Electron version from package.json");
|
||||
return packageJson.devDependencies.electron;
|
||||
}
|
||||
|
||||
for (const projectRoot of [ "apps/desktop", "apps/edit-docs" ]) {
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user