Revert "nixos: Multiple service instances, apply to nginx. See #6784"
This reverts commit 7ef59c4fe2a87682054572a504fc7c6046c282e5. Wrong push! Sorry!
This commit is contained in:
parent
7ef59c4fe2
commit
cb45b7ec3e
@ -227,19 +227,4 @@ rec {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mkMultiInstance = path: args: f:
|
|
||||||
let
|
|
||||||
def = f (args // { name = "default"; config = getAttrFromPath path args.config; });
|
|
||||||
in {
|
|
||||||
options = setAttrByPath path (def.options // {
|
|
||||||
instances = mkOption {
|
|
||||||
type = types.attrsOf (types.submodule f);
|
|
||||||
default = {};
|
|
||||||
description = "Additional instances of this service";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
config = def.config;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
{ config, lib, pkgs, ... }@args:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let topconfig = config;
|
|
||||||
in mkMultiInstance [ "services" "nginx" ] args ({ config, name, ... }:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config;
|
cfg = config.services.nginx;
|
||||||
nginx = cfg.package;
|
nginx = cfg.package;
|
||||||
configFile = pkgs.writeText "nginx.conf" ''
|
configFile = pkgs.writeText "nginx.conf" ''
|
||||||
user ${cfg.user} ${cfg.group};
|
user ${cfg.user} ${cfg.group};
|
||||||
@ -23,6 +20,7 @@ in
|
|||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
services.nginx = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
@ -84,13 +82,15 @@ in
|
|||||||
description = "Group account under which nginx runs.";
|
description = "Group account under which nginx runs.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
# TODO: test user supplied config file pases syntax test
|
# TODO: test user supplied config file pases syntax test
|
||||||
|
|
||||||
systemd.services."nginx-${name}" = {
|
systemd.services.nginx = {
|
||||||
description = "Nginx Web Server - ${name}";
|
description = "Nginx Web Server";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ nginx ];
|
path = [ nginx ];
|
||||||
@ -111,12 +111,12 @@ in
|
|||||||
users.extraUsers = optionalAttrs (cfg.user == "nginx") (singleton
|
users.extraUsers = optionalAttrs (cfg.user == "nginx") (singleton
|
||||||
{ name = "nginx";
|
{ name = "nginx";
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
uid = topconfig.ids.uids.nginx;
|
uid = config.ids.uids.nginx;
|
||||||
});
|
});
|
||||||
|
|
||||||
users.extraGroups = optionalAttrs (cfg.group == "nginx") (singleton
|
users.extraGroups = optionalAttrs (cfg.group == "nginx") (singleton
|
||||||
{ name = "nginx";
|
{ name = "nginx";
|
||||||
gid = topconfig.ids.gids.nginx;
|
gid = config.ids.gids.nginx;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
})
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user