Repository navigation
Expand file tree
/
Copy pathpackage.nix
More file actions
172 lines (154 loc) · 3.93 KB
/
Copy pathpackage.nix
File metadata and controls
172 lines (154 loc) · 3.93 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,
stdenvNoCC,
buildNpmPackage,
makeBinaryWrapper,
shellcheck,
bash,
bashNonInteractive,
cacert,
coreutils,
curl,
goose-cli,
jq,
mesh-llm ? null,
python3,
versionCheckHook,
nix-update-script,
runCommand,
}:
let
version = "0.1.0";
web = buildNpmPackage {
pname = "cadre-ai-web";
inherit version;
src = lib.fileset.toSource {
root = ./web;
fileset = lib.fileset.unions [
./web/package.json
./web/package-lock.json
./web/tsconfig.json
./web/vite.config.ts
./web/src
./web/test
];
};
npmDepsHash = "sha256-GQUSVkkgIWtXqgCE3vyYNm0DaIDjR8HUgWMVdUqDBYY=";
# pacote writes _cacache/tmp when unpacking git lockfile entries (@kleinbem/web-config).
makeCacheWritable = true;
strictDeps = true;
__structuredAttrs = true;
doCheck = true;
checkPhase = ''
runHook preCheck
npm test
npm run check
runHook postCheck
'';
installPhase = ''
runHook preInstall
mkdir -p "$out"
cp -r build/. "$out/"
if grep -rq '/nix/store/' "$out"; then
echo "Static web bundle leaked /nix/store references" >&2
exit 1
fi
runHook postInstall
'';
meta = {
description = "Web cockpit and local-inference telemetry assets for Cadre";
homepage = "https://github.com/kleinbem-dev/cadre";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ kleinbem ];
platforms = lib.platforms.all;
};
};
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "cadre-ai";
inherit version;
src = lib.fileset.toSource {
root = ./pkgs/cadre;
fileset = lib.fileset.unions [
./pkgs/cadre/cadre.sh
./pkgs/cadre/server.py
];
};
strictDeps = true;
__structuredAttrs = true;
nativeBuildInputs = [
makeBinaryWrapper
python3
shellcheck
];
buildInputs = [
bashNonInteractive
python3
];
dontBuild = true;
doCheck = true;
checkPhase = ''
runHook preCheck
shellcheck cadre.sh
python3 -m py_compile server.py
runHook postCheck
'';
installPhase = ''
runHook preInstall
install -Dm755 server.py "$out/libexec/cadre/server.py"
install -Dm755 cadre.sh "$out/bin/cadre"
substituteInPlace "$out/bin/cadre" \
--replace-fail "@version@" "${finalAttrs.version}" \
--replace-fail "@serverPy@" "$out/libexec/cadre/server.py" \
--replace-fail "@webDir@" "${web}"
mkdir -p "$out/share/cadre"
ln -s ${web} "$out/share/cadre/web"
patchShebangs "$out/bin/cadre" "$out/libexec/cadre/server.py"
wrapProgram "$out/bin/cadre" \
--prefix PATH : "${
lib.makeBinPath (
[
coreutils
curl
goose-cli
jq
python3
]
++ lib.optional (mesh-llm != null) mesh-llm
)
}"
runHook postInstall
'';
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
passthru = {
inherit web;
updateScript = nix-update-script { };
tests.cli =
runCommand "${finalAttrs.pname}-cli-check"
{
__darwinAllowLocalNetworking = true;
nativeBuildInputs = [
bash
cacert
coreutils
curl
jq
python3
];
}
''
bash ${./tests/cli.sh} ${lib.getExe finalAttrs.finalPackage} ${./pkgs/cadre/cadre.sh} ${./pkgs/cadre/server.py}
touch "$out"
'';
};
meta = {
description = "Private AI teammates on your own compute (Goose over local inference)";
homepage = "https://github.com/kleinbem-dev/cadre";
changelog = "https://github.com/kleinbem-dev/cadre/releases/tag/v${finalAttrs.version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ kleinbem ];
mainProgram = "cadre";
platforms = if mesh-llm != null then mesh-llm.meta.platforms else lib.platforms.unix;
};
})