2023-01-28 21:27:52 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2022-02-14 09:49:49 +00:00
|
|
|
psCfg = config.pub-solar;
|
|
|
|
cfg = config.pub-solar.paperless;
|
|
|
|
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
|
2023-01-28 21:27:52 +00:00
|
|
|
in {
|
2022-02-14 09:49:49 +00:00
|
|
|
options.pub-solar.paperless = {
|
|
|
|
enable = mkEnableOption "All you need to go paperless";
|
|
|
|
ocrLanguage = mkOption {
|
|
|
|
description = "OCR language";
|
|
|
|
type = types.str;
|
|
|
|
example = "eng+deu";
|
|
|
|
default = "eng";
|
|
|
|
};
|
|
|
|
consumptionDir = mkOption {
|
|
|
|
description = "Directory to be watched";
|
|
|
|
type = types.str;
|
|
|
|
example = "/var/lib/paperless/consume";
|
|
|
|
default = "/home/${psCfg.user.name}/Documents";
|
|
|
|
};
|
2023-02-07 14:56:19 +00:00
|
|
|
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;
|
|
|
|
};
|
2022-02-14 09:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2022-11-28 10:39:28 +00:00
|
|
|
services.paperless = {
|
2022-02-14 09:49:49 +00:00
|
|
|
enable = true;
|
2022-11-28 10:39:28 +00:00
|
|
|
user = psCfg.user.name;
|
2022-02-14 09:49:49 +00:00
|
|
|
consumptionDir = cfg.consumptionDir;
|
2023-02-07 14:56:19 +00:00
|
|
|
address = "paperless.local";
|
2022-02-14 09:49:49 +00:00
|
|
|
extraConfig = {
|
|
|
|
PAPERLESS_OCR_LANGUAGE = cfg.ocrLanguage;
|
2022-11-28 10:39:28 +00:00
|
|
|
PAPERLESS_ADMIN_USER = psCfg.user.name;
|
|
|
|
PAPERLESS_AUTO_LOGIN_USERNAME = psCfg.user.name;
|
2023-02-07 14:56:19 +00:00
|
|
|
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;
|
2022-02-14 09:49:49 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|