nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

commit 2572eaccff0ad5a9c0c7f6ec8c35813da4b2db0b
parent ae5dedba4f054cea6f37d5935b4ba1ec21895396
Author: Nikolay Korotkiy <sikmir@disroot.org>
Date:   Tue, 12 Nov 2024 19:30:30 +0400

Update tracks_storage_server module

Diffstat:
Mmodules/nixos/services/tracks_storage_server.nix | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 60 insertions(+), 14 deletions(-)

diff --git a/modules/nixos/services/tracks_storage_server.nix b/modules/nixos/services/tracks_storage_server.nix @@ -14,21 +14,67 @@ in options.services.tracks_storage_server = { enable = mkEnableOption "tracks_storage_server"; package = mkPackageOption pkgs "tracks_storage_server" { }; - }; - - config = mkIf cfg.enable { - services.uwsgi.enable = true; - services.uwsgi.plugins = [ "python3" ]; - services.uwsgi.instance = { - type = "emperor"; - vassals.tracks = { - type = "normal"; - master = true; - workers = 2; - socket = "127.0.0.1:8181"; - module = "server:application"; - pythonPackages = self: [ cfg.package ]; + nginx = mkOption { + default = { }; + description = '' + Configuration for nginx reverse proxy. + ''; + type = types.submodule { + options = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Configure the nginx reverse proxy settings. + ''; + }; + hostName = mkOption { + type = types.str; + description = '' + The hostname use to setup the virtualhost configuration + ''; + }; + }; }; }; }; + + config = mkIf cfg.enable (mkMerge [ + { + services.uwsgi.enable = true; + services.uwsgi.plugins = [ "python3" ]; + services.uwsgi.instance = { + type = "emperor"; + vassals.tracks = { + type = "normal"; + master = true; + workers = 2; + socket = "127.0.0.1:8181"; + module = "server:application"; + pythonPackages = self: [ cfg.package ]; + }; + }; + } + (mkIf cfg.nginx.enable { + services.nginx = { + enable = true; + virtualHosts."${cfg.nginx.hostName}" = { + locations."/" = { + extraConfig = '' + uwsgi_pass localhost:8181; + include ${config.services.nginx.package}/conf/uwsgi_params; + + more_clear_headers Access-Control-Allow-Origin; + more_clear_headers Access-Control-Allow-Credentials; + more_set_headers 'Access-Control-Allow-Origin: $http_origin'; + more_set_headers 'Access-Control-Allow-Credentials: true'; + more_set_headers 'Cache-Control: max-age=315360000'; + more_set_headers 'Expires: Thu, 31 Dec 2037 23:55:55 GMT'; + more_set_headers 'Vary: Origin'; + ''; + }; + }; + }; + }) + ]); }