Unverified Commit 1e11752b authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

bentopdf: init at 1.11.2, nixos/bentopdf: init, nixosTests.bentopdf: init (#484169)

parents 477e85d8 d22cd44d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@

- [nohang](https://github.com/hakavlad/nohang), a daemon for Linux that prevents out of memory (OOM) situations from affecting system responsiveness. Available as [services.nohang](#opt-services.nohang.enable)

- [bentopdf](https://github.com/alam00000/bentopdf), a privacy-first PDF toolkit running completely in-browser. Available as [services.bentopdf](#opt-services.bentopdf.enable).

- [DankMaterialShell](https://danklinux.com), a complete desktop shell for Wayland compositors built with Quickshell. Available as [programs.dms-shell](#opt-programs.dms-shell.enable).

- [dms-greeter](https://danklinux.com), a modern display manager greeter for DankMaterialShell that works with greetd and supports multiple Wayland compositors. Available as [services.displayManager.dms-greeter](#opt-services.displayManager.dms-greeter.enable).
+1 −0
Original line number Diff line number Diff line
@@ -1591,6 +1591,7 @@
  ./services/web-apps/artalk.nix
  ./services/web-apps/audiobookshelf.nix
  ./services/web-apps/baikal.nix
  ./services/web-apps/bentopdf.nix
  ./services/web-apps/bluemap.nix
  ./services/web-apps/bluesky-pds.nix
  ./services/web-apps/bookstack.nix
+112 −0
Original line number Diff line number Diff line
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.bentopdf;
in
{
  options.services.bentopdf = {
    enable = lib.mkEnableOption "bentopdf Privacy First PDF Toolkit";

    package = lib.mkPackageOption pkgs "bentopdf" {
      extraDescription = ''
        To use the "normal mode" variant of bentopdf, which includes all socials, marketing and explanatory texts, set this option to `pkgs.bentopdf.override { simpleMode = false; }`.
      '';
    };

    domain = lib.mkOption {
      description = "Domain to use for the virtual host.";
      type = lib.types.str;
    };

    nginx = {
      enable = lib.mkEnableOption "a virtualhost to serve bentopdf through nginx";

      virtualHost = lib.mkOption {
        type = lib.types.submodule (import ../web-servers/nginx/vhost-options.nix { inherit config lib; });
        default = { };
        example = lib.literalExpression ''
          {
            serverAliases = [ "bentopdf.''${config.networking.domain}" ];
          }
        '';
        description = "Extra configuration for the nginx virtual host of bentopdf.";
      };
    };

    caddy = {
      enable = lib.mkEnableOption "a virtualhost to serve bentopdf through caddy";

      virtualHost = lib.mkOption {
        type = lib.types.submodule (
          import ../web-servers/caddy/vhost-options.nix { cfg = config.services.caddy; }
        );
        default = { };
        example = lib.literalExpression ''
          {
            serverAliases = [ "bentopdf.''${config.networking.domain}" ];
          }
        '';
        description = "Extra configuration for the caddy virtual host of bentopdf.";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    services.nginx = lib.mkIf cfg.nginx.enable {
      enable = lib.mkDefault true;
      virtualHosts."${cfg.domain}" = lib.mkMerge [
        cfg.nginx.virtualHost
        {
          root = lib.mkForce "${cfg.package}";

          locations."/" = {
            index = "index.html";
            extraConfig = ''
              try_files $uri $uri/ /index.html;
            '';
          };

          locations."~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$".extraConfig = ''
            expires 1y;
            add_header Cache-Control "public, immutable";
          '';
        }
      ];
    };

    services.caddy = lib.mkIf cfg.caddy.enable {
      enable = lib.mkDefault true;
      virtualHosts."${cfg.domain}" = lib.mkMerge [
        cfg.caddy.virtualHost
        {
          hostName = lib.mkForce cfg.domain;
          extraConfig = ''
            root * ${cfg.package}
            try_files {path} /index.html
            file_server

            @static {
              path_regexp static \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$
            }
            handle @static {
              header {
                Cache-Control "public, immutable"
              }
              header Cache-Control max-age=31536000
            }
          '';
        }
      ];
    };
  };

  meta.maintainers = with lib.maintainers; [
    charludo
    stunkymonkey
  ];
}
+1 −0
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@ in
  beanstalkd = runTest ./beanstalkd.nix;
  bees = runTest ./bees.nix;
  benchexec = runTest ./benchexec.nix;
  bentopdf = handleTest ./bentopdf { };
  beszel = runTest ./beszel.nix;
  binary-cache = runTest {
    imports = [ ./binary-cache.nix ];
+28 −0
Original line number Diff line number Diff line
import ../make-test-python.nix (
  { lib, ... }:

  {
    name = "bentopdf-caddy";
    meta.maintainers = with lib.maintainers; [ stunkymonkey ];

    nodes.machine =
      { pkgs, ... }:
      {
        services.bentopdf = {
          enable = true;
          domain = "localhost:80";
          caddy.enable = true;
          caddy.virtualHost.extraConfig = "tls internal";
        };
        # disable letsencrypt cert fetching
        services.caddy.globalConfig = "auto_https disable_certs";
      };

    testScript = ''
      machine.wait_for_unit("caddy.service")
      machine.wait_for_open_port(80)
      machine.succeed("curl -vvv --fail --show-error --silent --location --insecure http://localhost/")
      assert "<title>BentoPDF - The Privacy First PDF Toolkit</title>" in machine.succeed("curl --fail --show-error --silent --location --insecure http://localhost/")
    '';
  }
)
Loading