fix: use internal scan2paperless

This commit is contained in:
Benjamin Bädorf 2023-11-20 17:29:03 +01:00
parent 0730673921
commit 8405999277
No known key found for this signature in database
GPG key ID: 1B7BF5B77A521346
5 changed files with 31 additions and 227 deletions

View file

@ -81,27 +81,6 @@
"type": "github" "type": "github"
} }
}, },
"deno2nix": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1686513235,
"narHash": "sha256-gVYRft/579iBC1J3gukn1CMIWrKksHm/GRA47+nvXRc=",
"ref": "refs/heads/main",
"rev": "193e1c9447d56fe434e4ab0983b2bb92f1c22255",
"revCount": 36,
"type": "git",
"url": "https://git.pub.solar/b12f/deno2.nix.git"
},
"original": {
"type": "git",
"url": "https://git.pub.solar/b12f/deno2.nix.git"
}
},
"deploy-rs": { "deploy-rs": {
"inputs": { "inputs": {
"flake-compat": [ "flake-compat": [
@ -126,51 +105,6 @@
"type": "github" "type": "github"
} }
}, },
"devshell": {
"inputs": {
"nixpkgs": [
"scan2paperless",
"deno2nix",
"nixpkgs"
],
"systems": "systems"
},
"locked": {
"lastModified": 1685972731,
"narHash": "sha256-VpwVUthxs3AFgvWxGTHu+KVDnS/zT3xkCtmjX2PjNQs=",
"owner": "numtide",
"repo": "devshell",
"rev": "6b2554d28d46bfa6e24b941e999a145760dad0e1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"devshell_2": {
"inputs": {
"nixpkgs": [
"scan2paperless",
"nixpkgs"
],
"systems": "systems_3"
},
"locked": {
"lastModified": 1698410321,
"narHash": "sha256-MphuSlgpmKwtJncGMohryHiK55J1n6WzVQ/OAfmfoMc=",
"owner": "numtide",
"repo": "devshell",
"rev": "1aed986e3c81a4f6698e85a7452cbfcc4b31a36e",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -187,22 +121,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
@ -236,42 +154,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_4"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -439,22 +321,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1686412476,
"narHash": "sha256-inl9SVk6o5h75XKC79qrDCAobTD1Jxh6kVYTZKHzewA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "21951114383770f96ae528d0ae68824557768e81",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"adblock-unbound": "adblock-unbound", "adblock-unbound": "adblock-unbound",
@ -469,91 +335,7 @@
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"nixpkgs-master": "nixpkgs-master", "nixpkgs-master": "nixpkgs-master",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable"
"scan2paperless": "scan2paperless"
}
},
"scan2paperless": {
"inputs": {
"deno2nix": "deno2nix",
"devshell": "devshell_2",
"flake-utils": "flake-utils_3",
"nixpkgs": [
"nixpkgs-unstable"
]
},
"locked": {
"lastModified": 1699822578,
"narHash": "sha256-+HO37PHDfJ/pv6NSEE7Yk8b0X22bCZbdP1v2sFnEo9c=",
"ref": "refs/heads/main",
"rev": "8d2f814a0ab37e8af2abaf95c6776771603cfc88",
"revCount": 13,
"type": "git",
"url": "https://git.pub.solar/b12f/scan2paperless.git"
},
"original": {
"type": "git",
"url": "https://git.pub.solar/b12f/scan2paperless.git"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
} }
}, },
"utils": { "utils": {

View file

@ -30,9 +30,6 @@
mobile-nixos.url = "github:nixos/mobile-nixos"; mobile-nixos.url = "github:nixos/mobile-nixos";
mobile-nixos.flake = false; mobile-nixos.flake = false;
scan2paperless.url = "git+https://git.pub.solar/b12f/scan2paperless.git";
scan2paperless.inputs.nixpkgs.follows = "nixpkgs-unstable";
musnix.url = "github:musnix/musnix"; musnix.url = "github:musnix/musnix";
adblock-unbound.url = "github:MayNiklas/nixos-adblock-unbound"; adblock-unbound.url = "github:MayNiklas/nixos-adblock-unbound";

View file

@ -32,7 +32,7 @@
swapDevices = [ swapDevices = [
{ {
device = "/swapfile"; device = "/swapfile";
size = 132 * 1024; # 132 GB size = 128 * 1024; # 132 GB
} }
]; ];
} }

View file

@ -12,6 +12,34 @@ with lib; let
dataDir = "${xdg.dataHome}/Paperless"; dataDir = "${xdg.dataHome}/Paperless";
backupDir = "${xdg.dataHome}/PaperlessBackup"; backupDir = "${xdg.dataHome}/PaperlessBackup";
consumptionDir = "/home/${psCfg.user.name}/.local/share/scandir"; consumptionDir = "/home/${psCfg.user.name}/.local/share/scandir";
scan2paperless = with pkgs; writeShellScriptBin "scan2paperless" ''
DEVICE=$1
NUM_PAGES=$2
NAME=$3
if [ -z "''${DEVICE}" ] || [ -z "''${NUM_PAGES}" ] || [ -z "''${NAME}" ]; then
echo "Usage: scan2paperless <device> <num_pages> <name>"
exit 1
fi
tmpDir=$(${coreutils}/bin/mktemp -d)
files=()
for i in $(seq 1 $NUM_PAGES); do
fileName=$(${openssl}/bin/openssl rand -hex 12)
file="$tmpDir/$fileName.jpg"
echo "Start scanning page $i/$NUM_PAGES";
${sane-backends}/bin/scanimage -d $DEVICE --format=jpeg --resolution 300 --progress -o $file
echo "Finished scanning page $i";
files+=($file)
done
pdf="${consumptionDir}/$NAME.pdf"
${python39Packages.img2pdf}/bin/img2pdf --output $pdf ''${files[@]}
echo "PDF written to $pdf"
'';
in { in {
services.paperless = { services.paperless = {
enable = true; enable = true;
@ -33,7 +61,7 @@ in {
}; };
users.users."${psCfg.user.name}".packages = with pkgs; [ users.users."${psCfg.user.name}".packages = with pkgs; [
# scan2paperless scan2paperless
sane-backends sane-backends
python310Packages.img2pdf python310Packages.img2pdf
]; ];

View file

@ -10,7 +10,6 @@
(final: prev: let (final: prev: let
unstable = import inputs.nixpkgs-unstable { system = prev.system; }; unstable = import inputs.nixpkgs-unstable { system = prev.system; };
master = import inputs.nixpkgs-master { system = prev.system; }; master = import inputs.nixpkgs-master { system = prev.system; };
scan2paperless = import inputs.scan2paperless { system = prev.system; };
in { in {
nixd = unstable.nixd; nixd = unstable.nixd;
@ -18,8 +17,6 @@
paperless-ngx = master.paperless-ngx; paperless-ngx = master.paperless-ngx;
waybar = master.waybar; waybar = master.waybar;
scan2paperless = scan2paperless.scan2paperless;
adlist = inputs.adblock-unbound.packages.${prev.system}; adlist = inputs.adblock-unbound.packages.${prev.system};
haskellPackages = haskellPackages =