Merge pull request #215750 from puppe/fix-paperless

nixos/paperless: download NLTK data

authored by Luke Granger-Brown and committed by GitHub b3c09089 ccbbe66c

+40 -8
+39 -7
nixos/modules/services/misc/paperless.nix
··· 6 6 pkg = cfg.package; 7 7 8 8 defaultUser = "paperless"; 9 + nltkDir = "/var/cache/paperless/nltk"; 9 10 10 11 # Don't start a redis instance if the user sets a custom redis connection 11 12 enableRedis = !hasAttr "PAPERLESS_REDIS" cfg.extraConfig; ··· 15 16 PAPERLESS_DATA_DIR = cfg.dataDir; 16 17 PAPERLESS_MEDIA_ROOT = cfg.mediaDir; 17 18 PAPERLESS_CONSUMPTION_DIR = cfg.consumptionDir; 19 + PAPERLESS_NLTK_DIR = nltkDir; 18 20 GUNICORN_CMD_ARGS = "--bind=${cfg.address}:${toString cfg.port}"; 19 21 } // optionalAttrs (config.time.timeZone != null) { 20 22 PAPERLESS_TIME_ZONE = config.time.timeZone; ··· 24 26 lib.mapAttrs (_: toString) cfg.extraConfig 25 27 ); 26 28 27 - manage = let 28 - setupEnv = lib.concatStringsSep "\n" (mapAttrsToList (name: val: "export ${name}=\"${val}\"") env); 29 - in pkgs.writeShellScript "manage" '' 30 - ${setupEnv} 31 - exec ${pkg}/bin/paperless-ngx "$@" 32 - ''; 29 + manage = 30 + let 31 + setupEnv = lib.concatStringsSep "\n" (mapAttrsToList (name: val: "export ${name}=\"${val}\"") env); 32 + in 33 + pkgs.writeShellScript "manage" '' 34 + ${setupEnv} 35 + exec ${pkg}/bin/paperless-ngx "$@" 36 + ''; 33 37 34 38 # Secure the services 35 39 defaultServiceConfig = { ··· 47 51 cfg.dataDir 48 52 cfg.mediaDir 49 53 ]; 54 + CacheDirectory = "paperless"; 50 55 CapabilityBoundingSet = ""; 51 56 # ProtectClock adds DeviceAllow=char-rtc r 52 57 DeviceAllow = ""; ··· 170 175 171 176 extraConfig = mkOption { 172 177 type = types.attrs; 173 - default = {}; 178 + default = { }; 174 179 description = lib.mdDoc '' 175 180 Extra paperless config options. 176 181 ··· 288 293 '${cfg.passwordFile}' '${cfg.dataDir}/superuser-password' 289 294 ''; 290 295 Type = "oneshot"; 296 + }; 297 + }; 298 + 299 + # Download NLTK corpus data 300 + systemd.services.paperless-download-nltk-data = { 301 + wantedBy = [ "paperless-scheduler.service" ]; 302 + before = [ "paperless-scheduler.service" ]; 303 + after = [ "network-online.target" ]; 304 + serviceConfig = defaultServiceConfig // { 305 + User = cfg.user; 306 + Type = "oneshot"; 307 + # Enable internet access 308 + PrivateNetwork = false; 309 + # Restrict write access 310 + BindPaths = []; 311 + BindReadOnlyPaths = [ 312 + "/nix/store" 313 + "-/etc/resolv.conf" 314 + "-/etc/nsswitch.conf" 315 + "-/etc/ssl/certs" 316 + "-/etc/static/ssl/certs" 317 + "-/etc/hosts" 318 + "-/etc/localtime" 319 + ]; 320 + ExecStart = let pythonWithNltk = pkg.python.withPackages (ps: [ ps.nltk ]); in '' 321 + ${pythonWithNltk}/bin/python -m nltk.downloader -d '${nltkDir}' punkt snowball_data stopwords 322 + ''; 291 323 }; 292 324 }; 293 325
+1 -1
pkgs/applications/office/paperless-ngx/default.nix
··· 318 318 319 319 meta = with lib; { 320 320 description = "Tool to scan, index, and archive all of your physical documents"; 321 - homepage = "https://paperless-ngx.readthedocs.io/"; 321 + homepage = "https://docs.paperless-ngx.com/"; 322 322 changelog = "https://github.com/paperless-ngx/paperless-ngx/releases/tag/v${version}"; 323 323 license = licenses.gpl3Only; 324 324 maintainers = with maintainers; [ lukegb gador erikarvstedt ];