From a0c617a0a9f6f4c885a3411043c87f9cf30df9ca Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 16 Jul 2024 00:01:23 +0200 Subject: [PATCH 1/3] appflowy: add darwin platform --- pkgs/applications/office/appflowy/default.nix | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/office/appflowy/default.nix b/pkgs/applications/office/appflowy/default.nix index 830f6c52bee4..599166c1de41 100644 --- a/pkgs/applications/office/appflowy/default.nix +++ b/pkgs/applications/office/appflowy/default.nix @@ -11,20 +11,34 @@ , libnotify }: +let + dist = rec { + x86_64-linux = { + urlSuffix = "linux-x86_64.tar.gz"; + hash = "sha256-PVlHPjr6aUkTp9x4MVC8cgebmdaUQXX6eV0/LfAmiJc="; + }; + x86_64-darwin = { + urlSuffix = "macos-universal.zip"; + hash = "sha256-gx+iMo2611uoR549gpBoHlp2h6zQtugPZnU9qbH6VIQ="; + }; + aarch64-darwin = x86_64-darwin; + }."${stdenv.hostPlatform.system}"; +in stdenv.mkDerivation rec { pname = "appflowy"; version = "0.6.4"; src = fetchzip { - url = "https://github.com/AppFlowy-IO/appflowy/releases/download/${version}/AppFlowy-${version}-linux-x86_64.tar.gz"; - hash = "sha256-PVlHPjr6aUkTp9x4MVC8cgebmdaUQXX6eV0/LfAmiJc="; + url = "https://github.com/AppFlowy-IO/appflowy/releases/download/${version}/AppFlowy-${version}-${dist.urlSuffix}"; + inherit (dist) hash; stripRoot = false; }; nativeBuildInputs = [ - autoPatchelfHook makeWrapper copyDesktopItems + ] ++ lib.optionals stdenv.isLinux [ + autoPatchelfHook ]; buildInputs = [ @@ -36,7 +50,7 @@ stdenv.mkDerivation rec { dontBuild = true; dontConfigure = true; - installPhase = '' + installPhase = lib.optionalString stdenv.isLinux '' runHook preInstall cd AppFlowy/ @@ -50,17 +64,26 @@ stdenv.mkDerivation rec { # Copy icon install -Dm444 data/flutter_assets/assets/images/flowy_logo.svg $out/share/icons/hicolor/scalable/apps/appflowy.svg + runHook postInstall + '' + lib.optionalString stdenv.isDarwin '' + runHook preInstall + + mkdir -p $out/{Applications,bin} + cp -r ./AppFlowy.app $out/Applications/ + runHook postInstall ''; - preFixup = '' + preFixup = lib.optionalString stdenv.isLinux '' # Add missing libraries to appflowy using the ones it comes with makeWrapper $out/opt/AppFlowy $out/bin/appflowy \ --set LD_LIBRARY_PATH "$out/opt/lib/" \ --prefix PATH : "${lib.makeBinPath [ xdg-user-dirs ]}" + '' + lib.optionalString stdenv.isDarwin '' + makeWrapper $out/Applications/AppFlowy.app/Contents/MacOS/AppFlowy $out/bin/appflowy ''; - desktopItems = [ + desktopItems = lib.optionals stdenv.isLinux [ (makeDesktopItem { name = pname; desktopName = "AppFlowy"; @@ -78,7 +101,7 @@ stdenv.mkDerivation rec { license = licenses.agpl3Only; changelog = "https://github.com/AppFlowy-IO/appflowy/releases/tag/${version}"; maintainers = with maintainers; [ darkonion0 ]; - platforms = [ "x86_64-linux" ]; + platforms = [ "x86_64-linux" ] ++ platforms.darwin; mainProgram = "appflowy"; }; } From 0e4dbceba01e62f02eba96cd9905984f3e0240b8 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 16 Jul 2024 00:04:12 +0200 Subject: [PATCH 2/3] appflowy: modernize --- pkgs/applications/office/appflowy/default.nix | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/pkgs/applications/office/appflowy/default.nix b/pkgs/applications/office/appflowy/default.nix index 599166c1de41..4f2abef92bae 100644 --- a/pkgs/applications/office/appflowy/default.nix +++ b/pkgs/applications/office/appflowy/default.nix @@ -1,4 +1,4 @@ -{ stdenv +{ stdenvNoCC , lib , fetchzip , autoPatchelfHook @@ -22,14 +22,14 @@ let hash = "sha256-gx+iMo2611uoR549gpBoHlp2h6zQtugPZnU9qbH6VIQ="; }; aarch64-darwin = x86_64-darwin; - }."${stdenv.hostPlatform.system}"; + }."${stdenvNoCC.hostPlatform.system}"; in -stdenv.mkDerivation rec { +stdenvNoCC.mkDerivation (finalAttrs: { pname = "appflowy"; version = "0.6.4"; src = fetchzip { - url = "https://github.com/AppFlowy-IO/appflowy/releases/download/${version}/AppFlowy-${version}-${dist.urlSuffix}"; + url = "https://github.com/AppFlowy-IO/appflowy/releases/download/${finalAttrs.version}/AppFlowy-${finalAttrs.version}-${dist.urlSuffix}"; inherit (dist) hash; stripRoot = false; }; @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ makeWrapper copyDesktopItems - ] ++ lib.optionals stdenv.isLinux [ + ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ]; @@ -50,13 +50,12 @@ stdenv.mkDerivation rec { dontBuild = true; dontConfigure = true; - installPhase = lib.optionalString stdenv.isLinux '' + installPhase = lib.optionalString stdenvNoCC.isLinux '' runHook preInstall cd AppFlowy/ - mkdir -p $out/opt/ - mkdir -p $out/bin/ + mkdir -p $out/{bin,opt} # Copy archive contents to the outpout directory cp -r ./* $out/opt/ @@ -65,7 +64,7 @@ stdenv.mkDerivation rec { install -Dm444 data/flutter_assets/assets/images/flowy_logo.svg $out/share/icons/hicolor/scalable/apps/appflowy.svg runHook postInstall - '' + lib.optionalString stdenv.isDarwin '' + '' + lib.optionalString stdenvNoCC.isDarwin '' runHook preInstall mkdir -p $out/{Applications,bin} @@ -74,20 +73,20 @@ stdenv.mkDerivation rec { runHook postInstall ''; - preFixup = lib.optionalString stdenv.isLinux '' + preFixup = lib.optionalString stdenvNoCC.isLinux '' # Add missing libraries to appflowy using the ones it comes with makeWrapper $out/opt/AppFlowy $out/bin/appflowy \ --set LD_LIBRARY_PATH "$out/opt/lib/" \ --prefix PATH : "${lib.makeBinPath [ xdg-user-dirs ]}" - '' + lib.optionalString stdenv.isDarwin '' + '' + lib.optionalString stdenvNoCC.isDarwin '' makeWrapper $out/Applications/AppFlowy.app/Contents/MacOS/AppFlowy $out/bin/appflowy ''; - desktopItems = lib.optionals stdenv.isLinux [ + desktopItems = lib.optionals stdenvNoCC.isLinux [ (makeDesktopItem { - name = pname; + name = "appflowy"; desktopName = "AppFlowy"; - comment = meta.description; + comment = finalAttrs.meta.description; exec = "appflowy"; icon = "appflowy"; categories = [ "Office" ]; @@ -99,9 +98,9 @@ stdenv.mkDerivation rec { homepage = "https://www.appflowy.io/"; sourceProvenance = with sourceTypes; [ binaryNativeCode ]; license = licenses.agpl3Only; - changelog = "https://github.com/AppFlowy-IO/appflowy/releases/tag/${version}"; + changelog = "https://github.com/AppFlowy-IO/appflowy/releases/tag/${finalAttrs.version}"; maintainers = with maintainers; [ darkonion0 ]; platforms = [ "x86_64-linux" ] ++ platforms.darwin; mainProgram = "appflowy"; }; -} +}) From 4767d299767f0e0e26373c6d50f9179990939e33 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 16 Jul 2024 00:05:23 +0200 Subject: [PATCH 3/3] appflowy: format using nixfmt --- pkgs/applications/office/appflowy/default.nix | 101 +++++++++--------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/pkgs/applications/office/appflowy/default.nix b/pkgs/applications/office/appflowy/default.nix index 4f2abef92bae..4d5e23b12205 100644 --- a/pkgs/applications/office/appflowy/default.nix +++ b/pkgs/applications/office/appflowy/default.nix @@ -1,28 +1,31 @@ -{ stdenvNoCC -, lib -, fetchzip -, autoPatchelfHook -, makeWrapper -, copyDesktopItems -, makeDesktopItem -, gtk3 -, xdg-user-dirs -, keybinder3 -, libnotify +{ + stdenvNoCC, + lib, + fetchzip, + autoPatchelfHook, + makeWrapper, + copyDesktopItems, + makeDesktopItem, + gtk3, + xdg-user-dirs, + keybinder3, + libnotify, }: let - dist = rec { - x86_64-linux = { - urlSuffix = "linux-x86_64.tar.gz"; - hash = "sha256-PVlHPjr6aUkTp9x4MVC8cgebmdaUQXX6eV0/LfAmiJc="; - }; - x86_64-darwin = { - urlSuffix = "macos-universal.zip"; - hash = "sha256-gx+iMo2611uoR549gpBoHlp2h6zQtugPZnU9qbH6VIQ="; - }; - aarch64-darwin = x86_64-darwin; - }."${stdenvNoCC.hostPlatform.system}"; + dist = + rec { + x86_64-linux = { + urlSuffix = "linux-x86_64.tar.gz"; + hash = "sha256-PVlHPjr6aUkTp9x4MVC8cgebmdaUQXX6eV0/LfAmiJc="; + }; + x86_64-darwin = { + urlSuffix = "macos-universal.zip"; + hash = "sha256-gx+iMo2611uoR549gpBoHlp2h6zQtugPZnU9qbH6VIQ="; + }; + aarch64-darwin = x86_64-darwin; + } + ."${stdenvNoCC.hostPlatform.system}"; in stdenvNoCC.mkDerivation (finalAttrs: { pname = "appflowy"; @@ -37,9 +40,7 @@ stdenvNoCC.mkDerivation (finalAttrs: { nativeBuildInputs = [ makeWrapper copyDesktopItems - ] ++ lib.optionals stdenvNoCC.isLinux [ - autoPatchelfHook - ]; + ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ]; buildInputs = [ gtk3 @@ -50,37 +51,41 @@ stdenvNoCC.mkDerivation (finalAttrs: { dontBuild = true; dontConfigure = true; - installPhase = lib.optionalString stdenvNoCC.isLinux '' - runHook preInstall + installPhase = + lib.optionalString stdenvNoCC.isLinux '' + runHook preInstall - cd AppFlowy/ + cd AppFlowy/ - mkdir -p $out/{bin,opt} + mkdir -p $out/{bin,opt} - # Copy archive contents to the outpout directory - cp -r ./* $out/opt/ + # Copy archive contents to the outpout directory + cp -r ./* $out/opt/ - # Copy icon - install -Dm444 data/flutter_assets/assets/images/flowy_logo.svg $out/share/icons/hicolor/scalable/apps/appflowy.svg + # Copy icon + install -Dm444 data/flutter_assets/assets/images/flowy_logo.svg $out/share/icons/hicolor/scalable/apps/appflowy.svg - runHook postInstall - '' + lib.optionalString stdenvNoCC.isDarwin '' - runHook preInstall + runHook postInstall + '' + + lib.optionalString stdenvNoCC.isDarwin '' + runHook preInstall - mkdir -p $out/{Applications,bin} - cp -r ./AppFlowy.app $out/Applications/ + mkdir -p $out/{Applications,bin} + cp -r ./AppFlowy.app $out/Applications/ - runHook postInstall - ''; + runHook postInstall + ''; - preFixup = lib.optionalString stdenvNoCC.isLinux '' - # Add missing libraries to appflowy using the ones it comes with - makeWrapper $out/opt/AppFlowy $out/bin/appflowy \ - --set LD_LIBRARY_PATH "$out/opt/lib/" \ - --prefix PATH : "${lib.makeBinPath [ xdg-user-dirs ]}" - '' + lib.optionalString stdenvNoCC.isDarwin '' - makeWrapper $out/Applications/AppFlowy.app/Contents/MacOS/AppFlowy $out/bin/appflowy - ''; + preFixup = + lib.optionalString stdenvNoCC.isLinux '' + # Add missing libraries to appflowy using the ones it comes with + makeWrapper $out/opt/AppFlowy $out/bin/appflowy \ + --set LD_LIBRARY_PATH "$out/opt/lib/" \ + --prefix PATH : "${lib.makeBinPath [ xdg-user-dirs ]}" + '' + + lib.optionalString stdenvNoCC.isDarwin '' + makeWrapper $out/Applications/AppFlowy.app/Contents/MacOS/AppFlowy $out/bin/appflowy + ''; desktopItems = lib.optionals stdenvNoCC.isLinux [ (makeDesktopItem {