From 2bc5c58d85990e483af8fde57ed5f2442351b69c Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 11 Jul 2015 19:44:12 +0200 Subject: move old stuff --- old/modules/tv/nginx/config.nix | 49 ++++++++++++++++++++++++++++++++++++++++ old/modules/tv/nginx/default.nix | 11 +++++++++ old/modules/tv/nginx/options.nix | 21 +++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 old/modules/tv/nginx/config.nix create mode 100644 old/modules/tv/nginx/default.nix create mode 100644 old/modules/tv/nginx/options.nix (limited to 'old/modules/tv/nginx') diff --git a/old/modules/tv/nginx/config.nix b/old/modules/tv/nginx/config.nix new file mode 100644 index 000000000..4bfd8ad28 --- /dev/null +++ b/old/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.tv.retiolum.name; + qname = "${name}.retiolum"; + in + assert config.tv.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; + } + } + ''; + }; +} diff --git a/old/modules/tv/nginx/default.nix b/old/modules/tv/nginx/default.nix new file mode 100644 index 000000000..49133fbb3 --- /dev/null +++ b/old/modules/tv/nginx/default.nix @@ -0,0 +1,11 @@ +arg@{ config, pkgs, lib, ... }: + +let + cfg = config.tv.nginx; + arg' = arg // { inherit cfg; }; +in + +{ + options.tv.nginx = import ./options.nix arg'; + config = lib.mkIf cfg.enable (import ./config.nix arg'); +} diff --git a/old/modules/tv/nginx/options.nix b/old/modules/tv/nginx/options.nix new file mode 100644 index 000000000..ddfb38049 --- /dev/null +++ b/old/modules/tv/nginx/options.nix @@ -0,0 +1,21 @@ +{ lib, ... }: + +let + inherit (lib) mkOption types; +in + +{ + enable = mkOption { + type = types.bool; + default = false; + description = "Enable nginx."; + }; + + retiolum-locations = mkOption { + type = with types; listOf (attrsOf str); + default = []; + description = '' + TODO + ''; + }; +} -- cgit v1.2.3