-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathpackage.nix
More file actions
173 lines (146 loc) · 4.06 KB
/
package.nix
File metadata and controls
173 lines (146 loc) · 4.06 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
173
{
lib,
flake,
stdenv,
buildNpmPackage,
fetchFromGitHub,
fetchNpmDepsWithPackuments,
npmConfigHook,
rustPlatform,
makeWrapper,
nodejs,
codex,
versionCheckHook,
}:
let
versionData = builtins.fromJSON (builtins.readFile ./hashes.json);
pname = "oh-my-codex";
inherit (versionData)
version
hash
cargoHash
npmDepsHash
;
src = fetchFromGitHub {
owner = "Yeachan-Heo";
repo = "oh-my-codex";
rev = "v${version}";
inherit hash;
};
nodePlatformMap = {
x86_64-linux = "linux";
aarch64-linux = "linux";
x86_64-darwin = "darwin";
aarch64-darwin = "darwin";
};
nodeArchMap = {
x86_64-linux = "x64";
aarch64-linux = "arm64";
x86_64-darwin = "x64";
aarch64-darwin = "arm64";
};
system = stdenv.hostPlatform.system;
nodePlatform = nodePlatformMap.${system} or (throw "Unsupported system for ${pname}: ${system}");
nodeArch = nodeArchMap.${system} or (throw "Unsupported architecture for ${pname}: ${system}");
mkNativeBinary =
cargoPackage: binaryName:
rustPlatform.buildRustPackage {
pname = binaryName;
inherit version src cargoHash;
cargoBuildFlags = [
"--package"
cargoPackage
];
cargoInstallFlags = [
"--path"
"."
"--bin"
binaryName
];
doCheck = false;
meta = with lib; {
description = "Native sidecar for ${pname}";
homepage = "https://github.com/Yeachan-Heo/oh-my-codex";
changelog = "https://github.com/Yeachan-Heo/oh-my-codex/releases/tag/v${version}";
license = licenses.mit;
sourceProvenance = with sourceTypes; [ fromSource ];
maintainers = with flake.lib.maintainers; [ smdex ];
mainProgram = binaryName;
platforms = platforms.unix;
};
};
exploreHarness = mkNativeBinary "omx-explore-harness" "omx-explore-harness";
sparkShell = mkNativeBinary "omx-sparkshell" "omx-sparkshell";
in
buildNpmPackage (finalAttrs: {
inherit
npmConfigHook
pname
version
src
;
npmDeps = fetchNpmDepsWithPackuments {
inherit (finalAttrs) src;
name = "${pname}-${version}-npm-deps";
hash = npmDepsHash;
fetcherVersion = 2;
};
makeCacheWritable = true;
npmFlags = [ "--ignore-scripts" ];
nativeBuildInputs = [ makeWrapper ];
buildPhase = ''
runHook preBuild
npm run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
root=$out/share/oh-my-codex
mkdir -p $out/bin $root $root/src
cp -r dist skills prompts templates package.json Cargo.toml Cargo.lock crates $root/
cp -r src/scripts $root/src/
npm prune --omit=dev
cp -r node_modules $root/
patchShebangs $root
install -Dm755 ${exploreHarness}/bin/omx-explore-harness \
$root/bin/omx-explore-harness
cat > $root/bin/omx-explore-harness.meta.json <<META
{
"binaryName": "omx-explore-harness",
"platform": "${nodePlatform}",
"arch": "${nodeArch}",
"strategy": "nix-packaged"
}
META
install -Dm755 ${sparkShell}/bin/omx-sparkshell \
$root/bin/native/${nodePlatform}-${nodeArch}/omx-sparkshell
makeWrapper ${lib.getExe nodejs} $out/bin/omx \
--add-flags "$root/dist/cli/omx.js" \
--prefix PATH : ${lib.makeBinPath [ codex ]}
runHook postInstall
'';
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = [ "--version" ];
passthru = {
category = "AI Coding Agents";
native = {
inherit exploreHarness sparkShell;
};
};
meta = with lib; {
description = "Multi-agent orchestration layer for OpenAI Codex CLI";
homepage = "https://github.com/Yeachan-Heo/oh-my-codex";
changelog = "https://github.com/Yeachan-Heo/oh-my-codex/releases/tag/v${version}";
license = licenses.mit;
sourceProvenance = with sourceTypes; [ fromSource ];
maintainers = with flake.lib.maintainers; [ smdex ];
mainProgram = "omx";
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
};
})