opencode: add web service configuration
Add configuration options for the opencode web service including host, port, mDNS, logging, and CORS settings. Implement systemd user service to run the web server with configurable parameters.
This commit is contained in:
parent
2539eba97a
commit
d9da6e6457
5 changed files with 157 additions and 0 deletions
|
|
@ -23,4 +23,5 @@
|
|||
opencode-themes-bulk-directory = ./themes-bulk-directory.nix;
|
||||
opencode-mcp-integration = ./mcp-integration.nix;
|
||||
opencode-mcp-integration-with-override = ./mcp-integration-with-override.nix;
|
||||
opencode-web-service = ./web-service.nix;
|
||||
}
|
||||
|
|
|
|||
41
tests/modules/programs/opencode/web-service.nix
Normal file
41
tests/modules/programs/opencode/web-service.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
programs.opencode = {
|
||||
enable = true;
|
||||
|
||||
web = {
|
||||
enable = true;
|
||||
extraArgs = [
|
||||
"--hostname"
|
||||
"0.0.0.0"
|
||||
"--port"
|
||||
"4096"
|
||||
"--mdns"
|
||||
"--cors"
|
||||
"https://example.com"
|
||||
"--cors"
|
||||
"http://localhost:3000"
|
||||
"--print-logs"
|
||||
"--log-level"
|
||||
"DEBUG"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
''
|
||||
serviceFile=LaunchAgents/org.nix-community.home.opencode-web.plist
|
||||
assertFileExists "$serviceFile"
|
||||
assertFileContent "$serviceFile" ${./web-service.plist}
|
||||
''
|
||||
else
|
||||
''
|
||||
serviceFile=home-files/.config/systemd/user/opencode-web.service
|
||||
assertFileExists "$serviceFile"
|
||||
assertFileContent "$serviceFile" ${./web-service.service}
|
||||
'';
|
||||
}
|
||||
36
tests/modules/programs/opencode/web-service.plist
Normal file
36
tests/modules/programs/opencode/web-service.plist
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>KeepAlive</key>
|
||||
<dict>
|
||||
<key>Crashed</key>
|
||||
<true/>
|
||||
<key>SuccessfulExit</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>Label</key>
|
||||
<string>org.nix-community.home.opencode-web</string>
|
||||
<key>ProcessType</key>
|
||||
<string>Background</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>@opencode@/bin/opencode</string>
|
||||
<string>web</string>
|
||||
<string>--hostname</string>
|
||||
<string>0.0.0.0</string>
|
||||
<string>--port</string>
|
||||
<string>4096</string>
|
||||
<string>--mdns</string>
|
||||
<string>--cors</string>
|
||||
<string>https://example.com</string>
|
||||
<string>--cors</string>
|
||||
<string>http://localhost:3000</string>
|
||||
<string>--print-logs</string>
|
||||
<string>--log-level</string>
|
||||
<string>DEBUG</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
11
tests/modules/programs/opencode/web-service.service
Normal file
11
tests/modules/programs/opencode/web-service.service
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[Install]
|
||||
WantedBy=default.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@opencode@/bin/opencode web --hostname 0.0.0.0 --port 4096 --mdns --cors https://example.com --cors http://localhost:3000 --print-logs --log-level DEBUG
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Unit]
|
||||
After=network.target
|
||||
Description=OpenCode Web Service
|
||||
Loading…
Add table
Add a link
Reference in a new issue