From 9be52e31b7d32565e4f4fc348840c4e4600ad9d7 Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Fri, 14 Jun 2024 19:39:31 +0200 Subject: [PATCH] ride: add darwin support --- pkgs/by-name/ri/ride/package.nix | 55 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/pkgs/by-name/ri/ride/package.nix b/pkgs/by-name/ri/ride/package.nix index 52adbc5387d0..25d18248d5bb 100644 --- a/pkgs/by-name/ri/ride/package.nix +++ b/pkgs/by-name/ri/ride/package.nix @@ -12,6 +12,7 @@ copyDesktopItems, makeDesktopItem, electron, + darwin, }: let @@ -31,6 +32,8 @@ let }; platformInfo = platformInfos.${stdenv.system}; + + electronDist = electron + (if stdenv.isDarwin then "/Applications" else "/libexec/electron"); in buildNpmPackage rec { pname = "ride"; @@ -83,22 +86,33 @@ buildNpmPackage rec { popd ''; - nativeBuildInputs = [ - zip - makeWrapper - copyDesktopItems - ]; + nativeBuildInputs = + [ + zip + makeWrapper + ] + ++ lib.optionals (!stdenv.isDarwin) [ copyDesktopItems ] + ++ lib.optionals stdenv.isDarwin [ darwin.cctools ]; env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; + # Fix error: no member named 'aligned_alloc' in the global namespace + env.NIX_CFLAGS_COMPILE = lib.optionalString ( + stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11.0" + ) "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1"; + npmBuildFlags = platformInfo.buildCmd; # This package uses electron-packager instead of electron-builder # Here, we create a local cache of electron zip-files, so electron-packager can copy from it postConfigure = '' mkdir local-cache - cp -r --no-preserve=all ${electron}/libexec/electron electron - pushd electron + + # electron files need to be writable on Darwin + cp -r ${electronDist} electron-dist + chmod -R u+w electron-dist + + pushd electron-dist zip -qr ../local-cache/electron-v${electron.version}-${platformInfo.zipSuffix}.zip * popd ''; @@ -106,19 +120,27 @@ buildNpmPackage rec { installPhase = '' runHook preInstall - install -Dm644 D.png $out/share/icons/hicolor/64x64/apps/ride.png - install -Dm644 D.svg $out/share/icons/hicolor/scalable/apps/ride.svg - pushd _/ride*/* install -Dm644 ThirdPartyNotices.txt -t $out/share/doc/ride - mkdir -p $out/share/ride - cp -r locales resources{,.pak} $out/share/ride - makeWrapper ${lib.getExe electron} $out/bin/ride \ - --add-flags $out/share/ride/resources/app.asar \ - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ - --inherit-argv0 + ${lib.optionalString (!stdenv.isDarwin) '' + install -Dm644 $src/D.png $out/share/icons/hicolor/64x64/apps/ride.png + install -Dm644 $src/D.svg $out/share/icons/hicolor/scalable/apps/ride.svg + + mkdir -p $out/share/ride + cp -r locales resources{,.pak} $out/share/ride + makeWrapper ${lib.getExe electron} $out/bin/ride \ + --add-flags $out/share/ride/resources/app.asar \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ + --inherit-argv0 + ''} + + ${lib.optionalString stdenv.isDarwin '' + mkdir -p $out/Applications + cp -r Ride-*.app $out/Applications + makeWrapper $out/Applications/Ride-*.app/Contents/MacOS/Ride-* $out/bin/ride + ''} popd @@ -141,7 +163,6 @@ buildNpmPackage rec { ]; meta = { - broken = stdenv.isDarwin; changelog = "https://github.com/Dyalog/ride/releases/tag/${src.rev}"; description = "Remote IDE for Dyalog APL"; homepage = "https://github.com/Dyalog/ride";