···2727 name = "paperless_ngx_nltk_data";
2828 paths = pkg.nltkData;
2929 };
3030+ } // optionalAttrs (cfg.openMPThreadingWorkaround) {
3131+ OMP_NUM_THREADS = "1";
3032 } // (lib.mapAttrs (_: s:
3133 if (lib.isAttrs s || lib.isList s) then builtins.toJSON s
3234 else if lib.isBool s then lib.boolToString s
···199201 };
200202201203 package = mkPackageOption pkgs "paperless-ngx" { };
204204+205205+ openMPThreadingWorkaround = mkEnableOption ''
206206+ a workaround for document classifier timeouts.
207207+208208+ Paperless uses OpenBLAS via scikit-learn for document classification.
209209+210210+ The default is to use threading for OpenMP but this would cause the
211211+ document classifier to spin on one core seemingly indefinitely if there
212212+ are large amounts of classes per classification; causing it to
213213+ effectively never complete due to running into timeouts.
214214+215215+ This sets `OMP_NUM_THREADS` to `1` in order to mitigate the issue. See
216216+ https://github.com/NixOS/nixpkgs/issues/240591 for more information.
217217+ '' // mkOption { default = true; };
202218 };
203219204220 config = mkIf cfg.enable {