1{
2 lib,
3 stdenv,
4 fetchurl,
5 dpkg,
6 autoPatchelfHook,
7 atk,
8 at-spi2-atk,
9 cups,
10 libdrm,
11 gtk3,
12 pango,
13 cairo,
14 libX11,
15 libXcomposite,
16 libXdamage,
17 libXext,
18 libXfixes,
19 libXrandr,
20 libgbm,
21 expat,
22 libxcb,
23 alsa-lib,
24 nss,
25 nspr,
26 vips,
27 udev,
28 libGL,
29 unzip,
30}:
31let
32 selectSystem = attrs: attrs.${stdenv.hostPlatform.system};
33 pname = "waveterm";
34 version = "0.11.3";
35
36 passthru.updateScript = ./update.sh;
37
38 metaCommon = {
39 description = "Open-source, cross-platform terminal for seamless workflows";
40 homepage = "https://www.waveterm.dev";
41 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
42 license = lib.licenses.asl20;
43 platforms = [
44 "aarch64-linux"
45 "aarch64-darwin"
46 "x86_64-linux"
47 "x86_64-darwin"
48 ];
49 maintainers = with lib.maintainers; [ ];
50 };
51
52 linux = stdenv.mkDerivation {
53 inherit pname version passthru;
54
55 src =
56 let
57 arch = selectSystem {
58 x86_64-linux = "amd64";
59 aarch64-linux = "arm64";
60 };
61 in
62 fetchurl {
63 url = "https://github.com/wavetermdev/waveterm/releases/download/v${version}/waveterm-linux-${arch}-${version}.deb";
64 hash = selectSystem {
65 x86_64-linux = "sha256-pcYJHj8Jt5RazHZNAgXuSL6mu0MnUVqM9lmAUVJvGfg=";
66 aarch64-linux = "sha256-HAnlEHhbl15W/ynRWTG7TLtGkC7EPPpJzWQfMK52loA=";
67 };
68 };
69
70 nativeBuildInputs = [
71 dpkg
72 autoPatchelfHook
73 ];
74
75 buildInputs = [
76 atk
77 at-spi2-atk
78 cups
79 libdrm
80 gtk3
81 pango
82 cairo
83 libX11
84 libXcomposite
85 libXdamage
86 libXext
87 libXfixes
88 libXrandr
89 libgbm
90 expat
91 libxcb
92 alsa-lib
93 nss
94 nspr
95 vips
96 ];
97
98 installPhase = ''
99 runHook preInstall
100
101 mkdir -p $out/bin $out/app
102 cp -r opt/Wave $out/app/waveterm
103 cp -r usr/share $out/share
104 substituteInPlace $out/share/applications/waveterm.desktop \
105 --replace-fail "/opt/Wave/" ""
106 ln -s $out/app/waveterm/waveterm $out/bin/waveterm
107
108 runHook postInstall
109 '';
110
111 preFixup = ''
112 patchelf --add-needed libGL.so.1 \
113 --add-rpath ${
114 lib.makeLibraryPath [
115 libGL
116 udev
117 ]
118 } $out/app/waveterm/waveterm
119 '';
120
121 meta = metaCommon // {
122 mainProgram = "waveterm";
123 };
124 };
125
126 darwin = stdenv.mkDerivation {
127 inherit pname version passthru;
128
129 src =
130 let
131 arch = selectSystem {
132 x86_64-darwin = "x64";
133 aarch64-darwin = "arm64";
134 };
135 in
136 fetchurl {
137 url = "https://github.com/wavetermdev/waveterm/releases/download/v${version}/Wave-darwin-${arch}-${version}.zip";
138 hash = selectSystem {
139 x86_64-darwin = "sha256-KmH5az2p2dRC1UCXCt7SBVfomj6dDaAtevIai1YIYO0=";
140 aarch64-darwin = "sha256-SdZY5MPi+oP3+ywW3BASMzYr16QiYS3MXyPs9jCqD+Y=";
141 };
142 };
143
144 nativeBuildInputs = [ unzip ];
145
146 installPhase = ''
147 runHook preInstall
148
149 mkdir -p $out/Applications
150 cp -r . "$out/Applications/Wave.app"
151
152 runHook postInstall
153 '';
154
155 meta = metaCommon // {
156 mainProgram = "Wave";
157 };
158 };
159in
160if stdenv.hostPlatform.isDarwin then darwin else linux