From e12e83406075733de4214b70693223ed7bfd0cce Mon Sep 17 00:00:00 2001 From: Mynacol Date: Tue, 12 May 2026 13:35:00 +0000 Subject: [PATCH 1/2] zotero: Use release channel Our zotero build had the version string 9.0.2.SOURCE.000000000, while upstream releases of course only have 9.0.2. This leaks in HTTP headers and JavaScript functions, which is used e.g. by Better BibTeX. This add-on actually partially fails due to the unexpected version string. This commit switches to the release channel. This also would enable updates, which fail/hang because the firefox updater is not included in our firefox builds. Instead of patching app/scripts/dir_build, I opt to call app/scripts/prepare_build and app/build.sh directly. This also brings us closer to cross-compile support (as we now select the build system and architecture from targetHost). --- pkgs/by-name/zo/zotero/avoid-git.patch | 13 ------ pkgs/by-name/zo/zotero/package.nix | 58 +++++++++++++++++--------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/pkgs/by-name/zo/zotero/avoid-git.patch b/pkgs/by-name/zo/zotero/avoid-git.patch index f0c6b4ffdeaf..dda5290a3ab2 100644 --- a/pkgs/by-name/zo/zotero/avoid-git.patch +++ b/pkgs/by-name/zo/zotero/avoid-git.patch @@ -1,16 +1,3 @@ -diff --git a/app/scripts/dir_build b/app/scripts/dir_build -index 493288ad47..ccabb3722b 100755 ---- a/app/scripts/dir_build -+++ b/app/scripts/dir_build -@@ -86,7 +86,7 @@ fi - - CHANNEL="source" - --hash=$(git -C "$ROOT_DIR" rev-parse --short HEAD) -+hash="0000000000000000000000000000000000000000" - - build_dir=$(mktemp -d) - cleanup() { rm -rf "$build_dir"; } diff --git a/js-build/note-editor.js b/js-build/note-editor.js index 1435730342..6eebb10c50 100644 --- a/js-build/note-editor.js diff --git a/pkgs/by-name/zo/zotero/package.nix b/pkgs/by-name/zo/zotero/package.nix index ec1954aabc99..b9cbdf0a28b0 100644 --- a/pkgs/by-name/zo/zotero/package.nix +++ b/pkgs/by-name/zo/zotero/package.nix @@ -223,30 +223,48 @@ buildNpmPackage (finalAttrs: { done ''; - buildPhase = '' - runHook preBuild + buildPhase = + let + zoteroArch = + platform: + if platform.isAarch64 then + "arm64" + else if platform.isx86_64 then + "x64" + else if platform.isx86_32 then + "i686" + else + platform.parsed.cpu.name; + in + '' + runHook preBuild - npm run build + npm run build - # Place firefox files at the right place. - # The correct firefox version can be found in zotero/app/config.sh at `GECKO_VERSION_LINUX`. - mkdir -p app/xulrunner/ - '' - + lib.optionalString stdenv.targetPlatform.isDarwin '' - cp -r "${firefox-esr-140-unwrapped}/Applications/Firefox ESR.app" app/xulrunner/Firefox.app - '' - + lib.optionalString (!stdenv.targetPlatform.isDarwin) '' - cp -r "${firefox-esr-140-unwrapped}/lib/firefox" "app/xulrunner/firefox-${stdenv.targetPlatform.parsed.kernel.name}-${ - lib.replaceString "aarch64" "arm64" stdenv.targetPlatform.parsed.cpu.name - }" - '' - + '' - chmod -R u+w app/xulrunner/ + # Place firefox files at the right place. + # The correct firefox version can be found in zotero/app/config.sh at `GECKO_VERSION_LINUX`. + mkdir -p app/xulrunner/ + '' + + lib.optionalString stdenv.targetPlatform.isDarwin '' + cp -r "${firefox-esr-140-unwrapped}/Applications/Firefox ESR.app" app/xulrunner/Firefox.app + '' + + lib.optionalString (!stdenv.targetPlatform.isDarwin) '' + cp -r "${firefox-esr-140-unwrapped}/lib/firefox" "app/xulrunner/firefox-${stdenv.targetPlatform.parsed.kernel.name}-${ + lib.replaceString "aarch64" "arm64" stdenv.targetPlatform.parsed.cpu.name + }" + '' + + '' + chmod -R u+w app/xulrunner/ - ./app/scripts/dir_build + build_dir=$(mktemp -d) + ./app/scripts/prepare_build -s ./build -o "$build_dir" -c release + ./app/build.sh -d "$build_dir" -c release -s \ + ${ + if stdenv.targetPlatform.isDarwin then "-p m" else "-p l -a ${zoteroArch stdenv.targetPlatform}" + } - runHook postBuild - ''; + runHook postBuild + ''; inherit doCheck; # Build with test support if `doCheck` is enabled. From 96a484e28e9b210ec25b50c619344541aac69dee Mon Sep 17 00:00:00 2001 From: Mynacol Date: Thu, 21 May 2026 20:53:00 +0000 Subject: [PATCH 2/2] zotero: Fix build on x86_64-darwin When setting a non-`source` update channel, the build fails on x86_64-darwin. The build fails with: ``` source not found twice in ChannelPrefs source stringWithCString:encoding: ``` Which definitely means it is caused by the strings command here. When manually executing the strings command on the file, I can repeat getting only one `source` result on x86 mac, while getting two on arm64 or linux. After digging around, I tried with the flag `-arch all`, and both `source` values are found on x86 mac. Full command: `strings -n 3 -arch all $binary`. Also reported to upstream in https://github.com/zotero/zotero/pull/5926 --- pkgs/by-name/zo/zotero/fix-x86_64-darwin.patch | 13 +++++++++++++ pkgs/by-name/zo/zotero/package.nix | 1 + 2 files changed, 14 insertions(+) create mode 100644 pkgs/by-name/zo/zotero/fix-x86_64-darwin.patch diff --git a/pkgs/by-name/zo/zotero/fix-x86_64-darwin.patch b/pkgs/by-name/zo/zotero/fix-x86_64-darwin.patch new file mode 100644 index 000000000000..e8ffe53513a7 --- /dev/null +++ b/pkgs/by-name/zo/zotero/fix-x86_64-darwin.patch @@ -0,0 +1,13 @@ +diff --git a/app/mac/set-channel-prefs-channel b/app/mac/set-channel-prefs-channel +index 2431837584..ab85d7e5c0 100755 +--- a/app/mac/set-channel-prefs-channel ++++ b/app/mac/set-channel-prefs-channel +@@ -19,7 +19,7 @@ binary=$1 + from_channel=$2 + to_channel=$3 + # `strings` has a 4-character minimum by default, but we need 3 for 'dev' +-strings_cmd="strings -n 3" ++strings_cmd="strings -n 3 -arch all" + + if [ ${#to_channel} -gt 7 ]; then + echo "Channel length cannot exceed 7 characters -- aborting" >&2 diff --git a/pkgs/by-name/zo/zotero/package.nix b/pkgs/by-name/zo/zotero/package.nix index b9cbdf0a28b0..e36aa85c2d72 100644 --- a/pkgs/by-name/zo/zotero/package.nix +++ b/pkgs/by-name/zo/zotero/package.nix @@ -193,6 +193,7 @@ buildNpmPackage (finalAttrs: { ./js-build-fixes.patch ./avoid-xulrunner-fetch.patch ./build-fixes.patch + ./fix-x86_64-darwin.patch ]; postPatch = ''