2015-10-19 21:50:08 +02:00
|
|
|
{ config, lib, 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;
|
|
|
|
|
|
|
|
out = {
|
|
|
|
options.krebs.retiolum-bootstrap = api;
|
2016-02-14 16:43:44 +01:00
|
|
|
config = lib.mkIf cfg.enable imp;
|
2015-10-19 21:50:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
api = {
|
|
|
|
enable = mkEnableOption "retiolum boot strap for tinc.krebsco.de";
|
|
|
|
hostname = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "hostname which serves tinc boot";
|
|
|
|
default = "tinc.krebsco.de" ;
|
|
|
|
};
|
2015-10-20 19:59:59 +02:00
|
|
|
listen = mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
description = ''Addresses to listen on (nginx-syntax).
|
|
|
|
ssl will be configured, http will be redirected to ssl.
|
|
|
|
Make sure to have at least 1 ssl port configured.
|
|
|
|
'';
|
|
|
|
default = [ "80" "443 ssl" ] ;
|
|
|
|
};
|
2015-10-19 21:50:08 +02:00
|
|
|
ssl_certificate_key = mkOption {
|
|
|
|
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
|
|
|
};
|
|
|
|
ssl_certificate = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Certificate file to use for ssl";
|
2016-07-18 15:13:22 +02:00
|
|
|
default = "${toString <secrets>}/tinc.krebsco.de.crt" ;
|
2015-10-19 21:50:08 +02:00
|
|
|
};
|
|
|
|
# in use:
|
|
|
|
# <secrets/tinc.krebsco.de.crt>
|
|
|
|
# <secrets/tinc.krebsco.de.key>
|
|
|
|
};
|
|
|
|
|
|
|
|
imp = {
|
2015-10-19 21:57:05 +02:00
|
|
|
krebs.nginx.servers = assert config.krebs.nginx.enable; {
|
2015-10-19 21:50:08 +02:00
|
|
|
retiolum-boot-ssl = {
|
|
|
|
server-names = singleton cfg.hostname;
|
2015-10-20 19:59:59 +02:00
|
|
|
listen = cfg.listen;
|
2015-10-19 21:50:08 +02:00
|
|
|
extraConfig = ''
|
|
|
|
ssl_certificate ${cfg.ssl_certificate};
|
|
|
|
ssl_certificate_key ${cfg.ssl_certificate_key};
|
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;
|
|
|
|
'';
|
|
|
|
locations = [];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
out
|