stockholm/modules/tv/nginx/config.nix

50 lines
1008 B
Nix
Raw Normal View History

2015-06-22 16:20:25 +00:00
{ cfg, config, lib, pkgs, ... }:
let
inherit (lib) concatStrings replaceChars;
indent = replaceChars ["\n"] ["\n "];
to-location = { name, value }: ''
location ${name} {
${indent value}
}
'';
in
{
services.nginx =
let
name = config.tv.retiolum.name;
2015-06-22 16:20:25 +00:00
qname = "${name}.retiolum";
in
assert config.tv.retiolum.enable;
2015-06-22 16:20:25 +00:00
{
enable = true;
httpConfig = ''
include ${pkgs.nginx}/conf/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80 default_server;
server_name _;
location / {
return 404;
}
}
server {
listen 80;
server_name ${name} ${qname};
${indent (concatStrings (map to-location cfg.retiolum-locations))}
location / {
return 404;
}
}
'';
};
}