summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/binary-cache/server.nix
blob: 2e05fd52e83e02149107e38bba145ce14da7d4fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, lib, pkgs, ...}:

{
  # generate private key with:
  # nix-store --generate-binary-cache-key gum nix-serve.key nix-serve.pub
  services.nix-serve = {
    enable = true;
    port = 5001;
    secretKeyFile = config.krebs.secret.files.nix-serve-key.path;
  };

  systemd.services.nix-serve = {
    after = [
      config.krebs.secret.files.nix-serve-key.service
    ];
    partOf = [
      config.krebs.secret.files.nix-serve-key.service
    ];
  };
  krebs.secret.files.nix-serve-key = {
    path = "/run/secret/nix-serve.key";
    owner.name = "nix-serve";
    source-path = toString <secrets> + "/nix-serve.key";
  };
  services.nginx = {
    enable = true;
    virtualHosts."cache.euer.krebsco.de" = {
      forceSSL = true;
      enableACME = true;
      serverAliases = [ # "cache.gum.r"
                        "cache.gum.krebsco.de"
                      ];
      locations."/".proxyPass= "http://localhost:${toString config.services.nix-serve.port}";
    };
  };
}