1 { config, lib, pkgs, ... }:
4 cfg = config.services.fluidd;
5 moonraker = config.services.moonraker;
8 options.services.fluidd = {
9 enable = mkEnableOption "Fluidd, a Klipper web interface for managing your 3d printer";
11 package = mkPackageOption pkgs "fluidd" { };
15 default = "localhost";
16 description = "Hostname to serve fluidd on";
20 type = types.submodule
21 (import ../web-servers/nginx/vhost-options.nix { inherit config lib; });
23 example = literalExpression ''
25 serverAliases = [ "fluidd.''${config.networking.domain}" ];
28 description = "Extra configuration for the nginx virtual host of fluidd.";
32 config = mkIf cfg.enable {
35 upstreams.fluidd-apiserver.servers."${moonraker.address}:${toString moonraker.port}" = { };
36 virtualHosts."${cfg.hostName}" = mkMerge [
39 root = mkForce "${cfg.package}/share/fluidd/htdocs";
43 tryFiles = "$uri $uri/ /index.html";
45 "/index.html".extraConfig = ''
46 add_header Cache-Control "no-store, no-cache, must-revalidate";
49 proxyWebsockets = true;
50 proxyPass = "http://fluidd-apiserver/websocket";
52 "~ ^/(printer|api|access|machine|server)/" = {
53 proxyWebsockets = true;
54 proxyPass = "http://fluidd-apiserver$request_uri";