From ed52a4493459ee51f9e8d0bf31b707b5a8598693 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Wed, 25 May 2022 17:47:56 +0200 Subject: [PATCH] libreoffice: general darwin improvements - throw error if platform is not supported - fix wrong pre/postInstallPhase hook -> pre/postInstall - switch to stdenvNoCC because we don't build anything - run all phases by default - wrap binary using `open -na $out/Applications/${appName} --args "$@"` --- .../office/libreoffice/darwin/darwin.nix | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/office/libreoffice/darwin/darwin.nix b/pkgs/applications/office/libreoffice/darwin/darwin.nix index 9ac615486ab5..73602d3e317b 100644 --- a/pkgs/applications/office/libreoffice/darwin/darwin.nix +++ b/pkgs/applications/office/libreoffice/darwin/darwin.nix @@ -1,4 +1,4 @@ -{ stdenv +{ stdenvNoCC , lib , fetchurl , undmg @@ -7,6 +7,7 @@ let appName = "LibreOffice.app"; + scriptName = "soffice"; version = "7.2.5"; baseUrl = "https://download.documentfoundation.org/libreoffice/stable"; dist = { @@ -25,25 +26,27 @@ let }; }; in -stdenv.mkDerivation rec { +stdenvNoCC.mkDerivation { inherit version; pname = "libreoffice"; src = fetchurl { - inherit (dist."${stdenv.hostPlatform.system}") url sha256; + inherit (dist.${stdenvNoCC.hostPlatform.system} or + (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}")) url sha256; }; nativeBuildInputs = [ undmg ]; sourceRoot = "${appName}"; - dontPatch = true; - dontConfigure = true; - dontBuild = true; installPhase = '' - runHook preInstallPhase + runHook preInstall mkdir -p $out/{Applications/${appName},bin} cp -R . $out/Applications/${appName} - ln -s $out/Applications/${appName}/Contents/MacOS/soffice $out/bin - runHook postInstallPhase + cat > $out/bin/${scriptName} << EOF + #!${stdenvNoCC.shell} + open -na $out/Applications/${appName} --args "$@" + EOF + chmod +x $out/bin/${scriptName} + runHook postInstall ''; passthru.updateScript = @@ -63,7 +66,7 @@ stdenv.mkDerivation rec { set -o errexit set -o nounset set -o pipefail - + # reset version first so that both platforms are always updated and in sync update-source-version libreoffice 0 ${nullHash} --system=aarch64-darwin update-source-version libreoffice ${newVersion} ${newAarch64Sha256} --system=aarch64-darwin