Mirror of the sgx opencode setup: systemd service on port 4196 fronted by nginx with a per-host ACME cert (DNS-01 via internetbs). Adds amd key + path rule to .sops.yaml so secrets under .secrets/amd/ encrypt for the host.
47 lines
1,017 B
Nix
47 lines
1,017 B
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
|
|
let
|
|
port = 4196;
|
|
user = "harald";
|
|
homeDir = "/home/harald";
|
|
in
|
|
{
|
|
systemd.services.opencode-serve = {
|
|
description = "OpenCode Web Server";
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
environment = {
|
|
HOME = homeDir;
|
|
};
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = user;
|
|
Group = "users";
|
|
WorkingDirectory = homeDir;
|
|
ExecStart = "${pkgs.opencode}/bin/opencode serve --hostname 127.0.0.1 --port ${toString port}";
|
|
Restart = "always";
|
|
RestartSec = 5;
|
|
EnvironmentFile = config.sops.secrets.opencode-web-password.path;
|
|
|
|
# Security hardening
|
|
PrivateTmp = true;
|
|
ProtectSystem = "strict";
|
|
ProtectHome = false;
|
|
NoNewPrivileges = true;
|
|
ReadWritePaths = [ homeDir ];
|
|
};
|
|
};
|
|
|
|
sops.secrets.opencode-web-password = {
|
|
sopsFile = ../../../.secrets/amd/opencode-web.yaml;
|
|
owner = user;
|
|
restartUnits = [ "opencode-serve.service" ];
|
|
};
|
|
}
|