-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathopencode-server.nix
More file actions
57 lines (55 loc) · 1.61 KB
/
Copy pathopencode-server.nix
File metadata and controls
57 lines (55 loc) · 1.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
{ inputs, pkgs, ... }:
let
llm = inputs.llm-agents.packages.${pkgs.system};
opencode-wrapped = pkgs.symlinkJoin {
name = "opencode-wrapped";
paths = [ llm.opencode ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/opencode --set OPENCODE_ENABLE_EXA 1
'';
};
in
{
home.packages = [ opencode-wrapped ];
xdg.configFile."opencode/opencode.json" = {
force = true;
text = builtins.toJSON {
"$schema" = "https://opencode.ai/config.json";
autoupdate = false;
share = "disabled";
model = "opencode-go/deepseek-v4-pro";
provider.opencode-go.options.apiKey = "{file:~/.config/opencode/opencode-go-api-key}";
permission = {
edit = "allow";
bash = "allow";
};
};
};
systemd.user.services.opencode-server = {
Unit = {
Description = "OpenCode Web Server";
After = [ "network.target" ];
};
Install = {
WantedBy = [ "default.target" ];
};
Service = {
Environment = [
"PATH=/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:%h/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin"
];
ExecStart =
let
startScript = pkgs.writeShellScript "opencode-server-start" ''
if [ -f ~/.config/opencode/opencode-server-password ]; then
export OPENCODE_SERVER_PASSWORD=$(< ~/.config/opencode/opencode-server-password)
fi
exec ${opencode-wrapped}/bin/opencode web --hostname opencode.home --port 80
'';
in
"${startScript}";
Restart = "always";
RestartSec = 10;
};
};
}