From 222ca361e38b09ddef563abaaacd114ec86e2a5c Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 19 Oct 2015 20:36:09 +0200 Subject: nginx service: add port option and extraConfig --- krebs/3modules/nginx.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'krebs/3modules/nginx.nix') diff --git a/krebs/3modules/nginx.nix b/krebs/3modules/nginx.nix index 702e8a7f6..65f3b238e 100644 --- a/krebs/3modules/nginx.nix +++ b/krebs/3modules/nginx.nix @@ -24,9 +24,17 @@ let "${config.networking.hostName}.retiolum" ]; }; + port = mkOption { + type = with types; int; + default = 80; + }; locations = mkOption { type = with types; listOf (attrsOf str); }; + extraConfig = mkOption { + type = with types; str; + default = ""; + }; }; default = {}; }; @@ -60,10 +68,11 @@ let } ''; - to-server = { server-names, locations, ... }: '' + to-server = { server-names, port, locations, extraConfig, ... }: '' server { - listen 80; + listen ${toString port}; server_name ${toString server-names}; + ${extraConfig} ${indent (concatStrings (map to-location locations))} } ''; -- cgit v1.2.3 From dc52c4b988ba1e64bf91567f06b89586ca92fa47 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 19 Oct 2015 20:42:18 +0200 Subject: nginx service: replace port by listen --- krebs/3modules/nginx.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'krebs/3modules/nginx.nix') diff --git a/krebs/3modules/nginx.nix b/krebs/3modules/nginx.nix index 65f3b238e..c5f38c271 100644 --- a/krebs/3modules/nginx.nix +++ b/krebs/3modules/nginx.nix @@ -24,9 +24,9 @@ let "${config.networking.hostName}.retiolum" ]; }; - port = mkOption { - type = with types; int; - default = 80; + listen = mkOption { + type = with types; str; + default = "80"; }; locations = mkOption { type = with types; listOf (attrsOf str); @@ -68,9 +68,9 @@ let } ''; - to-server = { server-names, port, locations, extraConfig, ... }: '' + to-server = { server-names, listen, locations, extraConfig, ... }: '' server { - listen ${toString port}; + listen ${listen}; server_name ${toString server-names}; ${extraConfig} ${indent (concatStrings (map to-location locations))} -- cgit v1.2.3 From b2fd7be3ff755e17e9d303f03b9a2345623fd384 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Oct 2015 18:53:11 +0200 Subject: nginx service: allow multiple listen entries --- krebs/3modules/nginx.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'krebs/3modules/nginx.nix') diff --git a/krebs/3modules/nginx.nix b/krebs/3modules/nginx.nix index c5f38c271..0530921a0 100644 --- a/krebs/3modules/nginx.nix +++ b/krebs/3modules/nginx.nix @@ -25,8 +25,12 @@ let ]; }; listen = mkOption { - type = with types; str; + type = with types; either str (listOf str); default = "80"; + apply = x: + if typeOf x != "list" + then [x] + else x; }; locations = mkOption { type = with types; listOf (attrsOf str); @@ -70,7 +74,7 @@ let to-server = { server-names, listen, locations, extraConfig, ... }: '' server { - listen ${listen}; + ${concatMapStringsSep "\n" (x: "listen ${x};") listen} server_name ${toString server-names}; ${extraConfig} ${indent (concatStrings (map to-location locations))} -- cgit v1.2.3