forked from numtide/llm-agents.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.nix
More file actions
172 lines (148 loc) · 3.94 KB
/
Copy pathpackage.nix
File metadata and controls
172 lines (148 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{
lib,
stdenv,
fetchurl,
autoPatchelfHook,
gcc-unwrapped,
dpkg,
makeWrapper,
makeDesktopItem,
copyDesktopItems,
# Runtime dependencies for Linux
alsa-lib,
cairo,
gdk-pixbuf,
glib,
gtk3,
gtk-layer-shell,
libayatana-appindicator,
libsoup_3,
onnxruntime,
openssl,
vulkan-loader,
webkitgtk_4_1,
}:
let
pname = "handy";
versionData = builtins.fromJSON (builtins.readFile ./hashes.json);
inherit (versionData) version hashes;
# Linux uses deb packages, macOS uses app tarballs
srcs = {
x86_64-linux = fetchurl {
url = "https://github.com/cjpais/Handy/releases/download/v${version}/Handy_${version}_amd64.deb";
hash = hashes.x86_64-linux;
};
x86_64-darwin = fetchurl {
url = "https://github.com/cjpais/Handy/releases/download/v${version}/Handy_x64.app.tar.gz";
hash = hashes.x86_64-darwin;
};
aarch64-darwin = fetchurl {
url = "https://github.com/cjpais/Handy/releases/download/v${version}/Handy_aarch64.app.tar.gz";
hash = hashes.aarch64-darwin;
};
};
src =
srcs.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}. Supported systems: x86_64-linux, x86_64-darwin, aarch64-darwin");
desktopItem = makeDesktopItem {
name = "handy";
desktopName = "Handy";
comment = "Fast and accurate local transcription app";
exec = "handy";
icon = "handy";
categories = [
"Audio"
"AudioVideo"
"Utility"
];
startupNotify = true;
};
in
stdenv.mkDerivation {
inherit pname version src;
nativeBuildInputs =
lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
dpkg
copyDesktopItems
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
makeWrapper
];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
gcc-unwrapped.lib
alsa-lib
cairo
gdk-pixbuf
glib
gtk3
gtk-layer-shell
libsoup_3
onnxruntime
openssl
vulkan-loader
webkitgtk_4_1
];
runtimeDependencies = lib.optionals stdenv.hostPlatform.isLinux [
stdenv.cc.cc.lib
libayatana-appindicator
];
desktopItems = lib.optionals stdenv.hostPlatform.isLinux [ desktopItem ];
unpackPhase =
if stdenv.hostPlatform.isLinux then
''
runHook preUnpack
dpkg -x $src .
runHook postUnpack
''
else
''
runHook preUnpack
mkdir -p ./unpacked
tar -xzf $src -C ./unpacked
runHook postUnpack
'';
installPhase =
if stdenv.hostPlatform.isLinux then
''
runHook preInstall
# Install the binary
install -Dm755 usr/bin/handy $out/bin/handy
# Install resources
mkdir -p $out/lib/Handy/resources
cp -r usr/lib/Handy/resources/* $out/lib/Handy/resources/
# Install icons
mkdir -p $out/share/icons/hicolor
if [ -d usr/share/icons/hicolor ]; then
cp -r usr/share/icons/hicolor/* $out/share/icons/hicolor/
fi
runHook postInstall
''
else
''
runHook preInstall
mkdir -p $out/Applications
cp -r ./unpacked/Handy.app $out/Applications/
# Create a wrapper script in bin
mkdir -p $out/bin
makeWrapper $out/Applications/Handy.app/Contents/MacOS/Handy $out/bin/handy
runHook postInstall
'';
# GUI-only Tauri app - no CLI version support, would block trying to start GUI
doInstallCheck = false;
passthru.category = "Utilities";
meta = with lib; {
description = "Fast and accurate local transcription app using AI models";
homepage = "https://handy.computer/";
changelog = "https://github.com/cjpais/Handy/releases/tag/v${version}";
license = licenses.mit;
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
maintainers = with maintainers; [ ];
platforms = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
mainProgram = "handy";
};
}