ride: refactor and improve electron usage

+55 -44
+35 -8
pkgs/by-name/ri/ride/mk.patch
··· 1 1 diff --git a/mk b/mk 2 - index a5baa0f8..37cac28e 100755 2 + index a5baa0f..4ed2350 100644 3 3 --- a/mk 4 4 +++ b/mk 5 5 @@ -25,7 +25,7 @@ const rm = (x) => { ··· 22 22 }, 23 23 }; 24 24 wf('_/version.js', `D=${JSON.stringify(vi)}`); 25 - @@ -50,6 +50,9 @@ const incl = new RegExp('^$' 26 - + '|^/style($|/(fonts|img)|.*\\.css$)'); 25 + @@ -51,8 +51,7 @@ const incl = new RegExp('^$' 27 26 const pkg = (x, y, f) => { 28 27 rq('electron-packager')({ 28 + dir: '.', 29 + - platform: x, 30 + - arch: y, 29 31 + asar: true, 30 - + electronZipDir: "local-cache", 31 - + electronVersion: "@electron_version@", 32 - dir: '.', 33 - platform: x, 34 - arch: y, 32 + tmpdir: '/tmp/ridebuild', 33 + out: `_/${pj.name}`, 34 + overwrite: true, 35 + @@ -79,8 +78,8 @@ const pkg = (x, y, f) => { 36 + ProductName: 'RIDE', 37 + InternalName: 'RIDE', 38 + }, 39 + - }).then(() => { 40 + - const d = `_/${pj.name}/${pj.productName}-${x}-${y}`; 41 + + }).then(paths => { 42 + + const d = paths[0]; 43 + rm(`${d}/version`); 44 + fs.existsSync(`${d}/LICENSE`) && mv(`${d}/LICENSE`, `${d}/LICENSE.electron`); 45 + generateLicenses(`${d}/ThirdPartyNotices.txt`); 46 + @@ -88,6 +87,7 @@ const pkg = (x, y, f) => { 47 + }, e => f(e)); 48 + }; 49 + 50 + +const self = (f) => { b(e => (e ? f(e) : pkg(undefined, undefined, f))); }; 51 + const l = (f) => { b(e => (e ? f(e) : pkg('linux', 'x64', f))); }; 52 + const w = (f) => { b(e => (e ? f(e) : pkg('win32', 'ia32', f))); }; 53 + const o = (f) => { b(e => (e ? f(e) : pkg('darwin', 'x64', f))); }; 54 + @@ -109,6 +109,7 @@ tasks.ma=ma; tasks.masarm = ma; 55 + tasks.a = a; tasks.arm = a; 56 + tasks.d = d; tasks.dist = d; 57 + tasks.c = c; tasks.clean = c; 58 + +tasks.self = self; 59 + 60 + async.each( 61 + process.argv.length > 2 ? process.argv.slice(2) : ['build'],
+20 -36
pkgs/by-name/ri/ride/package.nix
··· 4 4 buildNpmPackage, 5 5 fetchFromGitHub, 6 6 fetchpatch, 7 - substituteAll, 7 + replaceVars, 8 8 jq, 9 9 moreutils, 10 10 zip, ··· 15 15 cctools, 16 16 }: 17 17 18 - let 19 - platformInfos = { 20 - "x86_64-linux" = { 21 - zipSuffix = "linux-x64"; 22 - buildCmd = "linux"; 23 - }; 24 - "x86_64-darwin" = { 25 - zipSuffix = "darwin-x64"; 26 - buildCmd = "osx"; 27 - }; 28 - "aarch64-darwin" = { 29 - zipSuffix = "darwin-arm64"; 30 - buildCmd = "osxarm"; 31 - }; 32 - }; 33 - 34 - platformInfo = platformInfos.${stdenv.system}; 35 - in 36 18 buildNpmPackage rec { 37 19 pname = "ride"; 38 20 version = "4.5.4097"; ··· 40 22 src = fetchFromGitHub { 41 23 owner = "Dyalog"; 42 24 repo = "ride"; 43 - rev = "v${version}"; 25 + rev = "refs/tags/v${version}"; 44 26 hash = "sha256-xR+HVC1JVrPkgPhIJZxdTVG52+QbanmD1c/uO5l84oc="; 45 27 }; 46 28 ··· 53 35 url = "https://github.com/Dyalog/ride/commit/de42ebbd5036cfe0c7e6604296e87cc57ac9d365.patch"; 54 36 hash = "sha256-5iKSNcxOOo2fKNvy3Rv+AlH3psYhLWLWUY0l8M6mAD4="; 55 37 }) 56 - # Fix info in the "about" page, set electron version, set local-cache as zipdir 57 - (substituteAll { 58 - src = ./mk.patch; 59 - version = version; 60 - electron_version = electron.version; 38 + 39 + # Fix info in the "about" page, enable asar, add option to build for the detected system 40 + (replaceVars ./mk.patch { 41 + inherit version; 61 42 }) 62 43 ]; 63 44 ··· 89 70 zip 90 71 makeWrapper 91 72 ] 92 - ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ copyDesktopItems ] 73 + ++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ] 93 74 ++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools ]; 94 75 95 76 env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; ··· 99 80 stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11.0" 100 81 ) "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1"; 101 82 102 - npmBuildFlags = platformInfo.buildCmd; 83 + # our patch adds the platform detecting build option 84 + npmBuildFlags = "self"; 103 85 104 - # This package uses electron-packager instead of electron-builder 105 - # Here, we create a local cache of electron zip-files, so electron-packager can copy from it 106 86 postConfigure = '' 107 - mkdir local-cache 108 - 109 87 # electron files need to be writable on Darwin 110 88 cp -r ${electron.dist} electron-dist 111 89 chmod -R u+w electron-dist 112 90 113 91 pushd electron-dist 114 - zip -qr ../local-cache/electron-v${electron.version}-${platformInfo.zipSuffix}.zip * 92 + zip -0Xqr ../electron.zip * 115 93 popd 94 + 95 + rm -r electron-dist 96 + 97 + # force electron-packager to use our electron instead of downloading it, even if it is a different version 98 + substituteInPlace node_modules/electron-packager/src/index.js \ 99 + --replace-fail 'await this.getElectronZipPath(downloadOpts)' '"electron.zip"' 116 100 ''; 117 101 118 102 installPhase = '' ··· 122 106 123 107 install -Dm644 ThirdPartyNotices.txt -t $out/share/doc/ride 124 108 125 - ${lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 109 + ${lib.optionalString stdenv.hostPlatform.isLinux '' 126 110 install -Dm644 $src/D.png $out/share/icons/hicolor/64x64/apps/ride.png 127 111 install -Dm644 $src/D.svg $out/share/icons/hicolor/scalable/apps/ride.svg 128 112 129 113 mkdir -p $out/share/ride 130 114 cp -r locales resources{,.pak} $out/share/ride 131 - makeWrapper ${lib.getExe electron} $out/bin/ride \ 115 + makeShellWrapper ${lib.getExe electron} $out/bin/ride \ 132 116 --add-flags $out/share/ride/resources/app.asar \ 133 117 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 134 118 --inherit-argv0 ··· 161 145 ]; 162 146 163 147 meta = { 164 - changelog = "https://github.com/Dyalog/ride/releases/tag/${src.rev}"; 148 + changelog = "https://github.com/Dyalog/ride/releases/tag/v${version}"; 165 149 description = "Remote IDE for Dyalog APL"; 166 150 homepage = "https://github.com/Dyalog/ride"; 167 151 license = lib.licenses.mit; ··· 170 154 tomasajt 171 155 markus1189 172 156 ]; 173 - platforms = lib.attrNames platformInfos; 157 + platforms = electron.meta.platforms; 174 158 }; 175 159 }