Installation¶
A production instance with managed secrets, a chosen database, and TLS matching the network in front of the server. The steps below extend the Quick Start configuration.
Requirements:
- A NixOS host configured through a flake, with the Gradient module added (Quick Start, step 1)
- PostgreSQL 18 or newer. The server will refuse to start against older versions.
1. Public Binary Cache¶
Pre-built Gradient packages are available for substituting instead of compiling.
nix.settings = {
substituters = [ "https://public.gradient.ci/cache/main" ];
trusted-public-keys = [
"public.gradient.ci-main:qmxRE+saUvhNa3jqaCMWje+feVU77TjABchZrPGf7A8="
];
};
2. Secrets¶
Gradient needs two secrets, each 48 random bytes in base64.
jwtFile: key for signing login sessions.cryptFile: key for encrypting secrets stored in the database.
Root can keep ownership of the files. The server will read them as systemd credentials.
Warning
Every secret stored in the database is unreadable without cryptFile. Back up cryptFile together with the database.
3. Database¶
A PostgreSQL 18 cluster on the same host, with a gradient role and database.
4. Reverse Proxy and TLS¶
The server will handle the API, the worker protocol and the cache. A reverse proxy in front will deliver the web frontend and TLS.
Enabled by default, with a Let's Encrypt certificate.
services.gradient.reverseProxy.caddy = {
enable = true; # (1)!
useACMEHost = "gradient.example.com"; # (2)!
};
- Used instead of nginx.
- An existing certificate from
security.acme.certs. Caddy will request no certificate for this host.
A load balancer or Cloudflare will terminate TLS and forward plain HTTP.
- nginx will no longer request a certificate.
useTlswill staytrue, and Gradient will still emithttps://links and secure cookies.
Warning
services.gradient.useTls = false is only for plain HTTP end to end. Browsers then drop the session cookie behind any HTTPS proxy, and login will break.
5. Workers¶
- Server host:
services.gradient.worker.enable = true, as in the Quick Start. - Other machines: Add a Remote Worker.
Verify Deployment¶
https://gradient.example.comshows the login page with a valid certificate.journalctl -u gradient-servershows no database or secret errors.
Crash Reports
services.gradient.sentry.enable = true will send crash reports to the Gradient developers. Crash reports are off by default.
Network Tuning for Fast or Distant Links
A default deployment is fine without tuning. BBR and larger TCP buffers help on a high-bandwidth or high-latency link between workers and server.
boot.kernel.sysctl = {
"net.ipv4.tcp_congestion_control" = "bbr";
"net.ipv4.tcp_rmem" = "4096 131072 16777216";
"net.ipv4.tcp_wmem" = "4096 16384 16777216";
};
Jumbo frames save little CPU. Jumbo frames can hang large transfers on an MTU mismatch at any hop. Enable them only where every hop is under control.
Next Steps¶
- First Project: the first user, project and build
- Add a Remote Worker: build machines beyond the server host
- Configuration: every server and worker option
- Options search: all NixOS options