-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathpackage.nix
More file actions
112 lines (97 loc) · 2.61 KB
/
package.nix
File metadata and controls
112 lines (97 loc) · 2.61 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
{
lib,
flake,
stdenv,
rustPlatform,
fetchFromGitHub,
runCommand,
nodejs,
fetchNpmDeps,
npmConfigHook,
versionCheckHook,
versionCheckHomeHook,
}:
let
pname = "zeroclaw";
version = "0.7.5";
src = fetchFromGitHub {
owner = "zeroclaw-labs";
repo = "zeroclaw";
tag = "v${version}";
hash = "sha256-hVHfsBw3u0CLWAbmizLA9ZrB+3B0qBIrSUuzsyChwW0=";
};
frontendSrc = runCommand "${pname}-web-src-${version}" { } ''
mkdir -p $out
cp -r ${src}/web/. $out/
'';
frontend = stdenv.mkDerivation {
pname = "${pname}-frontend";
inherit version;
src = frontendSrc;
nativeBuildInputs = [
nodejs
npmConfigHook
];
env.NIX_NPM_FETCHER_VERSION = "2";
npmDeps = fetchNpmDeps {
src = frontendSrc;
name = "${pname}-${version}-npm-deps";
hash = "sha256-k5RJkLXMRk8HXG8Qju3Pprd65kySHRQEpeNJbvgwndQ=";
fetcherVersion = 2;
};
makeCacheWritable = true;
# `api-generated.ts` is normally produced by `cargo web gen-api`, which
# renders the gateway's OpenAPI spec and pipes it through openapi-typescript.
# It is only re-exported as a type from api.ts and never consumed elsewhere,
# so stub it instead of pulling the whole Rust toolchain into the frontend.
postPatch = ''
cat > src/lib/api-generated.ts <<'EOF'
export type paths = Record<string, unknown>;
export type components = Record<string, unknown>;
EOF
'';
buildPhase = ''
runHook preBuild
npm run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r dist/* $out/
runHook postInstall
'';
};
in
rustPlatform.buildRustPackage rec {
inherit pname version src;
cargoHash = "sha256-6MGIJsaqRp3k/ysjdu6BE2iM2sehERQR+QoSqiThSpg=";
preBuild = ''
mkdir -p web/dist
cp -r ${frontend}/* web/dist/
'';
# Tests require runtime configuration and network access
doCheck = false;
doInstallCheck = true;
nativeInstallCheckInputs = [
versionCheckHook
versionCheckHomeHook
];
passthru = {
inherit frontend;
category = "AI Assistants";
};
meta = {
description = "Fast, small, and fully autonomous AI assistant infrastructure";
homepage = "https://github.com/zeroclaw-labs/zeroclaw";
changelog = "https://github.com/zeroclaw-labs/zeroclaw/releases/tag/v${version}";
license = with lib.licenses; [
mit
asl20
];
sourceProvenance = with lib.sourceTypes; [ fromSource ];
maintainers = with flake.lib.maintainers; [ commandodev ];
mainProgram = "zeroclaw";
platforms = lib.platforms.unix;
};
}