{ flake, lib, config, pkgs, ... }: with lib; let psCfg = config.pub-solar; xdg = config.home-manager.users."${psCfg.user.name}".xdg; dataDir = "${xdg.dataHome}/Paperless"; consumptionDir = "/home/${psCfg.user.name}/.local/share/scandir"; scannerDefaultDevice = "hp3900:libusb:005:004"; in { services.paperless = { enable = true; user = psCfg.user.name; consumptionDir = consumptionDir; dataDir = dataDir; address = "paperless.local"; extraConfig = { PAPERLESS_OCR_LANGUAGE = "nld+deu"; PAPERLESS_ADMIN_USER = psCfg.user.name; PAPERLESS_AUTO_LOGIN_USERNAME = psCfg.user.name; PAPERLESS_URL = "http://paperless.local"; }; }; users.users."${psCfg.user.name}".packages = with pkgs; [ scan2paperless sane-backends python310Packages.img2pdf ]; home-manager.users."${psCfg.user.name}" = { home.sessionVariables = { SCANNER_DEFAULT_DEVICE = scannerDefaultDevice; SCANNER_OUTPUT_DIR = consumptionDir; }; systemd.user.sessionVariables = { SCANNER_DEFAULT_DEVICE = scannerDefaultDevice; SCANNER_OUTPUT_DIR = consumptionDir; }; }; networking.hosts = flake.self.lib.addLocalHostname ["paperless.local"]; services.caddy.extraConfig = '' paperless.local:80 { request_header Host localhost:${builtins.toString config.services.paperless.port} reverse_proxy localhost:${builtins.toString config.services.paperless.port} } ''; }