-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.nix
More file actions
88 lines (70 loc) · 2.33 KB
/
package.nix
File metadata and controls
88 lines (70 loc) · 2.33 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
{
lib,
stdenv,
fetchurl,
unzip,
autoPatchelfHook,
zlib,
bash,
}:
let
version = "0.2.0";
repo = "parallel-web/parallel-web-tools";
platformMap = {
"x86_64-linux" = "linux-x64";
"aarch64-linux" = "linux-arm64";
"x86_64-darwin" = "darwin-x64";
"aarch64-darwin" = "darwin-arm64";
};
hashes = {
"linux-x64" = "sha256:4bd65835e5a35b0730d58da5b5cb6ab9b928c59d6b815668b81d13595280e1df";
"linux-arm64" = "sha256:19bbafe24c825b18679f273ff26ec1f544e8d5f4d0a8f84883df59f789cc6f0b";
"darwin-x64" = "sha256:ec37c138e88d01b032eab5388ad785023fe951be098a79e0b2ab6d22b0f0ac74";
"darwin-arm64" = "sha256:d731569f7b77881f0c92c6d09b65521e59eb8af42af93b8701d6ff5895ba40a7";
};
platform = platformMap.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
isLinux = stdenv.hostPlatform.isLinux;
in
stdenv.mkDerivation {
pname = "parallel-cli";
inherit version;
src = fetchurl {
url = "https://github.com/${repo}/releases/download/v${version}/parallel-cli-${platform}.zip";
hash = hashes.${platform};
};
sourceRoot = ".";
nativeBuildInputs = [ unzip ]
++ lib.optionals isLinux [ autoPatchelfHook ];
buildInputs = lib.optionals isLinux [
stdenv.cc.cc.lib
zlib
];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/parallel-cli $out/bin
cp parallel-cli/parallel-cli $out/lib/parallel-cli/parallel-cli
chmod +x $out/lib/parallel-cli/parallel-cli
cp -r parallel-cli/_internal $out/lib/parallel-cli/_internal
cat > $out/bin/parallel-cli <<WRAPPER
#!${bash}/bin/bash
exec $out/lib/parallel-cli/parallel-cli "\$@"
WRAPPER
chmod +x $out/bin/parallel-cli
runHook postInstall
'';
# On macOS the binary links to system dylibs (libSystem, libz) which is fine.
# On Linux autoPatchelfHook handles the dynamic linker and rpath.
dontFixup = !isLinux;
meta = {
description = "AI-powered web search, extraction, and research CLI from parallel.ai";
homepage = "https://parallel.ai";
changelog = "https://github.com/${repo}/releases/tag/v${version}";
license = lib.licenses.unfreeRedistributable;
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
platforms = builtins.attrNames platformMap;
mainProgram = "parallel-cli";
};
}