summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/retiolum-bootstrap.nix
blob: bd7e7c5f6735f0892854c4d30e7d85c1c608b29a (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
38
39
40
41
42
43
{ config, pkgs, lib, ... }:
with lib;
let
  cfg = config.krebs.retiolum-bootstrap;
in
{
  options.krebs.retiolum-bootstrap = {
    enable = mkEnableOption "retiolum boot strap for ${cfg.serverName}";
    serverName = mkOption {
        type = types.str;
        description = "hostname which serves tinc boot";
        default = "tinc.krebsco.de" ;
    };
    sslCertificate = mkOption {
        type = types.str;
        description = "Certificate file to use for ssl";
        default = "${config.krebs.secret.directory}/tinc.krebsco.de.crt" ;
    };
    sslCertificateKey = mkOption {
        type = types.str;
        description = "Certificate key to use for ssl";
        default = "${config.krebs.secret.directory}/tinc.krebsco.de.key";
    };
    # in use:
    #  <secrets/tinc.krebsco.de.crt>
    #  <secrets/tinc.krebsco.de.key>
  };

  config = mkIf cfg.enable {
    services.nginx = {
      enable = mkDefault true;
      virtualHosts.retiolum-bootstrap = {
        inherit (cfg) serverName sslCertificate sslCertificateKey;
        forceSSL = true;
        extraConfig =''

          root ${pkgs.retiolum-bootstrap};
          try_files $uri $uri/retiolum.sh;
        '';
      };
    };
  };
}