fix nginx type check

This commit is contained in:
陈浩南 2023-11-07 16:16:04 +08:00
parent 35c183f9dc
commit bc351ff0d4

View File

@ -23,8 +23,7 @@ inputs:
detectAuth = mkOption { type = types.bool; default = false; };
locations = mkOption
{
type = types.attrsOf (types.addCheck
(types.submodule { options =
type = types.attrsOf (types.submodule { options =
{
proxy = mkOption
{
@ -55,8 +54,7 @@ inputs:
};});
default = null;
};
};})
(value: (inputs.lib.count (value: value != null) (builtins.attrValues value)) == 1));
};});
default = {};
};
};});
@ -88,11 +86,18 @@ inputs:
inherit (inputs.lib) mkMerge mkIf;
inherit (inputs.localLib) stripeTabs attrsToList;
inherit (inputs.config.nixos.services) nginx;
inherit (builtins) map listToAttrs concatStringsSep toString filter attrValues;
inherit (builtins) map listToAttrs concatStringsSep toString filter attrValues concatLists;
in mkMerge
[
(mkIf nginx.enable
{
assertions =
[{
assertion = builtins.all
(path: (inputs.lib.count (x: x != null) (map (type: path.${type}) [ "proxy" "static" "php" ])) == 1)
(concatLists (map (http: attrValues http.locations) (attrValues nginx.http)));
message = "";
}];
services =
{
nginx =
@ -265,7 +270,7 @@ inputs:
(cert: { inherit (cert) name; value.group = inputs.config.services.nginx.group; })
(attrsToList nginx.http));
})
(mkIf nginx.transparentProxy.enable
(mkIf (nginx.enable && nginx.transparentProxy.enable)
{
services.nginx.streamConfig =
''
@ -348,7 +353,7 @@ inputs:
wantedBy= [ "multi-user.target" ];
};
})
(mkIf nginx.streamProxy.enable
(mkIf (nginx.enable && nginx.streamProxy.enable)
{
services.nginx =
{