mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
chore: nf-fmt-nix
This commit is contained in:
parent
7486517713
commit
9903866044
160 changed files with 4570 additions and 3019 deletions
|
|
@ -1,4 +1,9 @@
|
|||
{pkgs, config, lib, ...}: let
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.modules) mkIf mkMerge mkAfter mkOptionDefault;
|
||||
inherit (lib.strings) hasPrefix;
|
||||
|
|
@ -10,7 +15,8 @@
|
|||
luaModule = {config, ...}: let
|
||||
cfg = config.lua;
|
||||
mkSetBy = var: value:
|
||||
if hasPrefix "/" "${value}" then "set_by_lua_file \$${var} ${value};"
|
||||
if hasPrefix "/" "${value}"
|
||||
then "set_by_lua_file \$${var} ${value};"
|
||||
else ''
|
||||
set_by_lua_block ''$${var} {
|
||||
${value}
|
||||
|
|
@ -25,12 +31,12 @@
|
|||
};
|
||||
files = mkOption {
|
||||
type = listOf path;
|
||||
default = [ ];
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
set = mkOption {
|
||||
type = attrsOf (either path lines);
|
||||
default = { };
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
config = {
|
||||
|
|
@ -40,25 +46,27 @@
|
|||
${cfg.access.block}
|
||||
}
|
||||
''))
|
||||
(mkIf (cfg.access.files != [ ]) (assert lua.http.enable; mkMerge (
|
||||
map (file: "access_by_lua_file ${file};") cfg.access.files
|
||||
)))
|
||||
(mkIf (cfg.set != { }) (assert lua.http.enable && lua.ndk.enable; mkMerge (
|
||||
mapAttrsToList mkSetBy cfg.set
|
||||
)))
|
||||
(mkIf (cfg.access.files != []) (assert lua.http.enable;
|
||||
mkMerge (
|
||||
map (file: "access_by_lua_file ${file};") cfg.access.files
|
||||
)))
|
||||
(mkIf (cfg.set != {}) (assert lua.http.enable && lua.ndk.enable;
|
||||
mkMerge (
|
||||
mapAttrsToList mkSetBy cfg.set
|
||||
)))
|
||||
];
|
||||
};
|
||||
};
|
||||
locationModule = {config, ...}: {
|
||||
imports = [ luaModule ];
|
||||
imports = [luaModule];
|
||||
};
|
||||
hostModule = {config, ...}: {
|
||||
imports = [ luaModule ];
|
||||
imports = [luaModule];
|
||||
|
||||
options = with lib.types; {
|
||||
locations = mkOption {
|
||||
type = attrsOf (submoduleWith {
|
||||
modules = [ locationModule ];
|
||||
modules = [locationModule];
|
||||
shorthandOnlyDefinesConfig = true;
|
||||
});
|
||||
};
|
||||
|
|
@ -84,7 +92,7 @@ in {
|
|||
};
|
||||
virtualHosts = mkOption {
|
||||
type = attrsOf (submoduleWith {
|
||||
modules = [ hostModule ];
|
||||
modules = [hostModule];
|
||||
shorthandOnlyDefinesConfig = true;
|
||||
});
|
||||
};
|
||||
|
|
@ -92,18 +100,20 @@ in {
|
|||
config = {
|
||||
services.nginx = {
|
||||
lua = {
|
||||
modules = [
|
||||
cfg.luaPackage.pkgs.lua-resty-core
|
||||
] ++ cfg.luaPackage.pkgs.lua-resty-core.propagatedBuildInputs;
|
||||
modules =
|
||||
[
|
||||
cfg.luaPackage.pkgs.lua-resty-core
|
||||
]
|
||||
++ cfg.luaPackage.pkgs.lua-resty-core.propagatedBuildInputs;
|
||||
luaPath = mkMerge (
|
||||
map luaPkgPath cfg.modules
|
||||
++ [ (mkAfter ";") ]
|
||||
++ [(mkAfter ";")]
|
||||
);
|
||||
};
|
||||
additionalModules = mkMerge [
|
||||
(mkIf cfg.ndk.enable [ pkgs.nginxModules.develkit ])
|
||||
(mkIf cfg.http.enable [ pkgs.nginxModules.lua ])
|
||||
(mkIf cfg.upstream.enable [ pkgs.nginxModules.lua-upstream ])
|
||||
(mkIf cfg.ndk.enable [pkgs.nginxModules.develkit])
|
||||
(mkIf cfg.http.enable [pkgs.nginxModules.lua])
|
||||
(mkIf cfg.upstream.enable [pkgs.nginxModules.lua-upstream])
|
||||
];
|
||||
};
|
||||
systemd.services.nginx = mkIf config.services.nginx.enable {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue