Repository navigation
Expand file tree
/
Copy pathopencode.nix
More file actions
72 lines (72 loc) · 1.73 KB
/
Copy pathopencode.nix
File metadata and controls
72 lines (72 loc) · 1.73 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
{
pkgs,
makeBinaryWrapper,
symlinkJoin,
lib
}:
let
refactorMd = builtins.readFile ./refactor.md;
reviewMd = builtins.readFile ./review.md;
in
symlinkJoin {
name = "opencode";
paths = with pkgs; [ opencode ];
nativeBuildInputs = [ makeBinaryWrapper ];
postBuild = let
config = {
"$schema" = "https://opencode.ai/config.json";
provider = {
ollama = {
npm = "@ai-sdk/openai-compatible";
name = "Ollama (local)";
options = {
baseURL = "http://localhost:11434/v1";
};
models = {
"gpt-oss:20b" = {
name = "gpt-oss:20b";
tools = true;
tool_call = true;
};
};
};
};
mode = {
review = {
prompt = reviewMd;
permission = {
edit = "deny";
bash = {
"*" = "deny";
"grep *" = "allow";
"git diff*" = "allow";
"git log*" = "allow";
"git show*" = "allow";
"git status" = "allow";
};
};
};
refactor = {
prompt = refactorMd;
permission = {
edit = "ask";
bash = {
"*" = "ask";
"grep *" = "allow";
"git diff*" = "allow";
"git log*" = "allow";
"git show*" = "allow";
"git status" = "allow";
};
};
};
};
};
jsonfile = builtins.toFile "opencode.json" (builtins.toJSON config);
wrapperArgs = [
"--set-default" "OPENCODE_CONFIG" "${jsonfile}"
];
in ''
wrapProgram "$out/bin/opencode" ${lib.escapeShellArgs wrapperArgs}
'';
}