nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 154 lines 4.1 kB view raw
1{ 2 lib, 3 stdenv, 4 buildNpmPackage, 5 fetchFromGitHub, 6 fetchpatch, 7 replaceVars, 8 jq, 9 moreutils, 10 zip, 11 makeWrapper, 12 copyDesktopItems, 13 makeDesktopItem, 14 electron, 15}: 16 17buildNpmPackage rec { 18 pname = "ride"; 19 version = "4.5.4097"; 20 21 src = fetchFromGitHub { 22 owner = "Dyalog"; 23 repo = "ride"; 24 tag = "v${version}"; 25 hash = "sha256-xR+HVC1JVrPkgPhIJZxdTVG52+QbanmD1c/uO5l84oc="; 26 }; 27 28 npmDepsHash = "sha256-C8puCz/w5xkaR4QVXXOdoO8n4gNZrRWMcB9/f1DcuMc="; 29 30 patches = [ 31 # Adds support for electron versions >=28 32 (fetchpatch { 33 name = "bump-electron-version.patch"; 34 url = "https://github.com/Dyalog/ride/commit/de42ebbd5036cfe0c7e6604296e87cc57ac9d365.patch"; 35 hash = "sha256-5iKSNcxOOo2fKNvy3Rv+AlH3psYhLWLWUY0l8M6mAD4="; 36 }) 37 38 # Fix info in the "about" page, enable asar, add option to build for the detected system 39 (replaceVars ./mk.patch { 40 inherit version; 41 }) 42 43 # would not build with nodejs_22 and above without this 44 ./update-nan.patch 45 ]; 46 47 postPatch = '' 48 # Remove spectron (it would download electron-chromedriver binaries) 49 ${jq}/bin/jq 'del(.devDependencies.spectron)' package.json | ${moreutils}/bin/sponge package.json 50 51 pushd style 52 53 # Remove non-deterministic glob ordering 54 sed -i "/\*\*/d" layout.less light-theme.less dark-theme.less 55 56 # Individually include all files that were previously globbed 57 shopt -s globstar 58 for file in less/layout/**/*.less; do 59 echo "@import '$file';" >> layout.less 60 done 61 for file in less/colour/**/*.less; do 62 echo "@import '$file';" >> light-theme.less 63 echo "@import '$file';" >> dark-theme.less 64 done 65 shopt -u globstar 66 67 popd 68 ''; 69 70 nativeBuildInputs = [ 71 zip 72 makeWrapper 73 ] 74 ++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ]; 75 76 env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; 77 78 # our patch adds the platform detecting build option 79 npmBuildFlags = "self"; 80 81 postConfigure = '' 82 # electron files need to be writable on Darwin 83 cp -r ${electron.dist} electron-dist 84 chmod -R u+w electron-dist 85 86 pushd electron-dist 87 zip -0Xqr ../electron.zip * 88 popd 89 90 rm -r electron-dist 91 92 # force electron-packager to use our electron instead of downloading it, even if it is a different version 93 substituteInPlace node_modules/electron-packager/src/index.js \ 94 --replace-fail 'await this.getElectronZipPath(downloadOpts)' '"electron.zip"' 95 ''; 96 97 installPhase = '' 98 runHook preInstall 99 100 pushd _/ride*/* 101 102 install -Dm644 ThirdPartyNotices.txt -t $out/share/doc/ride 103 104 ${lib.optionalString stdenv.hostPlatform.isLinux '' 105 install -Dm644 $src/D.png $out/share/icons/hicolor/64x64/apps/ride.png 106 install -Dm644 $src/D.svg $out/share/icons/hicolor/scalable/apps/ride.svg 107 108 mkdir -p $out/share/ride 109 cp -r locales resources{,.pak} $out/share/ride 110 makeShellWrapper ${lib.getExe electron} $out/bin/ride \ 111 --add-flags $out/share/ride/resources/app.asar \ 112 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ 113 --inherit-argv0 114 ''} 115 116 ${lib.optionalString stdenv.hostPlatform.isDarwin '' 117 mkdir -p $out/Applications 118 cp -r Ride-*.app $out/Applications 119 makeWrapper $out/Applications/Ride-*.app/Contents/MacOS/Ride-* $out/bin/ride 120 ''} 121 122 popd 123 124 runHook postInstall 125 ''; 126 127 desktopItems = [ 128 (makeDesktopItem { 129 name = "ride"; 130 exec = "ride"; 131 icon = "ride"; 132 desktopName = "RIDE"; 133 categories = [ 134 "Development" 135 "IDE" 136 ]; 137 comment = meta.description; 138 terminal = false; 139 }) 140 ]; 141 142 meta = { 143 changelog = "https://github.com/Dyalog/ride/releases/tag/v${version}"; 144 description = "Remote IDE for Dyalog APL"; 145 homepage = "https://github.com/Dyalog/ride"; 146 license = lib.licenses.mit; 147 mainProgram = "ride"; 148 maintainers = with lib.maintainers; [ 149 tomasajt 150 markus1189 151 ]; 152 platforms = electron.meta.platforms; 153 }; 154}