nixos-conf/modules/services/nix-cache-server.nix

71 lines
1.5 KiB
Nix
Raw Normal View History

{ config, lib, ... }:
let
cfg = config.custom.services.nixCacheServer;
2025-07-14 03:03:22 +03:00
cacheDomain = "cache.sinerva.eu";
in
{
options.custom.services.nixCacheServer.enable = lib.mkEnableOption "Nix SSH cache server";
config = lib.mkIf cfg.enable {
sops.secrets.priv-cache-key.sopsFile = ../../secrets/ci.yaml;
2025-07-14 03:03:22 +03:00
services = {
nix-serve = {
enable = true;
bindAddress = "127.0.0.2";
port = 8081;
secretKeyFile = config.sops.secrets.priv-cache-key.path;
};
nginx.virtualHosts = {
${cacheDomain}.locations."/" = {
proxyPass = "http://127.0.0.2:8081";
};
};
};
nix = {
extraOptions = ''
secret-key-files = ${config.sops.secrets.priv-cache-key.path}
'';
sshServe = {
enable = true;
2025-07-14 01:51:32 +03:00
trusted = true;
write = true;
2025-07-18 18:55:17 +03:00
keys =
let
keys = config.custom.sshKeys;
in
[
keys.borg
2025-07-18 18:55:17 +03:00
keys.cert-store
keys.forgejo
keys.gaming
2025-07-19 12:38:25 +03:00
keys.helium
2025-07-18 18:55:17 +03:00
keys.idacloud
keys.lithium
keys.nextcloud
keys.vaultwarden
];
};
};
# Added because we are opening up SSH to the world
services.fail2ban = {
enable = true;
maxretry = 10;
bantime = "10m";
bantime-increment = {
enable = true;
maxtime = "1d";
};
jails = {
DEFAULT.settings = {
findtime = 3600;
};
};
};
};
}