9 cfg = config.services.stirling-pdf;
12 options.services.stirling-pdf = {
13 enable = lib.mkEnableOption "the stirling-pdf service";
15 package = lib.mkPackageOption pkgs "stirling-pdf" { };
17 environment = lib.mkOption {
18 type = lib.types.attrsOf (
27 INSTALL_BOOK_AND_ADVANCED_HTML_OPS = "true";
30 Environment variables for the stirling-pdf app.
31 See https://github.com/Stirling-Tools/Stirling-PDF#customisation for available options.
35 environmentFiles = lib.mkOption {
36 type = lib.types.listOf lib.types.path;
39 Files containing additional environment variables to pass to Stirling PDF.
40 Secrets should be added in environmentFiles instead of environment.
45 config = lib.mkIf cfg.enable {
46 systemd.services.stirling-pdf = {
47 environment = lib.mapAttrs (_: toString) cfg.environment;
49 # following https://github.com/Stirling-Tools/Stirling-PDF#locally
61 python3Packages.weasyprint
64 ++ lib.optional (cfg.environment.INSTALL_BOOK_AND_ADVANCED_HTML_OPS or "false" == "true") calibre;
66 wantedBy = [ "multi-user.target" ];
69 BindReadOnlyPaths = [ "${pkgs.tesseract}/share/tessdata:/usr/share/tessdata" ];
70 CacheDirectory = "stirling-pdf";
71 Environment = [ "HOME=%S/stirling-pdf" ];
72 EnvironmentFile = cfg.environmentFiles;
73 ExecStart = lib.getExe cfg.package;
74 RuntimeDirectory = "stirling-pdf";
75 StateDirectory = "stirling-pdf";
76 SuccessExitStatus = 143;
77 User = "stirling-pdf";
78 WorkingDirectory = "/var/lib/stirling-pdf";
81 CapabilityBoundingSet = "";
83 LockPersonality = true;
84 NoNewPrivileges = true;
85 PrivateDevices = true;
89 ProtectControlGroups = true;
91 ProtectHostname = true;
92 ProtectKernelLogs = true;
93 ProtectKernelModules = true;
94 ProtectKernelTunables = true;
95 ProtectProc = "invisible";
96 RestrictAddressFamilies = [
101 RestrictNamespaces = true;
102 RestrictRealtime = true;
103 SystemCallArchitectures = "native";
105 "~@cpu-emulation @debug @keyring @mount @obsolete @privileged @resources @clock @setuid @chown"
112 meta.maintainers = with lib.maintainers; [ DCsunset ];