tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
ride: refactor and improve electron usage
TomaSajt
1 year ago
e05db846
91bbd392
+55
-44
2 changed files
expand all
collapse all
unified
split
pkgs
by-name
ri
ride
mk.patch
package.nix
+35
-8
pkgs/by-name/ri/ride/mk.patch
···
1
diff --git a/mk b/mk
2
-
index a5baa0f8..37cac28e 100755
3
--- a/mk
4
+++ b/mk
5
@@ -25,7 +25,7 @@ const rm = (x) => {
···
22
},
23
};
24
wf('_/version.js', `D=${JSON.stringify(vi)}`);
25
-
@@ -50,6 +50,9 @@ const incl = new RegExp('^$'
26
-
+ '|^/style($|/(fonts|img)|.*\\.css$)');
27
const pkg = (x, y, f) => {
28
rq('electron-packager')({
0
0
0
29
+ asar: true,
30
-
+ electronZipDir: "local-cache",
31
-
+ electronVersion: "@electron_version@",
32
-
dir: '.',
33
-
platform: x,
34
-
arch: y,
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
diff --git a/mk b/mk
2
+
index a5baa0f..4ed2350 100644
3
--- a/mk
4
+++ b/mk
5
@@ -25,7 +25,7 @@ const rm = (x) => {
···
22
},
23
};
24
wf('_/version.js', `D=${JSON.stringify(vi)}`);
25
+
@@ -51,8 +51,7 @@ const incl = new RegExp('^$'
0
26
const pkg = (x, y, f) => {
27
rq('electron-packager')({
28
+
dir: '.',
29
+
- platform: x,
30
+
- arch: y,
31
+ asar: true,
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
buildNpmPackage,
5
fetchFromGitHub,
6
fetchpatch,
7
-
substituteAll,
8
jq,
9
moreutils,
10
zip,
···
15
cctools,
16
}:
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
buildNpmPackage rec {
37
pname = "ride";
38
version = "4.5.4097";
···
40
src = fetchFromGitHub {
41
owner = "Dyalog";
42
repo = "ride";
43
-
rev = "v${version}";
44
hash = "sha256-xR+HVC1JVrPkgPhIJZxdTVG52+QbanmD1c/uO5l84oc=";
45
};
46
···
53
url = "https://github.com/Dyalog/ride/commit/de42ebbd5036cfe0c7e6604296e87cc57ac9d365.patch";
54
hash = "sha256-5iKSNcxOOo2fKNvy3Rv+AlH3psYhLWLWUY0l8M6mAD4=";
55
})
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;
61
})
62
];
63
···
89
zip
90
makeWrapper
91
]
92
-
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ copyDesktopItems ]
93
++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools ];
94
95
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
···
99
stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11.0"
100
) "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1";
101
102
-
npmBuildFlags = platformInfo.buildCmd;
0
103
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
postConfigure = ''
107
-
mkdir local-cache
108
-
109
# electron files need to be writable on Darwin
110
cp -r ${electron.dist} electron-dist
111
chmod -R u+w electron-dist
112
113
pushd electron-dist
114
-
zip -qr ../local-cache/electron-v${electron.version}-${platformInfo.zipSuffix}.zip *
115
popd
0
0
0
0
0
0
116
'';
117
118
installPhase = ''
···
122
123
install -Dm644 ThirdPartyNotices.txt -t $out/share/doc/ride
124
125
-
${lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
126
install -Dm644 $src/D.png $out/share/icons/hicolor/64x64/apps/ride.png
127
install -Dm644 $src/D.svg $out/share/icons/hicolor/scalable/apps/ride.svg
128
129
mkdir -p $out/share/ride
130
cp -r locales resources{,.pak} $out/share/ride
131
-
makeWrapper ${lib.getExe electron} $out/bin/ride \
132
--add-flags $out/share/ride/resources/app.asar \
133
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
134
--inherit-argv0
···
161
];
162
163
meta = {
164
-
changelog = "https://github.com/Dyalog/ride/releases/tag/${src.rev}";
165
description = "Remote IDE for Dyalog APL";
166
homepage = "https://github.com/Dyalog/ride";
167
license = lib.licenses.mit;
···
170
tomasajt
171
markus1189
172
];
173
-
platforms = lib.attrNames platformInfos;
174
};
175
}
···
4
buildNpmPackage,
5
fetchFromGitHub,
6
fetchpatch,
7
+
replaceVars,
8
jq,
9
moreutils,
10
zip,
···
15
cctools,
16
}:
17
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
18
buildNpmPackage rec {
19
pname = "ride";
20
version = "4.5.4097";
···
22
src = fetchFromGitHub {
23
owner = "Dyalog";
24
repo = "ride";
25
+
rev = "refs/tags/v${version}";
26
hash = "sha256-xR+HVC1JVrPkgPhIJZxdTVG52+QbanmD1c/uO5l84oc=";
27
};
28
···
35
url = "https://github.com/Dyalog/ride/commit/de42ebbd5036cfe0c7e6604296e87cc57ac9d365.patch";
36
hash = "sha256-5iKSNcxOOo2fKNvy3Rv+AlH3psYhLWLWUY0l8M6mAD4=";
37
})
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;
0
42
})
43
];
44
···
70
zip
71
makeWrapper
72
]
73
+
++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ]
74
++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools ];
75
76
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
···
80
stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11.0"
81
) "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1";
82
83
+
# our patch adds the platform detecting build option
84
+
npmBuildFlags = "self";
85
0
0
86
postConfigure = ''
0
0
87
# electron files need to be writable on Darwin
88
cp -r ${electron.dist} electron-dist
89
chmod -R u+w electron-dist
90
91
pushd electron-dist
92
+
zip -0Xqr ../electron.zip *
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"'
100
'';
101
102
installPhase = ''
···
106
107
install -Dm644 ThirdPartyNotices.txt -t $out/share/doc/ride
108
109
+
${lib.optionalString stdenv.hostPlatform.isLinux ''
110
install -Dm644 $src/D.png $out/share/icons/hicolor/64x64/apps/ride.png
111
install -Dm644 $src/D.svg $out/share/icons/hicolor/scalable/apps/ride.svg
112
113
mkdir -p $out/share/ride
114
cp -r locales resources{,.pak} $out/share/ride
115
+
makeShellWrapper ${lib.getExe electron} $out/bin/ride \
116
--add-flags $out/share/ride/resources/app.asar \
117
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
118
--inherit-argv0
···
145
];
146
147
meta = {
148
+
changelog = "https://github.com/Dyalog/ride/releases/tag/v${version}";
149
description = "Remote IDE for Dyalog APL";
150
homepage = "https://github.com/Dyalog/ride";
151
license = lib.licenses.mit;
···
154
tomasajt
155
markus1189
156
];
157
+
platforms = electron.meta.platforms;
158
};
159
}