Merge pull request #313397 from TomaSajt/ride-darwin

ride: add darwin support
This commit is contained in:
Sandro 2024-07-02 20:24:09 +02:00 committed by GitHub
commit 0088f2063f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@
copyDesktopItems, copyDesktopItems,
makeDesktopItem, makeDesktopItem,
electron, electron,
darwin,
}: }:
let let
@ -31,6 +32,8 @@ let
}; };
platformInfo = platformInfos.${stdenv.system}; platformInfo = platformInfos.${stdenv.system};
electronDist = electron + (if stdenv.isDarwin then "/Applications" else "/libexec/electron");
in in
buildNpmPackage rec { buildNpmPackage rec {
pname = "ride"; pname = "ride";
@ -83,22 +86,33 @@ buildNpmPackage rec {
popd popd
''; '';
nativeBuildInputs = [ nativeBuildInputs =
zip [
makeWrapper zip
copyDesktopItems makeWrapper
]; ]
++ lib.optionals (!stdenv.isDarwin) [ copyDesktopItems ]
++ lib.optionals stdenv.isDarwin [ darwin.cctools ];
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; 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; npmBuildFlags = platformInfo.buildCmd;
# This package uses electron-packager instead of electron-builder # 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 # Here, we create a local cache of electron zip-files, so electron-packager can copy from it
postConfigure = '' postConfigure = ''
mkdir local-cache 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 * zip -qr ../local-cache/electron-v${electron.version}-${platformInfo.zipSuffix}.zip *
popd popd
''; '';
@ -106,19 +120,27 @@ buildNpmPackage rec {
installPhase = '' installPhase = ''
runHook preInstall 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*/* pushd _/ride*/*
install -Dm644 ThirdPartyNotices.txt -t $out/share/doc/ride install -Dm644 ThirdPartyNotices.txt -t $out/share/doc/ride
mkdir -p $out/share/ride ${lib.optionalString (!stdenv.isDarwin) ''
cp -r locales resources{,.pak} $out/share/ride install -Dm644 $src/D.png $out/share/icons/hicolor/64x64/apps/ride.png
makeWrapper ${lib.getExe electron} $out/bin/ride \ install -Dm644 $src/D.svg $out/share/icons/hicolor/scalable/apps/ride.svg
--add-flags $out/share/ride/resources/app.asar \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ mkdir -p $out/share/ride
--inherit-argv0 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 popd
@ -141,7 +163,6 @@ buildNpmPackage rec {
]; ];
meta = { meta = {
broken = stdenv.isDarwin;
changelog = "https://github.com/Dyalog/ride/releases/tag/${src.rev}"; changelog = "https://github.com/Dyalog/ride/releases/tag/${src.rev}";
description = "Remote IDE for Dyalog APL"; description = "Remote IDE for Dyalog APL";
homepage = "https://github.com/Dyalog/ride"; homepage = "https://github.com/Dyalog/ride";