diff --git a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml index 58e0953e7de2..a138d4c8780c 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml @@ -182,6 +182,16 @@ + + + + fluidd, a + Klipper web interface for managing 3d printers using + moonraker. Available as + fluidd. + + +
Backward Incompatibilities diff --git a/nixos/doc/manual/release-notes/rl-2111.section.md b/nixos/doc/manual/release-notes/rl-2111.section.md index 33955e0437e1..35d65dc43cf3 100644 --- a/nixos/doc/manual/release-notes/rl-2111.section.md +++ b/nixos/doc/manual/release-notes/rl-2111.section.md @@ -56,6 +56,8 @@ pt-services.clipcat.enable). * [navidrome](https://www.navidrome.org/), a personal music streaming server with subsonic-compatible api. Available as [navidrome](#opt-services.navidrome.enable). +- [fluidd](https://docs.fluidd.xyz/), a Klipper web interface for managing 3d printers using moonraker. Available as [fluidd](#opt-services.fluidd.enable). + ## Backward Incompatibilities {#sec-release-21.11-incompatibilities} - The `paperless` module and package have been removed. All users should migrate to the diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 931b9d039ab7..2473bf2f55fb 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -953,6 +953,7 @@ ./services/web-apps/documize.nix ./services/web-apps/dokuwiki.nix ./services/web-apps/engelsystem.nix + ./services/web-apps/fluidd.nix ./services/web-apps/galene.nix ./services/web-apps/gerrit.nix ./services/web-apps/gotify-server.nix diff --git a/nixos/modules/services/web-apps/fluidd.nix b/nixos/modules/services/web-apps/fluidd.nix new file mode 100644 index 000000000000..c632b8ff7199 --- /dev/null +++ b/nixos/modules/services/web-apps/fluidd.nix @@ -0,0 +1,64 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.services.fluidd; + moonraker = config.services.moonraker; +in +{ + options.services.fluidd = { + enable = mkEnableOption "Fluidd, a Klipper web interface for managing your 3d printer"; + + package = mkOption { + type = types.package; + description = "Fluidd package to be used in the module"; + default = pkgs.fluidd; + defaultText = "pkgs.fluidd"; + }; + + hostName = mkOption { + type = types.str; + default = "localhost"; + description = "Hostname to serve fluidd on"; + }; + + nginx = mkOption { + type = types.submodule + (import ../web-servers/nginx/vhost-options.nix { inherit config lib; }); + default = { }; + example = { + serverAliases = [ "fluidd.\${config.networking.domain}" ]; + }; + description = "Extra configuration for the nginx virtual host of fluidd."; + }; + }; + + config = mkIf cfg.enable { + services.nginx = { + enable = true; + upstreams.fluidd-apiserver.servers."${moonraker.address}:${toString moonraker.port}" = { }; + virtualHosts."${cfg.hostName}" = mkMerge [ + cfg.nginx + { + root = mkForce "${cfg.package}/share/fluidd/htdocs"; + locations = { + "/" = { + index = "index.html"; + tryFiles = "$uri $uri/ /index.html"; + }; + "/index.html".extraConfig = '' + add_header Cache-Control "no-store, no-cache, must-revalidate"; + ''; + "/websocket" = { + proxyWebsockets = true; + proxyPass = "http://fluidd-apiserver/websocket"; + }; + "~ ^/(printer|api|access|machine|server)/" = { + proxyWebsockets = true; + proxyPass = "http://fluidd-apiserver$request_uri"; + }; + }; + } + ]; + }; + }; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index d17904c776e7..314c031bb3d4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -136,6 +136,7 @@ in fish = handleTest ./fish.nix {}; flannel = handleTestOn ["x86_64-linux"] ./flannel.nix {}; fluentd = handleTest ./fluentd.nix {}; + fluidd = handleTest ./fluidd.nix {}; fontconfig-default-fonts = handleTest ./fontconfig-default-fonts.nix {}; freeswitch = handleTest ./freeswitch.nix {}; fsck = handleTest ./fsck.nix {}; diff --git a/nixos/tests/fluidd.nix b/nixos/tests/fluidd.nix new file mode 100644 index 000000000000..f49a4110d714 --- /dev/null +++ b/nixos/tests/fluidd.nix @@ -0,0 +1,21 @@ +import ./make-test-python.nix ({ lib, ... }: + +with lib; + +{ + name = "fluidd"; + meta.maintainers = with maintainers; [ vtuan10 ]; + + nodes.machine = { pkgs, ... }: { + services.fluidd = { + enable = true; + }; + }; + + testScript = '' + machine.start() + machine.wait_for_unit("nginx.service") + machine.wait_for_open_port(80) + machine.succeed("curl -sSfL http://localhost/ | grep 'fluidd'") + ''; +})