diff options
author | tv <tv@shackspace.de> | 2015-06-22 18:20:25 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-06-22 18:20:25 +0200 |
commit | 964855f30bcb36869f24cb8474b9a0c44f58a736 (patch) | |
tree | 1056515620276960498f3c7455624802d6173620 /modules/tv/nginx/config.nix | |
parent | f2c8dbe4d126501e271e58c8a3ee3130c46dc0b9 (diff) |
tv: modularize nginx
Diffstat (limited to 'modules/tv/nginx/config.nix')
-rw-r--r-- | modules/tv/nginx/config.nix | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/modules/tv/nginx/config.nix b/modules/tv/nginx/config.nix new file mode 100644 index 000000000..e5c3dd152 --- /dev/null +++ b/modules/tv/nginx/config.nix @@ -0,0 +1,49 @@ +{ 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.services.retiolum.name; + qname = "${name}.retiolum"; + in + assert config.services.retiolum.enable; + { + 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; + } + } + ''; + }; +} |