2025-07-14 00:56:49 +03:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.custom.services.nixCacheServer;
|
2025-07-14 03:03:22 +03:00
|
|
|
cacheDomain = "cache.sinerva.eu";
|
2025-07-14 00:56:49 +03:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2025-07-14 00:56:49 +03:00
|
|
|
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;
|
2025-07-14 00:56:49 +03:00
|
|
|
write = true;
|
2025-07-18 18:55:17 +03:00
|
|
|
keys =
|
|
|
|
let
|
|
|
|
keys = config.custom.sshKeys;
|
|
|
|
in
|
|
|
|
[
|
2025-07-28 22:59:26 +03:00
|
|
|
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
|
|
|
|
];
|
2025-07-14 00:56:49 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# 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;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|