summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2015-03-13 14:11:59 +0000
committerLuca Bruno <lucabru@src.gnome.org>2015-03-18 14:07:29 +0000
commit7ef59c4fe2a87682054572a504fc7c6046c282e5 (patch)
tree0f0af3abb1d6558dfc8a289cc185e85cc31c262d /nixos/modules/services
parent506cbf05a9460ae452c29ebd1324eeae04082a2e (diff)
downloadnixlib-7ef59c4fe2a87682054572a504fc7c6046c282e5.tar
nixlib-7ef59c4fe2a87682054572a504fc7c6046c282e5.tar.gz
nixlib-7ef59c4fe2a87682054572a504fc7c6046c282e5.tar.bz2
nixlib-7ef59c4fe2a87682054572a504fc7c6046c282e5.tar.lz
nixlib-7ef59c4fe2a87682054572a504fc7c6046c282e5.tar.xz
nixlib-7ef59c4fe2a87682054572a504fc7c6046c282e5.tar.zst
nixlib-7ef59c4fe2a87682054572a504fc7c6046c282e5.zip
nixos: Multiple service instances, apply to nginx. See #6784
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/web-servers/nginx/default.nix20
1 files changed, 10 insertions, 10 deletions
diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix
index 0f21ef012639..94dad49f9fd1 100644
--- a/nixos/modules/services/web-servers/nginx/default.nix
+++ b/nixos/modules/services/web-servers/nginx/default.nix
@@ -1,9 +1,12 @@
-{ config, lib, pkgs, ... }:
+{ config, lib, pkgs, ... }@args:
 
 with lib;
 
+let topconfig = config;
+in mkMultiInstance [ "services" "nginx" ] args ({ config, name, ... }:
+
 let
-  cfg = config.services.nginx;
+  cfg = config;
   nginx = cfg.package;
   configFile = pkgs.writeText "nginx.conf" ''
     user ${cfg.user} ${cfg.group};
@@ -20,7 +23,6 @@ in
 
 {
   options = {
-    services.nginx = {
       enable = mkOption {
         default = false;
         type = types.bool;
@@ -82,15 +84,13 @@ in
         description = "Group account under which nginx runs.";
       };
 
-    };
-
   };
 
   config = mkIf cfg.enable {
     # TODO: test user supplied config file pases syntax test
 
-    systemd.services.nginx = {
-      description = "Nginx Web Server";
+    systemd.services."nginx-${name}" = {
+      description = "Nginx Web Server - ${name}";
       after = [ "network.target" ];
       wantedBy = [ "multi-user.target" ];
       path = [ nginx ];
@@ -111,12 +111,12 @@ in
     users.extraUsers = optionalAttrs (cfg.user == "nginx") (singleton
       { name = "nginx";
         group = cfg.group;
-        uid = config.ids.uids.nginx;
+        uid = topconfig.ids.uids.nginx;
       });
 
     users.extraGroups = optionalAttrs (cfg.group == "nginx") (singleton
       { name = "nginx";
-        gid = config.ids.gids.nginx;
+        gid = topconfig.ids.gids.nginx;
       });
   };
-}
+})