aboutsummaryrefslogtreecommitdiff
path: root/nixos/serverModules/nginx.nix
diff options
context:
space:
mode:
authorspl3g <notspl3g@duck.com>2026-03-18 18:01:41 +0300
committerspl3g <notspl3g@duck.com>2026-03-18 18:01:59 +0300
commit03648b3d9f177227df40129bed22558f6924b91c (patch)
tree8a22eda142beeafd9002a8d5901ba9428a77ad52 /nixos/serverModules/nginx.nix
parentdc19a2b583b3ab50d8e36ff0a90ca633495f675f (diff)
so.. v2 i guess
Diffstat (limited to 'nixos/serverModules/nginx.nix')
-rw-r--r--nixos/serverModules/nginx.nix136
1 files changed, 0 insertions, 136 deletions
diff --git a/nixos/serverModules/nginx.nix b/nixos/serverModules/nginx.nix
deleted file mode 100644
index 9e249d9..0000000
--- a/nixos/serverModules/nginx.nix
+++ /dev/null
@@ -1,136 +0,0 @@
-{ pkgs, config, lib, ... }:
-with lib;
-let
- vhostOptions = import (pkgs.path + "/nixos/modules/services/web-servers/nginx/vhost-options.nix");
- locationOptions = import (pkgs.path + "/nixos/modules/services/web-servers/nginx/location-options.nix");
- nginxOptions = import (pkgs.path + "/nixos/modules/services/web-servers/nginx/default.nix");
- cfg = config.nginx;
-in
-{
- options.nginx = {
- enable = mkEnableOption "Enable nginx";
-
- domain = mkOption {
- type = types.str;
- description = ''
- Domain to use with subdomains
- '';
- };
-
- recommendedProxySettings = mkOption {
- type = types.bool;
- default = true;
- description = ''
- Enables global recommended proxy settings
- '';
- };
-
- subdomains = mkOption {
- type = types.attrsOf (types.submodule (locationOptions { inherit config lib; }));
- description = ''
- Subdomains with nginx virtualHosts configuration
- '';
- };
-
- extraVirtualHosts = mkOption {
- type = types.attrsOf (types.submodule (vhostOptions { inherit config lib; }));
- default = {};
- };
-
- home = {
- virtualHosts = mkOption {
- type = types.attrsOf (types.submodule (vhostOptions { inherit config lib; }));
- default = {};
- description = ''
- Virtual hosts from another nginx configuration, that will be used to decrypt ssl and forward traffic to another server.
- Make sure that the connection between the two is secure.
- '';
- };
-
- subdomains = mkOption {
- type = types.attrsOf (types.submodule (locationOptions { inherit config lib; }));
- default = {};
- description = ''
- Subdomains from another nginx configuration, that will be used to decrypt ssl and forward traffic to another server.
- Make sure that the connection between the two is secure.
- '';
- };
-
- domain = mkOption {
- type = types.str;
- default = cfg.domain;
- description = ''
- Home domain, if no domain provided, the current will be used;
- '';
- };
-
- url = mkOption {
- type = types.str;
- default = "";
- description = ''
- Url that requests would be passed to;
- '';
- };
- };
-
- acme = {
- enable = mkEnableOption "enable acme certs";
- email = mkOption {
- type = types.str;
- default = "notspl3g+acme@duck.com";
- };
- };
-
- extraConfig = mkOption {
- type = types.attrsOf (types.submodule nginxOptions);
- default = {};
- description = ''
- Extra nginx config.
- '';
- };
- };
-
- config = mkIf cfg.enable {
- security.acme = mkIf cfg.acme.enable {
- acceptTerms = true;
- defaults.email = cfg.acme.email;
- };
-
- users.groups.nginx = mkIf cfg.acme.enable {};
- users.users.nginx = mkIf cfg.acme.enable {
- group = "nginx";
- extraGroups = [ "acme" ];
- isSystemUser = true;
- };
- services.nginx =
- let
- ssl = {
- forceSSL = cfg.acme.enable;
- enableACME = cfg.acme.enable;
- };
-
- makeVhosts = (domain: subdomains:
- lib.concatMapAttrs
- (name: value: { ${name + "." + domain} = { locations."/" = value; } // ssl; })
- subdomains);
-
- homeRoutes = (homeVirtualHosts: homeUrl:
- builtins.mapAttrs
- (name: value: {
- locations."/" = value.locations."/" // {
- proxyPass = homeUrl;
- recommendedProxySettings = true;
- };
- } // ssl)
- homeVirtualHosts);
-
- vhosts = (makeVhosts cfg.domain cfg.subdomains);
- homeVhosts = (homeRoutes ((makeVhosts (cfg.home.domain) cfg.home.subdomains) // cfg.home.virtualHosts) cfg.home.url);
- in {
- enable = true;
- recommendedProxySettings = cfg.recommendedProxySettings;
-
- virtualHosts = vhosts // homeVhosts // cfg.extraVirtualHosts;
- } // cfg.extraConfig;
- };
-}