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

37 lines
1,012 B
Nix
Raw Normal View History

{ inputs, config, lib, pkgs, ... }:
let
cfg = config.services.binary-cache;
in
{
imports = [
];
options.services.binary-cache = {
enable = lib.mkOption {
type = with lib.types; uniq bool;
default = false;
description = "Enable minecraft server";
};
};
config = lib.mkIf cfg.enable {
services.nix-serve = {
enable = true;
secretKeyFile = "/var/secrets/cache-games01-private-key.pem";
bindAddress = "cache.game01.kb-one.de";
};
# Configure Reverse-Proxy
services.traefik-proxy.enable = true;
services.traefik.staticConfigOptions = {
http.routers.nix-cache.entrypoints = "websecure";
http.routers.nix-cache.tls.certresolver = "letsencrypt";
http.routers.nix-cache.rule = "Host(`${config.services.nix-serve.bindAddress}`)";
http.routers.nix-cache.service = "nix-cache";
services.nix-cache.loadBalancer.servers = [ { url = "http://localhost:${toString config.services.nix-serve.port}/"; } ];
};
};
}