tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/mainsail: init
Bernardo Meurer
2 years ago
4804f7a0
78963777
+68
-1
3 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
misc
moonraker.nix
web-apps
mainsail.nix
+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
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
75
-
cors_domains = [ "https://app.fluidd.xyz" ];
75
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
1
+
{ config, lib, pkgs, ... }:
2
2
+
with lib;
3
3
+
let
4
4
+
cfg = config.services.mainsail;
5
5
+
moonraker = config.services.moonraker;
6
6
+
in
7
7
+
{
8
8
+
options.services.mainsail = {
9
9
+
enable = mkEnableOption (lib.mdDoc "a modern and responsive user interface for Klipper");
10
10
+
11
11
+
package = mkOption {
12
12
+
type = types.package;
13
13
+
description = lib.mdDoc "Mainsail package to be used in the module";
14
14
+
default = pkgs.mainsail;
15
15
+
defaultText = literalExpression "pkgs.mainsail";
16
16
+
};
17
17
+
18
18
+
hostName = mkOption {
19
19
+
type = types.str;
20
20
+
default = "localhost";
21
21
+
description = lib.mdDoc "Hostname to serve mainsail on";
22
22
+
};
23
23
+
24
24
+
nginx = mkOption {
25
25
+
type = types.submodule
26
26
+
(import ../web-servers/nginx/vhost-options.nix { inherit config lib; });
27
27
+
default = { };
28
28
+
example = literalExpression ''
29
29
+
{
30
30
+
serverAliases = [ "mainsail.''${config.networking.domain}" ];
31
31
+
}
32
32
+
'';
33
33
+
description = lib.mdDoc "Extra configuration for the nginx virtual host of mainsail.";
34
34
+
};
35
35
+
};
36
36
+
37
37
+
config = mkIf cfg.enable {
38
38
+
services.nginx = {
39
39
+
enable = true;
40
40
+
upstreams.mainsail-apiserver.servers."${moonraker.address}:${toString moonraker.port}" = { };
41
41
+
virtualHosts."${cfg.hostName}" = mkMerge [
42
42
+
cfg.nginx
43
43
+
{
44
44
+
root = mkForce "${cfg.package}/share/mainsail";
45
45
+
locations = {
46
46
+
"/" = {
47
47
+
index = "index.html";
48
48
+
tryFiles = "$uri $uri/ /index.html";
49
49
+
};
50
50
+
"/index.html".extraConfig = ''
51
51
+
add_header Cache-Control "no-store, no-cache, must-revalidate";
52
52
+
'';
53
53
+
"/websocket" = {
54
54
+
proxyWebsockets = true;
55
55
+
proxyPass = "http://mainsail-apiserver/websocket";
56
56
+
};
57
57
+
"~ ^/(printer|api|access|machine|server)/" = {
58
58
+
proxyWebsockets = true;
59
59
+
proxyPass = "http://mainsail-apiserver$request_uri";
60
60
+
};
61
61
+
};
62
62
+
}
63
63
+
];
64
64
+
};
65
65
+
};
66
66
+
}