lol

nixos/mainsail: init

+68 -1
+1
nixos/modules/module-list.nix
··· 1189 1189 ./services/web-apps/komga.nix 1190 1190 ./services/web-apps/lemmy.nix 1191 1191 ./services/web-apps/limesurvey.nix 1192 + ./services/web-apps/mainsail.nix 1192 1193 ./services/web-apps/mastodon.nix 1193 1194 ./services/web-apps/matomo.nix 1194 1195 ./services/web-apps/mattermost.nix
+1 -1
nixos/modules/services/misc/moonraker.nix
··· 72 72 example = { 73 73 authorization = { 74 74 trusted_clients = [ "10.0.0.0/24" ]; 75 - cors_domains = [ "https://app.fluidd.xyz" ]; 75 + cors_domains = [ "https://app.fluidd.xyz" "https://my.mainsail.xyz" ]; 76 76 }; 77 77 }; 78 78 description = lib.mdDoc ''
+66
nixos/modules/services/web-apps/mainsail.nix
··· 1 + { config, lib, pkgs, ... }: 2 + with lib; 3 + let 4 + cfg = config.services.mainsail; 5 + moonraker = config.services.moonraker; 6 + in 7 + { 8 + options.services.mainsail = { 9 + enable = mkEnableOption (lib.mdDoc "a modern and responsive user interface for Klipper"); 10 + 11 + package = mkOption { 12 + type = types.package; 13 + description = lib.mdDoc "Mainsail package to be used in the module"; 14 + default = pkgs.mainsail; 15 + defaultText = literalExpression "pkgs.mainsail"; 16 + }; 17 + 18 + hostName = mkOption { 19 + type = types.str; 20 + default = "localhost"; 21 + description = lib.mdDoc "Hostname to serve mainsail on"; 22 + }; 23 + 24 + nginx = mkOption { 25 + type = types.submodule 26 + (import ../web-servers/nginx/vhost-options.nix { inherit config lib; }); 27 + default = { }; 28 + example = literalExpression '' 29 + { 30 + serverAliases = [ "mainsail.''${config.networking.domain}" ]; 31 + } 32 + ''; 33 + description = lib.mdDoc "Extra configuration for the nginx virtual host of mainsail."; 34 + }; 35 + }; 36 + 37 + config = mkIf cfg.enable { 38 + services.nginx = { 39 + enable = true; 40 + upstreams.mainsail-apiserver.servers."${moonraker.address}:${toString moonraker.port}" = { }; 41 + virtualHosts."${cfg.hostName}" = mkMerge [ 42 + cfg.nginx 43 + { 44 + root = mkForce "${cfg.package}/share/mainsail"; 45 + locations = { 46 + "/" = { 47 + index = "index.html"; 48 + tryFiles = "$uri $uri/ /index.html"; 49 + }; 50 + "/index.html".extraConfig = '' 51 + add_header Cache-Control "no-store, no-cache, must-revalidate"; 52 + ''; 53 + "/websocket" = { 54 + proxyWebsockets = true; 55 + proxyPass = "http://mainsail-apiserver/websocket"; 56 + }; 57 + "~ ^/(printer|api|access|machine|server)/" = { 58 + proxyWebsockets = true; 59 + proxyPass = "http://mainsail-apiserver$request_uri"; 60 + }; 61 + }; 62 + } 63 + ]; 64 + }; 65 + }; 66 + }