Set up build farm (#3)

Reviewed-on: #3
Co-authored-by: Natsu Kagami <nki@nkagami.me>
Co-committed-by: Natsu Kagami <nki@nkagami.me>
This commit is contained in:
Natsu Kagami 2024-08-19 14:04:52 +00:00 committed by nki
parent 70ab3aa5b3
commit bc4cfe7c69
Signed by: DTTHgit
GPG key ID: 3681E15E5C14A241
13 changed files with 162 additions and 25 deletions

View file

@ -3,6 +3,8 @@
with { inherit (lib) mkEnableOption mkOption types mkIf; };
let
cfg = config.nki.services.nix-cache;
bindAddr = "127.0.0.1:5000";
in
{
options.nki.services.nix-cache = {
@ -31,18 +33,17 @@ in
config = {
nix.settings = mkIf cfg.enableClient {
substituters = [ "http://${cfg.host}" ];
substituters = lib.mkAfter [ "http://${cfg.host}" ];
trusted-public-keys = [ cfg.publicKey ];
};
services.nix-serve = mkIf cfg.enableServer {
services.harmonia = mkIf cfg.enableServer {
enable = true;
secretKeyFile = cfg.privateKeyFile;
};
users = mkIf cfg.enableServer {
users.nix-serve = { group = "nix-serve"; isSystemUser = true; };
groups.nix-serve = { };
signKeyPath = cfg.privateKeyFile;
settings = {
bind = bindAddr;
priority = 45;
};
};
services.nginx = mkIf cfg.enableServer {
@ -51,7 +52,7 @@ in
virtualHosts = {
# ... existing hosts config etc. ...
"${cfg.host}" = {
locations."/".proxyPass = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}";
locations."/".proxyPass = "http://${bindAddr}";
};
};
};