os/modules/paperless/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

96 lines
2.5 KiB
Nix
Raw Normal View History

2023-01-28 21:27:52 +00:00
{
lib,
config,
pkgs,
2023-02-07 23:31:55 +00:00
masterModulesPath,
2023-02-21 11:37:18 +00:00
inputs,
2023-01-28 21:27:52 +00:00
...
}:
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 {
2023-02-07 23:31:55 +00:00
imports = [
"${masterModulesPath}/services/misc/paperless.nix"
];
disabledModules = [
"services/misc/paperless.nix"
];
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";
};
2023-02-07 23:31:55 +00:00
dataDir = mkOption {
description = "Directory to save data in";
type = types.str;
example = "/home/pub_solar/Paperless";
default = "/home/${psCfg.user.name}/Paperless";
};
2022-02-14 09:49:49 +00:00
consumptionDir = mkOption {
description = "Directory to be watched";
type = types.str;
example = "/var/lib/paperless/consume";
2023-02-07 23:31:55 +00:00
default = "/var/lib/paperless/consume";
2022-02-14 09:49:49 +00:00
};
2023-02-07 23:31:55 +00:00
2023-02-07 14:56:19 +00:00
scannerDefaultDevice = mkOption {
2023-02-07 23:31:55 +00:00
description = ''
The scanner device. To find this, use `scanimage -L`.
2023-02-07 14:56:19 +00:00
2023-02-07 23:31:55 +00:00
For example, your output might be the following:
2023-02-07 14:56:19 +00:00
2023-02-07 23:31:55 +00:00
```
device `v4l:/dev/video3' is a Noname Logitech StreamCam virtual device
device `hp3900:libusb:005:002' is a Hewlett-Packard Scanjet G3010 flatbed scanner
```
2023-02-07 14:56:19 +00:00
2023-02-07 23:31:55 +00:00
Here, the scannerDevice is `hp3900:libusb:005:002`.
2023-02-07 14:56:19 +00:00
'';
type = types.str;
2023-02-24 17:33:01 +00:00
example = "hp3900:libusb:005:002";
default = "";
2023-02-07 14:56:19 +00:00
};
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 23:31:55 +00:00
dataDir = cfg.dataDir;
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; [
2023-02-21 11:37:18 +00:00
inputs.scan2paperless.legacyPackages.x86_64-linux.scan2paperless
sane-backends
2023-06-11 20:54:11 +00:00
python310Packages.img2pdf
2023-02-07 14:56:19 +00:00
];
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
};
};
};
}