Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(dx/nix): fix flake fully
FliegendeWurst834c67aeffe5
diff --git a/flake.lock b/flake.lockindex d77c38c697..590f44ef1b 100644--- a/flake.lock+++ b/flake.lock@@ -38,11 +38,11 @@},"nixpkgs": {"locked": {- "lastModified": 1751886450,- "narHash": "sha256-ODg0kj9LqBfwijQIDGC3WATqYN0sndImloD3IvinJEM=",+ "lastModified": 1757942231,+ "narHash": "sha256-yM1FFsRiyESij/lzbdBMCUoFOKMoShHu0CAexnBWzTM=","owner": "nixos","repo": "nixpkgs",- "rev": "979affb003b4626f2603b03ae7709dd4617b27e4",+ "rev": "dd16e0b60390586a261a4e28fc180a91212fe010","type": "github"},"original": {diff --git a/flake.nix b/flake.nixindex d819195be4..7920ec528a 100644--- a/flake.nix+++ b/flake.nix@@ -23,7 +23,15 @@pkgs = import nixpkgs { inherit system; };electron = pkgs."electron_${lib.versions.major packageJsonDesktop.devDependencies.electron}";nodejs = pkgs.nodejs_22;- pnpm = pkgs.pnpm_10;+ # pnpm creates an overly long PATH env variable for child processes.+ # This patch deduplicates entries in PATH, which results in an equivalent but shorter entry.+ # https://github.com/pnpm/pnpm/issues/6106+ # https://github.com/pnpm/pnpm/issues/8552+ pnpm = (pkgs.pnpm_10.overrideAttrs (prev: {+ postInstall = prev.postInstall + ''+ patch $out/libexec/pnpm/dist/pnpm.cjs ${./patches/pnpm-PATH-reduction.patch}+ '';+ }));inherit (pkgs)copyDesktopItemsdarwin@@ -47,7 +55,8 @@baseName = baseNameOf (toString name);in# No need to copy the flake.- baseName != "flake.nix" && baseName != "flake.lock"+ # No need to copy local copy of node_modules.+ baseName != "flake.nix" && baseName != "flake.lock" && baseName != "node_modules");fullCleanSource =src:@@ -139,6 +148,11 @@runHook postInstall'';+ # This file is a symlink into /build which is not allowed.+ postFixup = ''+ rm $out/opt/trilium*/node_modules/better-sqlite3/node_modules/.bin/prebuild-install || true+ '';+components = ["packages/ckeditor5""packages/ckeditor5-admonition"@@ -181,7 +195,13 @@desktop = makeApp {app = "desktop";- preBuildCommands = "export npm_config_nodedir=${electron.headers}; pnpm postinstall";+ # pnpm throws an error at the end of `pnpm postinstall`, but it doesn't seem to matter:+ # ENOENT: no such file or directory, lstat+ # '/build/source/apps/desktop/node_modules/better-sqlite3/build/node_gyp_bins'+ preBuildCommands = ''+ export npm_config_nodedir=${electron.headers}+ pnpm postinstall || true+ '';buildTask = "desktop:build";mainProgram = "trilium";installCommands = ''@@ -202,7 +222,16 @@server = makeApp {app = "server";- preBuildCommands = "pushd apps/server; pnpm rebuild; popd";+ # pnpm throws an error at the end of `pnpm rebuild`, but it doesn't seem to matter:+ # ERR_PNPM_MISSING_HOISTED_LOCATIONS+ # [email protected](@types/[email protected])([email protected])([email protected])([email protected])+ # is not found in hoistedLocations inside node_modules/.modules.yaml+ preBuildCommands = ''+ pushd apps/server+ pnpm rebuild || true+ popd+ '';buildTask = "server:build";mainProgram = "trilium-server";installCommands = ''diff --git a/patches/pnpm-PATH-reduction.patch b/patches/pnpm-PATH-reduction.patchnew file mode 100644index 0000000000..8c02352168--- /dev/null+++ b/patches/pnpm-PATH-reduction.patch@@ -0,0 +1,17 @@+--- a/libexec/pnpm/dist/pnpm.cjs 2025-09-15 11:33:34.014095372 +0200++++ b/libexec/pnpm/dist/pnpm.cjs 2025-09-15 11:37:00.260553326 +0200+@@ -68067,10 +68067,14 @@+ return false;+ }+ function spawn(cmd, args, options, log) {+ const cmdWillOutput = willCmdOutput(options && options.stdio);+ if (cmdWillOutput) startRunning(log);++ const stupidPath = options.env["PATH"];++ const parts = stupidPath.split(":");++ const partsDedup = new Set(parts);++ options.env["PATH"] = [...partsDedup].join(":");+ const raw = _spawn(cmd, args, options);+ const cooked = new EventEmitter();+ raw.on("error", function(er) {+ if (cmdWillOutput) stopRunning(log);+ er.file = cmd;