nix-config/modules/nixos/services/nix-cache/default.nix

54 lines
1.1 KiB
Nix
Raw Normal View History

# Binary cache
{ config, lib, ... }:
2023-04-19 22:23:01 +02:00
let
cfg = config.my.services.nix-cache;
2023-04-19 22:23:01 +02:00
in
{
options.my.services.nix-cache = with lib; {
enable = mkEnableOption "nix binary cache";
2023-04-19 22:23:01 +02:00
port = mkOption {
type = types.port;
default = 5000;
example = 8080;
description = "Internal port for serving cache";
};
secretKeyFile = mkOption {
type = types.str;
example = "/run/secrets/nix-cache";
2023-04-19 22:23:01 +02:00
description = "Secret signing key for the cache";
};
priority = mkOption {
type = types.int;
default = 50;
example = 30;
description = ''
Which priority to assign to this cache. Lower number is higher priority.
The official nixpkgs hydra cache is priority 40.
'';
};
};
config = lib.mkIf cfg.enable {
services.harmonia = {
2023-04-19 22:23:01 +02:00
enable = true;
settings = {
bind = "127.0.0.1:${toString cfg.port}";
inherit (cfg) priority;
};
2023-04-19 22:23:01 +02:00
signKeyPath = cfg.secretKeyFile;
2023-04-19 22:23:01 +02:00
};
my.services.nginx.virtualHosts = [
{
subdomain = "cache";
inherit (cfg) port;
}
];
};
}