Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 85 lines 2.6 kB view raw
1{ 2 stdenvNoCC, 3 lib, 4 fetchurl, 5 undmg, 6 writeScript, 7}: 8 9let 10 appName = "LibreOffice.app"; 11 scriptName = "soffice"; 12 version = "25.2.1"; 13 14 dist = { 15 aarch64-darwin = rec { 16 arch = "aarch64"; 17 archSuffix = arch; 18 url = "https://download.documentfoundation.org/libreoffice/stable/${version}/mac/${arch}/LibreOffice_${version}_MacOS_${archSuffix}.dmg"; 19 sha256 = "d0f8573dfc5d1a858061a9bc7889313cb6837db8a8f1b568d067ca156c03745e"; 20 }; 21 22 x86_64-darwin = rec { 23 arch = "x86_64"; 24 archSuffix = "x86-64"; 25 url = "https://download.documentfoundation.org/libreoffice/stable/${version}/mac/${arch}/LibreOffice_${version}_MacOS_${archSuffix}.dmg"; 26 sha256 = "88746b5e46a72ae964ed2275399ee0fb2a0712f6d93a30b151358ffa0ea8349a"; 27 }; 28 }; 29in 30stdenvNoCC.mkDerivation { 31 inherit version; 32 pname = "libreoffice"; 33 src = fetchurl { 34 inherit 35 (dist.${stdenvNoCC.hostPlatform.system} 36 or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}") 37 ) 38 url 39 sha256 40 ; 41 }; 42 43 nativeBuildInputs = [ undmg ]; 44 sourceRoot = appName; 45 46 installPhase = '' 47 runHook preInstall 48 mkdir -p $out/{Applications/${appName},bin} 49 cp -R . $out/Applications/${appName} 50 cat > $out/bin/${scriptName} << EOF 51 #!${stdenvNoCC.shell} 52 open -na $out/Applications/${appName} --args "\$@" 53 EOF 54 chmod +x $out/bin/${scriptName} 55 runHook postInstall 56 ''; 57 58 passthru.updateScript = 59 let 60 defaultNixFile = builtins.toString ./default.nix; 61 updateNix = builtins.toString ./update.nix; 62 aarch64Url = dist."aarch64-darwin".url; 63 x86_64Url = dist."x86_64-darwin".url; 64 in 65 writeScript "update-libreoffice.sh" '' 66 #!/usr/bin/env nix-shell 67 #!nix-shell -i bash --argstr aarch64Url ${aarch64Url} --argstr x86_64Url ${x86_64Url} --argstr version ${version} ${updateNix} 68 set -eou pipefail 69 70 update-source-version libreoffice-bin $newVersion $newAarch64Sha256 --file=${defaultNixFile} --system=aarch64-darwin --ignore-same-version 71 update-source-version libreoffice-bin $newVersion $newX86_64Sha256 --file=${defaultNixFile} --system=x86_64-darwin --ignore-same-version 72 ''; 73 74 meta = with lib; { 75 description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org"; 76 homepage = "https://libreoffice.org/"; 77 license = licenses.lgpl3; 78 maintainers = with maintainers; [ tricktron ]; 79 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 80 platforms = [ 81 "x86_64-darwin" 82 "aarch64-darwin" 83 ]; 84 }; 85}