Update paperless module

This commit is contained in:
Benjamin Bädorf 2023-02-07 15:56:19 +01:00
parent c434d1769f
commit 892aa2e4fa
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
3 changed files with 45 additions and 2 deletions

View file

@ -79,8 +79,8 @@ in {
config.pub-solar.paperless.enable
''
paperless.local:80 {
request_header Host localhost:28981
reverse_proxy localhost:28981
request_header Host localhost:${builtins.toString config.services.paperless.port}
reverse_proxy localhost:${builtins.toString config.services.paperless.port}
}
'')

View file

@ -23,6 +23,20 @@ in {
example = "/var/lib/paperless/consume";
default = "/home/${psCfg.user.name}/Documents";
};
scannerDefaultDevice = mkOption {
description = '' The scanner device. To find this, use `scanimage -L`.
For example, your output might be the following:
```
device `v4l:/dev/video3' is a Noname Logitech StreamCam virtual device
device `hp3900:libusb:005:002' is a Hewlett-Packard Scanjet G3010 flatbed scanner
```
Here, the scannerDevice is `hp3900:libusb:005:002`.
'';
type = types.str;
};
};
config = mkIf cfg.enable {
@ -30,10 +44,26 @@ in {
enable = true;
user = psCfg.user.name;
consumptionDir = cfg.consumptionDir;
address = "paperless.local";
extraConfig = {
PAPERLESS_OCR_LANGUAGE = cfg.ocrLanguage;
PAPERLESS_ADMIN_USER = psCfg.user.name;
PAPERLESS_AUTO_LOGIN_USERNAME = psCfg.user.name;
PAPERLESS_URL = "http://paperless.local";
};
};
home-manager = pkgs.lib.setAttrByPath ["users" psCfg.user.name] {
home.packages = with pkgs; [
scan2paperless
];
home.sessionVariables = {
SCANNER_DEFAULT_DEVICE = cfg.scannerDefaultDevice;
SCANNER_OUTPUT_DIR = cfg.consumptionDir;
};
systemd.user.sessionVariables = {
SCANNER_DEFAULT_DEVICE = cfg.scannerDefaultDevice;
SCANNER_OUTPUT_DIR = cfg.consumptionDir;
};
};
};

View file

@ -1,4 +1,17 @@
self:
with self; ''
export PATH=${lib.makeBinPath [pkgs.coreutils pkgs.sane-frontends pkgs.sane-backends pkgs.ghostscript pkgs.imagemagick]}
while true;
do
read -p "Press Enter to continue or Ctrl+C to stop" < /dev/tty
DATETIME=$(date -Iseconds)
scanimage \
-d "''${SCANNER_DEFAULT_DEVICE}" \
--format=jpeg \
--resolution 300 \
--progress \
-o "''${SCANNER_OUTPUT_DIR}/''${DATETIME}.jpg"
done
''