Merge pull request #5937 from ttuegel/zotero

zotero: build standalone from cross-platform XPI with latest firefox

+49 -27
+49 -27
pkgs/applications/office/zotero/default.nix
··· 1 - { stdenv, fetchurl, useGoldLinker, bash, callPackage, gnome, xlibs }: 2 - 3 - assert (stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux"); 4 - 1 + { stdenv, fetchurl, bash, firefox, perl, unzipNLS, xlibs }: 5 2 6 3 let 7 - /* Zotero always has a hard upper bound on its firefox/xulrunner dependency. 8 - * Use private version of firefox to prevent breakage when the system 9 - * packages are updated. Please update this dependency whenever zotero is 10 - * updated; it should be as simple as copying the system firefox expression 11 - * into place. 12 - */ 13 4 14 - firefox = callPackage ./firefox-bin { 15 - gconf = gnome.GConf; 16 - inherit (gnome) libgnome libgnomeui; 17 - inherit (xlibs) libX11 libXScrnSaver libXcomposite libXdamage libXext 18 - libXfixes libXinerama libXrender libXt; 5 + xpi = fetchurl { 6 + url = "https://download.zotero.org/extension/zotero-${version}.xpi"; 7 + sha256 = "0di6d3s95fmb4pmghl4ix7lq5pmqrddd4y8dmnpsrhbj0awzxw3s"; 19 8 }; 20 9 21 - # Please update the firefox dependency when zotero is updated! 22 - version = "4.0.23"; 23 - arch = if stdenv.system == "x86_64-linux" 24 - then "linux-x86_64" 25 - else "linux-i686"; 10 + version = "4.0.25.2"; 11 + 26 12 in 27 13 stdenv.mkDerivation { 28 14 name = "zotero-${version}"; 15 + inherit version; 29 16 30 17 src = fetchurl { 31 - url = "https://download.zotero.org/standalone/${version}/Zotero-${version}_${arch}.tar.bz2"; 32 - sha256 = if stdenv.system == "x86_64-linux" 33 - then "1fz5xn69vapfw8d20207zr9p5r1h9x5kahh334pl2dn1h8il0sm8" 34 - else "1kmsvvg2lh881rzy3rxbigzivixjamyrwf5x7vmn1kzhvsvifrng"; 18 + url = "https://github.com/zotero/zotero-standalone-build/archive/${version}.tar.gz"; 19 + sha256 = "0wjmpz7fy3ij8q22s885kv8xrgc3yx7f1mwrvb6lnpc2xl54rl5g"; 35 20 }; 36 21 37 - # Strip the bundled xulrunner 38 - prePatch = ''rm -fr run-zotero.sh zotero xulrunner/''; 22 + nativeBuildInputs = [ perl unzipNLS ]; 39 23 40 24 inherit bash firefox; 25 + 26 + phases = "unpackPhase installPhase fixupPhase"; 27 + 41 28 installPhase = '' 42 29 mkdir -p "$out/libexec/zotero" 43 - cp -vR * "$out/libexec/zotero/" 30 + unzip "${xpi}" -d "$out/libexec/zotero" 31 + 32 + BUILDID=`date +%Y%m%d` 33 + GECKO_VERSION="${firefox.passthru.version}" 34 + UPDATE_CHANNEL="default" 35 + 36 + # Copy branding 37 + cp -R assets/branding "$out/libexec/zotero/chrome/branding" 38 + 39 + # Adjust chrome.manifest 40 + echo "" >> "$out/libexec/zotero/chrome.manifest" 41 + cat assets/chrome.manifest >> "$out/libexec/zotero/chrome.manifest" 42 + 43 + # Copy updater.ini 44 + cp assets/updater.ini "$out/libexec/zotero" 45 + 46 + # Adjust connector pref 47 + perl -pi -e 's/pref\("extensions\.zotero\.httpServer\.enabled", false\);/pref("extensions.zotero.httpServer.enabled", true);/g' "$out/libexec/zotero/defaults/preferences/zotero.js" 48 + perl -pi -e 's/pref\("extensions\.zotero\.connector\.enabled", false\);/pref("extensions.zotero.connector.enabled", true);/g' "$out/libexec/zotero/defaults/preferences/zotero.js" 49 + 50 + # Copy icons 51 + cp -r assets/icons "$out/libexec/zotero/chrome/icons" 52 + 53 + # Copy application.ini and modify 54 + cp assets/application.ini "$out/libexec/zotero/application.ini" 55 + perl -pi -e "s/{{VERSION}}/$version/" "$out/libexec/zotero/application.ini" 56 + perl -pi -e "s/{{BUILDID}}/$BUILDID/" "$out/libexec/zotero/application.ini" 57 + perl -pi -e "s/^MaxVersion.*\$/MaxVersion=$GECKO_VERSION/" "$out/libexec/zotero/application.ini" 58 + 59 + # Copy prefs.js and modify 60 + cp assets/prefs.js "$out/libexec/zotero/defaults/preferences" 61 + perl -pi -e 's/pref\("app\.update\.channel", "[^"]*"\);/pref\("app\.update\.channel", "'"$UPDATE_CHANNEL"'");/' "$out/libexec/zotero/defaults/preferences/prefs.js" 62 + perl -pi -e 's/%GECKO_VERSION%/'"$GECKO_VERSION"'/g' "$out/libexec/zotero/defaults/preferences/prefs.js" 63 + 64 + # Add platform-specific standalone assets 65 + cp -R assets/unix "$out/libexec/zotero" 44 66 45 67 mkdir -p "$out/bin" 46 68 substituteAll "${./zotero.sh}" "$out/bin/zotero"