summary refs log tree commit diff
path: root/pkgs/applications/office/libreoffice/darwin/darwin.nix
blob: 7b2f89cf0a5c951555b06f1b727767bef2b6ff55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ stdenv
, lib
, fetchurl
, undmg
, writeScript
}:

let
  appName = "LibreOffice.app";
  version = "7.2.5";
  baseUrl = "https://download.documentfoundation.org/libreoffice/stable";
  dist = {
    aarch64-darwin = rec {
      arch = "aarch64";
      archSuffix = arch;
      url = "${baseUrl}/${version}/mac/${arch}/LibreOffice_${version}_MacOS_${archSuffix}.dmg";
      sha256 = "bdbcb9a98211f866ca089d440aebcd1d313aa99e8ab4104aae4e65ea3cee74ca";
    };

    x86_64-darwin = rec {
      arch = "x86_64";
      archSuffix = "x86-64";
      url = "${baseUrl}/${version}/mac/${arch}/LibreOffice_${version}_MacOS_${archSuffix}.dmg";
      sha256 = "0b7ef18ed08341ac6c15339fe9a161ad17f6b469009d987cfc7d50c628d12a4e";
    };
  };
in
stdenv.mkDerivation rec {
  inherit version;
  pname = "libreoffice";
  src = fetchurl {
    inherit (dist."${stdenv.hostPlatform.system}") url sha256;
  };

  nativeBuildInputs = [ undmg ];
  sourceRoot = "${appName}";
  dontPatch = true;
  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstallPhase
    mkdir -p $out/{Applications/${appName},bin}
    cp -R . $out/Applications/${appName}
    ln -s $out/Applications/${appName}/Contents/MacOS/soffice $out/bin
    runHook postInstallPhase
  '';

  passthru.updateScript =
    let
      inherit (import ./update-utils.nix { inherit lib; }) getLatestStableVersion getSha256 nullHash;
      newVersion = getLatestStableVersion;
    in
    writeScript "update-libreoffice.sh"
    ''
      #!/usr/bin/env nix-shell
      #!nix-shell -i bash -p common-updater-scripts
      set -o errexit
      set -o nounset
      set -o pipefail
      update-source-version libreoffice ${newVersion} ${getSha256 dist."aarch64-darwin".url version newVersion} --system=aarch64-darwin
      update-source-version libreoffice 0 ${nullHash} --system=x86_64-darwin
      update-source-version libreoffice ${newVersion} ${getSha256 dist."x86_64-darwin".url version newVersion} --system=x86_64-darwin
    '';

  meta = with lib; {
    description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org";
    homepage = "https://libreoffice.org/";
    license = licenses.lgpl3;
    maintainers = with maintainers; [ tricktron ];
    platforms = [ "aarch64-darwin" "x86_64-darwin" ];
  };
}