From 32ba6d0d1e404833c8792c3e14572835fe367345 Mon Sep 17 00:00:00 2001 From: aprilthepink Date: Fri, 3 May 2024 02:19:10 +0200 Subject: [PATCH] chore: format --- flake.nix | 10 +++++----- module.nix | 45 +++++++++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/flake.nix b/flake.nix index edbefd7..d8bb010 100644 --- a/flake.nix +++ b/flake.nix @@ -17,12 +17,12 @@ inputs.flake-parts.lib.mkFlake { inherit inputs self; } { systems = import inputs.systems; flake = { - nixosModules = { - default = { - imports = [ ./module.nix ]; - nixpkgs.overlays = [ self.overlays.default ]; - }; + nixosModules = { + default = { + imports = [ ./module.nix ]; + nixpkgs.overlays = [ self.overlays.default ]; }; + }; }; imports = [ inputs.treefmt-nix.flakeModule diff --git a/module.nix b/module.nix index e828b58..fbc397f 100644 --- a/module.nix +++ b/module.nix @@ -43,30 +43,31 @@ let ensureDatabases = lib.singleton cfg.settings.db.dbname; }; }; - nginxConfig = lib.mkIf cfg.nginx.enable { - services.nginx = let - ip = if cfg.address == "0.0.0.0" then "127.0.0.1" else cfg.address; - in - { - enable = true; - virtualHosts.${cfg.domain} = { - locations."/".proxyPass = - if cfg.serviceScale == 1 then - "http://${ip}:${toString cfg.port}" - else "http://upstream-invidious"; + nginxConfig = lib.mkIf cfg.nginx.enable { + services.nginx = + let + ip = if cfg.address == "0.0.0.0" then "127.0.0.1" else cfg.address; + in + { + enable = true; + virtualHosts.${cfg.domain} = { + locations."/".proxyPass = + if cfg.serviceScale == 1 then + "http://${ip}:${toString cfg.port}" + else "http://upstream-invidious"; - enableACME = lib.mkDefault true; - forceSSL = lib.mkDefault true; + enableACME = lib.mkDefault true; + forceSSL = lib.mkDefault true; + }; + upstreams = lib.mkIf (cfg.serviceScale > 1) { + "upstream-invidious".servers = builtins.listToAttrs (builtins.genList + (scaleIndex: { + name = "${ip}:${toString (cfg.port + scaleIndex)}"; + value = { }; + }) + cfg.serviceScale); + }; }; - upstreams = lib.mkIf (cfg.serviceScale > 1) { - "upstream-invidious".servers = builtins.listToAttrs (builtins.genList - (scaleIndex: { - name = "${ip}:${toString (cfg.port + scaleIndex)}"; - value = { }; - }) - cfg.serviceScale); - }; - }; assertions = [{ assertion = cfg.domain != null;