diff --git a/flake.lock b/flake.lock index 2105e2b..bf8069b 100644 --- a/flake.lock +++ b/flake.lock @@ -81,27 +81,6 @@ "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": { "inputs": { "flake-compat": [ @@ -126,51 +105,6 @@ "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": false, "locked": { @@ -187,22 +121,6 @@ "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": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -236,42 +154,6 @@ "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": { "inputs": { "nixpkgs": [ @@ -439,22 +321,6 @@ "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": { "inputs": { "adblock-unbound": "adblock-unbound", @@ -469,91 +335,7 @@ "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_2", "nixpkgs-master": "nixpkgs-master", - "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" + "nixpkgs-unstable": "nixpkgs-unstable" } }, "utils": { diff --git a/flake.nix b/flake.nix index b3feb3b..c6b6a3d 100644 --- a/flake.nix +++ b/flake.nix @@ -30,9 +30,6 @@ mobile-nixos.url = "github:nixos/mobile-nixos"; 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"; adblock-unbound.url = "github:MayNiklas/nixos-adblock-unbound"; diff --git a/hosts/chocolatebar/hardware-configuration.nix b/hosts/chocolatebar/hardware-configuration.nix index c4e60e5..cfe73c1 100644 --- a/hosts/chocolatebar/hardware-configuration.nix +++ b/hosts/chocolatebar/hardware-configuration.nix @@ -32,7 +32,7 @@ swapDevices = [ { device = "/swapfile"; - size = 132 * 1024; # 132 GB + size = 128 * 1024; # 132 GB } ]; } diff --git a/hosts/pie/paperless.nix b/hosts/pie/paperless.nix index 79f1a10..9ffd48c 100644 --- a/hosts/pie/paperless.nix +++ b/hosts/pie/paperless.nix @@ -12,6 +12,34 @@ with lib; let dataDir = "${xdg.dataHome}/Paperless"; backupDir = "${xdg.dataHome}/PaperlessBackup"; 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 " + 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 { services.paperless = { enable = true; @@ -33,7 +61,7 @@ in { }; users.users."${psCfg.user.name}".packages = with pkgs; [ - # scan2paperless + scan2paperless sane-backends python310Packages.img2pdf ]; diff --git a/overlays/default.nix b/overlays/default.nix index d2f70d4..8030fe4 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -10,7 +10,6 @@ (final: prev: let unstable = import inputs.nixpkgs-unstable { system = prev.system; }; master = import inputs.nixpkgs-master { system = prev.system; }; - scan2paperless = import inputs.scan2paperless { system = prev.system; }; in { nixd = unstable.nixd; @@ -18,8 +17,6 @@ paperless-ngx = master.paperless-ngx; waybar = master.waybar; - scan2paperless = scan2paperless.scan2paperless; - adlist = inputs.adblock-unbound.packages.${prev.system}; haskellPackages =