summaryrefslogtreecommitdiffstats
path: root/3modules/tv
diff options
context:
space:
mode:
Diffstat (limited to '3modules/tv')
-rw-r--r--3modules/tv/git.nix2
-rw-r--r--3modules/tv/nginx.nix75
2 files changed, 40 insertions, 37 deletions
diff --git a/3modules/tv/git.nix b/3modules/tv/git.nix
index 7170d2ebc..caa53d566 100644
--- a/3modules/tv/git.nix
+++ b/3modules/tv/git.nix
@@ -212,7 +212,7 @@ let
tv.nginx = {
enable = true;
- retiolum-locations = [
+ servers.default.locations = [
(nameValuePair "/cgit/" ''
include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
diff --git a/3modules/tv/nginx.nix b/3modules/tv/nginx.nix
index 93cd88aac..dfb4d6947 100644
--- a/3modules/tv/nginx.nix
+++ b/3modules/tv/nginx.nix
@@ -13,46 +13,41 @@ let
api = {
enable = mkEnableOption "tv.nginx";
- retiolum-locations = mkOption {
- type = with types; listOf (attrsOf str);
- default = [];
+ servers = mkOption {
+ type = with types; attrsOf optionSet;
+ options = singleton {
+ server-names = mkOption {
+ type = with types; listOf str;
+ default = [
+ "${config.networking.hostName}"
+ "${config.networking.hostName}.retiolum"
+ ];
+ };
+ locations = mkOption {
+ type = with types; listOf (attrsOf str);
+ };
+ };
+ default = {};
};
};
imp = {
- 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;
- }
- }
- '';
- };
+ services.nginx = {
+ 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 _;
+ return 404;
+ }
+ ${concatStrings (mapAttrsToList (_: to-server) cfg.servers)}
+ '';
+ };
};
@@ -64,6 +59,14 @@ let
}
'';
+ to-server = { server-names, locations, ... }: ''
+ server {
+ listen 80;
+ server_name ${toString server-names};
+ ${indent (concatStrings (map to-location locations))}
+ }
+ '';
+
in
out