From fc8cc14095cb7498cb8917477fb4d51d6ec0e093 Mon Sep 17 00:00:00 2001 From: Ethan Turkeltaub Date: Thu, 1 Jan 2026 11:51:03 -0500 Subject: [PATCH 1/2] Replace StirlingPDF with BentoPDF --- hosts/bastion/profiles/caddy/default.nix | 8 +-- hosts/matrix/configuration.nix | 1 + modules/nixos/services/bentopdf/default.nix | 64 +++++++++++++++++++ modules/overlays/default.nix | 3 +- modules/packages/bentopdf/default.nix | 35 ++++++++++ modules/packages/default.nix | 3 +- .../profiles/observability/gatus/default.nix | 2 +- modules/profiles/services/bentopdf.nix | 7 ++ 8 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 modules/nixos/services/bentopdf/default.nix create mode 100644 modules/packages/bentopdf/default.nix create mode 100644 modules/profiles/services/bentopdf.nix diff --git a/hosts/bastion/profiles/caddy/default.nix b/hosts/bastion/profiles/caddy/default.nix index 7bd1acd..5805c18 100644 --- a/hosts/bastion/profiles/caddy/default.nix +++ b/hosts/bastion/profiles/caddy/default.nix @@ -209,14 +209,8 @@ "pdf.e10.camp" = { host = hosts.matrix; - port = - hosts.matrix.config.services.stirling-pdf.environment.SERVER_PORT; + inherit (hosts.matrix.config.services.bentopdf) port; protected = true; - extraConfig = '' - request_body { - max_size 2GiB - } - ''; }; "mazanoke.e10.camp" = { diff --git a/hosts/matrix/configuration.nix b/hosts/matrix/configuration.nix index d81a3e0..db49f0c 100644 --- a/hosts/matrix/configuration.nix +++ b/hosts/matrix/configuration.nix @@ -10,6 +10,7 @@ profiles.networking.printing profiles.power.tripp-lite-smart1500lcd profiles.services.attic-watch-store.default + profiles.services.bentopdf profiles.services.changedetection-io profiles.services.e10-land profiles.services.glance.default diff --git a/modules/nixos/services/bentopdf/default.nix b/modules/nixos/services/bentopdf/default.nix new file mode 100644 index 0000000..46d7674 --- /dev/null +++ b/modules/nixos/services/bentopdf/default.nix @@ -0,0 +1,64 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.bentopdf; +in { + options.services.bentopdf = { + enable = mkEnableOption "Enable bentopdf"; + + package = mkPackageOption pkgs "bentopdf" { + extraDescription = '' + To use the "simple mode" variant of bentopdf, which removes all socials, marketing and explanatory texts, + set this option to `pkgs.bentopdf.overrideAttrs { SIMPLE_MODE = true; }` + ''; + }; + + host = mkOption { + type = types.str; + default = "0.0.0.0"; + description = "The host to listen on."; + }; + + port = mkOption { + type = types.port; + default = 4152; + description = "The port nginx is listening on for bentopdf."; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + description = "Open the port nginx is listening on for bentopdf."; + }; + }; + + config = mkIf cfg.enable { + services.nginx = { + enable = true; + + virtualHosts."bentopdf" = { + listen = [{ + addr = cfg.host; + inherit (cfg) port; + }]; + + root = cfg.package; + + locations."/".extraConfig = '' + try_files $uri $uri/ /index.html; + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + ''; + + locations."~* .(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$".extraConfig = + '' + expires 1y; + add_header Cache-Control "public, immutable"; + ''; + }; + }; + + networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port; + }; +} diff --git a/modules/overlays/default.nix b/modules/overlays/default.nix index fcc3fbb..cd0b8e5 100644 --- a/modules/overlays/default.nix +++ b/modules/overlays/default.nix @@ -20,7 +20,8 @@ # This is to pick up bugfix here: https://github.com/thanos-io/thanos/issues/7923 inherit (nixpkgs-master) thanos; - inherit (self'.packages) fileflows mongodb-ce-6_0; # caddy-with-plugins; + inherit (self'.packages) + bentopdf fileflows mongodb-ce-6_0; # caddy-with-plugins; }; }; } diff --git a/modules/packages/bentopdf/default.nix b/modules/packages/bentopdf/default.nix new file mode 100644 index 0000000..d3e39e6 --- /dev/null +++ b/modules/packages/bentopdf/default.nix @@ -0,0 +1,35 @@ +{ lib, buildNpmPackage, fetchFromGitHub, }: + +buildNpmPackage (finalAttrs: { + version = "1.11.2"; + pname = "bentopdf"; + + src = fetchFromGitHub { + owner = "alam00000"; + repo = "bentopdf"; + tag = "v${finalAttrs.version}"; + hash = "sha256-br4My0Q4zoA+ZIrXM4o4oQjZ7IpSdwg+iKiAUdc2B/s="; + }; + npmDepsHash = "sha256-UNNNYO7e7qdumI0/ka2ieFZzKURPl1V3981vHCPcVfY="; + + npmBuildScript = "build"; + npmBuildFlags = [ "--" "--mode" "production" ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r dist/* $out/ + + runHook postInstall + ''; + + meta = { + description = "Privacy-first PDF toolkit"; + mainProgram = "bentopdf"; + homepage = "https://bentopdf.com"; + changelog = "https://github.com/alam00000/bentopdf/releases"; + license = lib.licenses.asl20; + maintainers = [ ]; + }; +}) diff --git a/modules/packages/default.nix b/modules/packages/default.nix index b204d92..6ef34d3 100644 --- a/modules/packages/default.nix +++ b/modules/packages/default.nix @@ -1,8 +1,9 @@ _: { perSystem = { pkgs, ... }: { packages = { - mongodb-ce-6_0 = pkgs.callPackage ./mongodb-ce-6_0 { }; + bentopdf = pkgs.callPackage ./bentopdf { }; fileflows = pkgs.callPackage ./fileflows { }; + mongodb-ce-6_0 = pkgs.callPackage ./mongodb-ce-6_0 { }; }; }; } diff --git a/modules/profiles/observability/gatus/default.nix b/modules/profiles/observability/gatus/default.nix index 737119b..b5d928a 100644 --- a/modules/profiles/observability/gatus/default.nix +++ b/modules/profiles/observability/gatus/default.nix @@ -269,7 +269,7 @@ in { config, lib, ... }: { group = "Matrix"; }) (mkEndpoint { - name = "Stirling PDF"; + name = "BentoPDF"; url = "https://pdf.e10.camp"; group = "Matrix"; protected = true; diff --git a/modules/profiles/services/bentopdf.nix b/modules/profiles/services/bentopdf.nix new file mode 100644 index 0000000..95341b0 --- /dev/null +++ b/modules/profiles/services/bentopdf.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: { + services.bentopdf = { + enable = true; + package = pkgs.bentopdf.overrideAttrs { SIMPLE_MODE = true; }; + openFirewall = true; + }; +} From 457586687f9194b74be55cd2b8e61d4c4f3a847f Mon Sep 17 00:00:00 2001 From: Ethan Turkeltaub Date: Thu, 1 Jan 2026 14:16:07 -0500 Subject: [PATCH 2/2] Update Glance --- hosts/matrix/configuration.nix | 1 - modules/profiles/services/glance/default.nix | 4 ++-- modules/profiles/services/stirling-pdf.nix | 6 ------ 3 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 modules/profiles/services/stirling-pdf.nix diff --git a/hosts/matrix/configuration.nix b/hosts/matrix/configuration.nix index db49f0c..8152203 100644 --- a/hosts/matrix/configuration.nix +++ b/hosts/matrix/configuration.nix @@ -18,7 +18,6 @@ profiles.services.miniflux.default profiles.services.netbox.default profiles.services.paperless.default - profiles.services.stirling-pdf profiles.telemetry.prometheus-nut-exporter profiles.virtualisation.docker profiles.web-servers.caddy diff --git a/modules/profiles/services/glance/default.nix b/modules/profiles/services/glance/default.nix index 61908a3..b29f590 100644 --- a/modules/profiles/services/glance/default.nix +++ b/modules/profiles/services/glance/default.nix @@ -126,9 +126,9 @@ icon = "di:blocky"; } { - title = "Stirling PDF"; + title = "BentoPDF"; url = "https://pdf.e10.camp"; - icon = "di:stirling-pdf"; + icon = "di:bentopdf"; alt-status-codes = [ 401 ]; } { diff --git a/modules/profiles/services/stirling-pdf.nix b/modules/profiles/services/stirling-pdf.nix deleted file mode 100644 index 673d85c..0000000 --- a/modules/profiles/services/stirling-pdf.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - services.stirling-pdf = { - enable = true; - environment = { SERVER_PORT = 9123; }; - }; -}