Merge pull request #242275 from Atemu/nixos/paperless-manage-toShellVars

nixos/paperless: use toShellVars for paperless-manage

authored by Martin Weinelt and committed by GitHub 6847465f 821c7274

+22 -12
+22 -12
nixos/modules/services/misc/paperless.nix
··· 26 26 lib.mapAttrs (_: toString) cfg.extraConfig 27 27 ); 28 28 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 - ''; 29 + manage = pkgs.writeShellScript "manage" '' 30 + set -o allexport # Export the following env vars 31 + ${lib.toShellVars env} 32 + exec ${pkg}/bin/paperless-ngx "$@" 33 + ''; 37 34 38 35 # Secure the services 39 36 defaultServiceConfig = { ··· 172 169 description = lib.mdDoc "Web interface port."; 173 170 }; 174 171 172 + # FIXME this should become an RFC42-style settings attr 175 173 extraConfig = mkOption { 176 174 type = types.attrs; 177 175 default = { }; ··· 180 178 181 179 See [the documentation](https://paperless-ngx.readthedocs.io/en/latest/configuration.html) 182 180 for available options. 181 + 182 + Note that some options such as `PAPERLESS_CONSUMER_IGNORE_PATTERN` expect JSON values. Use `builtins.toJSON` to ensure proper quoting. 183 183 ''; 184 - example = { 185 - PAPERLESS_OCR_LANGUAGE = "deu+eng"; 186 - PAPERLESS_DBHOST = "/run/postgresql"; 187 - }; 184 + example = literalExpression '' 185 + { 186 + PAPERLESS_OCR_LANGUAGE = "deu+eng"; 187 + 188 + PAPERLESS_DBHOST = "/run/postgresql"; 189 + 190 + PAPERLESS_CONSUMER_IGNORE_PATTERN = builtins.toJSON [ ".DS_STORE/*" "desktop.ini" ]; 191 + 192 + PAPERLESS_OCR_USER_ARGS = builtins.toJSON { 193 + optimize = 1; 194 + pdfa_image_compression = "lossless"; 195 + }; 196 + }; 197 + ''; 188 198 }; 189 199 190 200 user = mkOption {