2017-04-17 16:20:05 +02:00
|
|
|
{ config, pkgs, ... }:
|
2016-10-20 20:54:38 +02:00
|
|
|
with import <stockholm/lib>;
|
2015-10-19 21:50:08 +02:00
|
|
|
let
|
|
|
|
cfg = config.krebs.retiolum-bootstrap;
|
2017-04-17 16:20:05 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.krebs.retiolum-bootstrap = {
|
|
|
|
enable = mkEnableOption "retiolum boot strap for ${cfg.serverName}";
|
|
|
|
serverName = mkOption {
|
2015-10-19 21:50:08 +02:00
|
|
|
type = types.str;
|
|
|
|
description = "hostname which serves tinc boot";
|
|
|
|
default = "tinc.krebsco.de" ;
|
|
|
|
};
|
2017-04-17 16:20:05 +02:00
|
|
|
sslCertificate = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Certificate file to use for ssl";
|
|
|
|
default = "${toString <secrets>}/tinc.krebsco.de.crt" ;
|
2015-10-20 19:59:59 +02:00
|
|
|
};
|
2017-04-17 16:20:05 +02:00
|
|
|
sslCertificateKey = mkOption {
|
2015-10-19 21:50:08 +02:00
|
|
|
type = types.str;
|
|
|
|
description = "Certificate key to use for ssl";
|
2016-07-18 15:13:22 +02:00
|
|
|
default = "${toString <secrets>}/tinc.krebsco.de.key";
|
2015-10-19 21:50:08 +02:00
|
|
|
};
|
|
|
|
# in use:
|
|
|
|
# <secrets/tinc.krebsco.de.crt>
|
|
|
|
# <secrets/tinc.krebsco.de.key>
|
|
|
|
};
|
|
|
|
|
2017-04-17 16:20:05 +02:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.nginx = {
|
|
|
|
enable = mkDefault true;
|
|
|
|
virtualHosts.retiolum-bootstrap = {
|
|
|
|
inherit (cfg) serverName sslCertificate sslCertificateKey;
|
|
|
|
enableSSL = true;
|
|
|
|
extraConfig =''
|
2015-10-20 19:59:59 +02:00
|
|
|
if ($scheme = http){
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
}
|
|
|
|
|
2015-10-19 21:50:08 +02:00
|
|
|
root ${pkgs.retiolum-bootstrap};
|
|
|
|
try_files $uri $uri/retiolum.sh;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2017-04-17 16:20:05 +02:00
|
|
|
}
|