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
build(nix): pin Electron 44, which drops armv7l and bundled ANGLE
Elian Doranae34d8ad0d0a
diff --git a/flake.nix b/flake.nixindex 83a9269945..d122f28525 100644--- a/flake.nix+++ b/flake.nix@@ -31,27 +31,47 @@# with an attribute error instead of falling through to the pinned binary below.electronFromNixpkgs = pkgs."electron_${lib.versions.major electronVersion}" or null;- # nixpkgs lags behind the Electron version pinned in apps/desktop/package.json- # (electron_43 is still 43.1.0), and its source build cannot be bumped without+ # nixpkgs lags behind the Electron version pinned in apps/desktop/package.json —+ # often by a whole major — and its source build cannot be bumped without# upstream's Chromium dependency hashes. Build the exact pinned version from# Electron's official binary release instead, reusing the nixpkgs builder.## Don't refresh these by hand — `pnpm chore:update-flake-electron` rewrites both# bindings from the release's SHASUMS256.txt, and the update-nix-flake workflow# opens a PR whenever apps/desktop/package.json moves ahead of the pin.- pinnedElectronVersion = "43.4.1";+ pinnedElectronVersion = "44.0.0";pinnedElectronHashes = {- x86_64-linux = "79d4efd69f0ccf1fc11891ea5075329c7b3faddad79a08d9fb395bbd63169acf";- armv7l-linux = "2875860d6b7cb2e8a0142fb87f9f7be50a382a87a24bf15a0861f20ba53dc400";- aarch64-linux = "9e2b5cfbd387e138f06c7bb19b399bb3ee487dbb4110215df097d94e80431892";- x86_64-darwin = "4fd0f1826660a94216a0633600a3c3e2cd87ee9e4bc6f0e1edf717ad8e30c10b";- aarch64-darwin = "fe3cac8cbfd9ba1739fac6c69166cf30848741f93cbe251d800ae6ef7cebb64b";- headers = "0q7l48q2l4srmkw67l1bhk3qbybnqamcr5z8yrsnbxk8aazqjshv";+ x86_64-linux = "d65286d812719f2b4c1a1b806a80f288a1058c89c7b058dae1e03ab25e499446";+ aarch64-linux = "74b6f18bc29c0d52cf8e963c45d476800419097c6f3d53b27c5df335207e52bb";+ aarch64-darwin = "076d79742986e1b100b69ebecc691cb07368045e54c9087cef631b8622b76a80";+ headers = "0jz1ybp3y9dmv1v39jixf8nnhypi18kjibr763wz44m1adx7q9x3";};mkElectronBin = pkgs.callPackage (pkgs.path + "/pkgs/development/tools/electron/binary/generic.nix") { };+ # The nixpkgs Linux builder rewrites the rpath of Electron's ANGLE libraries with+ # an unguarded `patchelf ... lib*GL*`. Electron 44 links ANGLE into the main binary+ # and ships no libEGL.so/libGLESv2.so, so the glob expands to nothing and patchelf+ # exits with "missing filename". Let that one command tolerate an empty match; it+ # still patches the libraries on releases that do ship them.+ angleLibGlob = "$out/libexec/electron/lib*GL*";+ tolerateMissingAngleLibs =+ drv:+ drv.overrideAttrs (prev: {+ postFixup = lib.throwIf (!lib.hasInfix angleLibGlob prev.postFixup) ''+ The nixpkgs Electron builder no longer runs patchelf over ${angleLibGlob};+ drop tolerateMissingAngleLibs from flake.nix.+ '' (builtins.replaceStrings [ angleLibGlob ] [ "${angleLibGlob} || true" ] prev.postFixup);+ });++ # Guarded on Linux because only that branch of the builder defines postFixup.+ pinnedElectron =+ let+ bin = mkElectronBin pinnedElectronVersion pinnedElectronHashes;+ in+ if stdenv.hostPlatform.isLinux then tolerateMissingAngleLibs bin else bin;+electron =if electronFromNixpkgs != null && electronFromNixpkgs.version == electronVersion thenelectronFromNixpkgs@@ -59,7 +79,7 @@lib.throwIf (pinnedElectronVersion != electronVersion) ''flake.nix pins Electron ${pinnedElectronVersion}, but apps/desktop/package.json wants ${electronVersion}.Refresh pinnedElectronVersion/pinnedElectronHashes in flake.nix, or drop the override if nixpkgs ships ${electronVersion}.- '' (mkElectronBin pinnedElectronVersion pinnedElectronHashes);+ '' pinnedElectron;nodejs = pkgs.nodejs_24;# pnpm creates an overly long PATH env variable for child processes.@@ -100,7 +120,7 @@makeBinaryWrappermakeDesktopItemmakeShellWrapper-removeReferencesTo+ removeReferencesTostdenvwrapGAppsHook3xcodebuild@@ -196,7 +216,7 @@ removeReferencesToextraNativeBuildInputs =[-nodejs.python+ nodejs.pythonremoveReferencesTo]++ lib.optionals (app == "desktop" || app == "edit-docs") [diff --git a/scripts/update-flake-electron.spec.ts b/scripts/update-flake-electron.spec.tsindex 1b17d74c02..27951c3765 100644--- a/scripts/update-flake-electron.spec.ts+++ b/scripts/update-flake-electron.spec.ts@@ -15,9 +15,7 @@ const FLAKE = `{pinnedElectronVersion = "43.2.0";pinnedElectronHashes = {x86_64-linux = "old-x64";- armv7l-linux = "old-armv7l";aarch64-linux = "old-arm64";- x86_64-darwin = "old-darwin-x64";aarch64-darwin = "old-darwin-arm64";headers = "old-headers";};@@ -29,9 +27,7 @@ const FLAKE = `{const HASHES = {"x86_64-linux": "x64",- "armv7l-linux": "armv7l","aarch64-linux": "arm64",- "x86_64-darwin": "darwin-x64","aarch64-darwin": "darwin-arm64","headers": "headers"};@@ -70,12 +66,10 @@ describe("parseShasums", () => {""].join("\n");- it("picks the five platform zips and ignores the rest of the release", () => {+ it("picks the platform zips it pins and ignores the rest of the release", () => {expect(parseShasums(shasums, "43.3.0")).toEqual({"x86_64-linux": "1".repeat(64),- "armv7l-linux": "2".repeat(64),"aarch64-linux": "3".repeat(64),- "x86_64-darwin": "4".repeat(64),"aarch64-darwin": "5".repeat(64)});});@@ -83,7 +77,7 @@ describe("parseShasums", () => {it("names the assets it could not find rather than emitting a partial set", () => {expect(() => parseShasums(shasums, "43.4.0")).toThrow(/electron-v43\.4\.0-linux-x64\.zip/);- // Only the one that is genuinely absent — the four it did resolve stay unmentioned.+ // Only the one that is genuinely absent — the two it did resolve stay unmentioned.const withoutArm = shasums.replace(/^.*darwin-arm64\.zip$/m, "");const onlyDarwinArm = /^(?!.*linux-x64).*darwin-arm64\.zip/s;expect(() => parseShasums(withoutArm, "43.3.0")).toThrow(onlyDarwinArm);@@ -101,9 +95,7 @@ describe("rewriteFlake", () => {pinnedElectronVersion = "43.3.0";pinnedElectronHashes = {x86_64-linux = "x64";- armv7l-linux = "armv7l";aarch64-linux = "arm64";- x86_64-darwin = "darwin-x64";aarch64-darwin = "darwin-arm64";headers = "headers";};diff --git a/scripts/update-flake-electron.ts b/scripts/update-flake-electron.tsindex 2b3abd2d51..44c0db2b85 100644--- a/scripts/update-flake-electron.ts+++ b/scripts/update-flake-electron.ts@@ -11,7 +11,7 @@* error: flake.nix pins Electron 43.2.0, but apps/desktop/package.json wants 43.3.0** This script is that mirroring, automated: it reads the wanted version, takes- * the five per-platform zip checksums from the release's own `SHASUMS256.txt`,+ * the per-platform zip checksums from the release's own `SHASUMS256.txt`,* computes the headers hash with `nix-prefetch-url`, and rewrites both* `pinnedElectron*` bindings. It is a no-op when the pin already matches, so it* is safe to run on a schedule.@@ -60,15 +60,14 @@ export async function main() {/*** Nix system → the tag Electron uses in its release asset names, in the order the- * generated `pinnedElectronHashes` block lists them. Mirrors `tags` in nixpkgs'- * `pkgs/development/tools/electron/binary/generic.nix`, which is the builder the- * flake reuses, so the set of systems here is exactly the set that builder covers.+ * generated `pinnedElectronHashes` block lists them. A system belongs here when the+ * Electron release ships that zip and `tags` in nixpkgs'+ * `pkgs/development/tools/electron/binary/generic.nix` — the builder the flake+ * reuses — covers it.*/export const ELECTRON_PLATFORM_TAGS: Record<string, string> = {"x86_64-linux": "linux-x64",- "armv7l-linux": "linux-armv7l","aarch64-linux": "linux-arm64",- "x86_64-darwin": "darwin-x64","aarch64-darwin": "darwin-arm64"};@@ -112,9 +111,13 @@ async function fetchShasums(version: string): Promise<string> {}/**- * Pull the five zip checksums out of a release's `SHASUMS256.txt`, whose lines are- * `<sha256> *<asset name>`. The file also lists chromedriver, symbol and mas- * builds, so match asset names exactly rather than by substring.+ * Pull the per-platform zip checksums out of a release's `SHASUMS256.txt`, whose+ * lines are `<sha256> *<asset name>`. The file also lists chromedriver, symbol and+ * mas builds, so match asset names exactly rather than by substring.+ *+ * Throw on a missing asset rather than emitting a partial set: Electron dropping a+ * platform has to shrink `ELECTRON_PLATFORM_TAGS` and the flake together, which is a+ * decision for a human, not something to paper over by silently pinning fewer systems.*/export function parseShasums(shasums: string, version: string): Record<string, string> {const byAsset = new Map<string, string>();