improve module

This commit is contained in:
Prunebutt 2025-09-27 22:26:10 +02:00
parent c8ce4db2a2
commit 3289b801f5
2 changed files with 20 additions and 4 deletions

View file

@ -27,7 +27,7 @@
runtimeInputs = with pkgs; [sane-backends brscan5 ghostscript];
text = builtins.readFile ./scanbuddy.bash;
text = builtins.readFile ./scanbuddy.sh;
};
# Returns an attribute set that can be passed to `buildPythonPackage`.
@ -66,10 +66,20 @@
lib,
...
}: {
options = {
service.scanbuddy = lib.mkEnableOption "Enable the scanbuddy server";
options = let
inherit (lib) mkOption mkEnableOption types;
in {
services.scanbuddy = {
enable = mkEnableOption "Enable the scanbuddy server";
environment = mkOption {
type = types.attrsOf (types.nullOr (types.oneOf [types.str types.path types.package]));
default = {};
};
config = {
};
};
config = let
cfg = config.services.scanbuddy;
in {
systemd.services.scanbuddy = lib.mkIf config.service.scanbuddy {
description = "The scanbuddy webservice";
wantedBy = ["multi-user.target"];
@ -78,6 +88,7 @@
Path = ["${scanbuddy-pkg}/bin"];
WorkingDirectory = "/var/lib/scanbuddy";
};
environment = cfg.environment;
};
};
};

View file

@ -87,6 +87,11 @@ dispatch() {
gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE="$combined_file" -dBATCH "${out_files[@]}"
echo "Merged pdf written to $combined_file"
# TODO
if [ ! -v PAPERLESS_TOKEN ]; then
true
fi
# send to paperless
PAPERLESS_STATUS=$(curl \
-H "Authorization: Token $PAPERLESS_TOKEN" \