Update paperless module

This commit is contained in:
Benjamin Bädorf 2023-02-21 12:37:18 +01:00
parent c04339c198
commit fd3cf376c3
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
5 changed files with 192 additions and 44 deletions

View file

@ -43,6 +43,27 @@
"type": "github"
}
},
"deno2nix": {
"inputs": {
"devshell": "devshell_2",
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1675869640,
"narHash": "sha256-HkSiT3VWfHaAUa/usB6+ywXKejZI7bh6yIoh2bTa0eE=",
"ref": "refs/heads/main",
"rev": "0b54d6ce4424039951c1c12cc4319836b76c1eaf",
"revCount": 32,
"type": "git",
"url": "https://git.pub.solar/b12f/deno2.nix.git"
},
"original": {
"type": "git",
"url": "https://git.pub.solar/b12f/deno2.nix.git"
}
},
"deploy": {
"inputs": {
"flake-compat": [
@ -89,6 +110,58 @@
"type": "github"
}
},
"devshell_2": {
"inputs": {
"flake-utils": [
"scan2paperless",
"deno2nix",
"flake-utils"
],
"nixpkgs": [
"scan2paperless",
"deno2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1667210711,
"narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=",
"owner": "numtide",
"repo": "devshell",
"rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"devshell_3": {
"inputs": {
"flake-utils": [
"scan2paperless",
"flake-utils"
],
"nixpkgs": [
"scan2paperless",
"nixpkgs"
]
},
"locked": {
"lastModified": 1675790942,
"narHash": "sha256-UfXATFXxACtdMQmwRZIdOc6CT4mwgbZBAnGxiUkgUM4=",
"owner": "numtide",
"repo": "devshell",
"rev": "6fe837bb4f540a1832522ec54604c453757836b2",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"digga": {
"inputs": {
"darwin": [
@ -145,6 +218,22 @@
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1668681692,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
@ -197,6 +286,36 @@
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home": {
"inputs": {
"nixpkgs": [
@ -221,11 +340,11 @@
},
"latest": {
"locked": {
"lastModified": 1675673983,
"narHash": "sha256-8hzNh1jtiPxL5r3ICNzSmpSzV7kGb3KwX+FS5BWJUTo=",
"lastModified": 1675763311,
"narHash": "sha256-bz0Q2H3mxsF1CUfk26Sl9Uzi8/HFjGFD/moZHz1HebU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5a350a8f31bb7ef0c6e79aea3795a890cf7743d4",
"rev": "fab09085df1b60d6a0870c8a89ce26d5a4a708c2",
"type": "github"
},
"original": {
@ -237,11 +356,11 @@
},
"master": {
"locked": {
"lastModified": 1675775932,
"narHash": "sha256-ysv4pFsZBU+/CZ01LbQW2T9HxRcR0LXBcAP1vYWQZag=",
"lastModified": 1675871537,
"narHash": "sha256-zx7BDeAGI2M19pRs2pmCuYp4W1CNC3QQSIU1BtcvaIY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e521a883757b06720d28d4a303e0b4f7f0d7fcfc",
"rev": "94a6a5c81a232a98c6df0977ab16019d759135e5",
"type": "github"
},
"original": {
@ -268,11 +387,11 @@
},
"nixos": {
"locked": {
"lastModified": 1675681488,
"narHash": "sha256-0E/oYpixC+joFk7UrY60TwZcdthzP2BXmJwne3Ni8ZI=",
"lastModified": 1675757258,
"narHash": "sha256-pIRer8vdsoherlRKpzfnHbMZ5TsAcvRlXHCIaHkIUbg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "13fdd3945d8a2da5e4afe35d8a629193a9680911",
"rev": "af96094e9b8eb162d70a84fa3b39f4b7a8b264d2",
"type": "github"
},
"original": {
@ -303,11 +422,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1674550793,
"narHash": "sha256-ljJlIFQZwtBbzWqWTmmw2O5BFmQf1A/DspwMOQtGXHk=",
"lastModified": 1675785029,
"narHash": "sha256-EoD3Wgqc0XWkBCwUrAxCIZett64jN/SEPPpXX2mCmrE=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "b7ac0a56029e4f9e6743b9993037a5aaafd57103",
"rev": "16b6928ec622fd2356a80c0a9359eb350a94227d",
"type": "github"
},
"original": {
@ -348,6 +467,38 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1670332253,
"narHash": "sha256-O5SmhlIUt1s+vK4NXeGYqwcBIMwbBPAEZ3GHE3XT28c=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1c9ffcf70786f0966982ce0fc76ec05df2e1dec2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1675763311,
"narHash": "sha256-bz0Q2H3mxsF1CUfk26Sl9Uzi8/HFjGFD/moZHz1HebU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "fab09085df1b60d6a0870c8a89ce26d5a4a708c2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 0,
@ -390,7 +541,29 @@
"nixos-generators": "nixos-generators",
"nixos-hardware": "nixos-hardware",
"nur": "nur",
"pub-solar": "pub-solar"
"pub-solar": "pub-solar",
"scan2paperless": "scan2paperless"
}
},
"scan2paperless": {
"inputs": {
"deno2nix": "deno2nix",
"devshell": "devshell_3",
"flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1675874729,
"narHash": "sha256-FhoV70g+H83XYxD5jF3963t4k7u967c/nZudHhTgxB0=",
"ref": "refs/heads/main",
"rev": "7ec158e547377bbe3a6dd7b5a2f6e141834d4c94",
"revCount": 8,
"type": "git",
"url": "https://git.pub.solar/b12f/scan2paperless.git"
},
"original": {
"type": "git",
"url": "https://git.pub.solar/b12f/scan2paperless.git"
}
},
"utils": {

View file

@ -41,6 +41,7 @@
master.url = "github:nixos/nixpkgs/master";
pub-solar.url = "github:pub-solar/nixpkgs/fix/use-latest-unstable-yubikey-agent";
scan2paperless.url = "git+https://git.pub.solar/b12f/scan2paperless.git";
};
outputs = {
@ -52,6 +53,7 @@
nur,
agenix,
deploy,
scan2paperless,
...
} @ inputs:
digga.lib.mkFlake

View file

@ -3,6 +3,7 @@
config,
pkgs,
masterModulesPath,
inputs,
...
}:
with lib; let
@ -75,7 +76,9 @@ in {
home-manager = pkgs.lib.setAttrByPath ["users" psCfg.user.name] {
home.packages = with pkgs; [
scan2paperless
inputs.scan2paperless.legacyPackages.x86_64-linux.scan2paperless
sane-backends
python39Packages.img2pdf
];
home.sessionVariables = {
SCANNER_DEFAULT_DEVICE = cfg.scannerDefaultDevice;

View file

@ -19,5 +19,4 @@ with final; {
wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final);
drone-docker-runner = writeShellScriptBin "drone-docker-runner" (import ./drone-docker-runner.nix final);
record-screen = writeShellScriptBin "record-screen" (import ./record-screen.nix final);
scan2paperless = writeShellScriptBin "scan2paperless" (import ./scan2paperless.nix final);
}

View file

@ -1,29 +0,0 @@
self:
with self; ''
export PATH=${lib.makeBinPath [pkgs.coreutils pkgs.sane-frontends pkgs.sane-backends pkgs.ghostscript pkgs.imagemagick]}
NAME=$([ "$1" == "" ] && date -Iseconds || echo "$1")
TMPDIR=$(mktemp -d)
echo "Using ''${NAME}.pdf as filename"
RESPONSE=""
while [ -z "$RESPONSE" ];
do
DATETIME=$(date -Iseconds)
echo "Starting scan $DATETIME"
scanimage \
-d "''${SCANNER_DEFAULT_DEVICE}" \
--format=jpeg \
--resolution 300 \
--progress \
-o "''${TMPDIR}/''${DATETIME}.jpg"
read -p "Press ENTER to scan another page, or any other key to generate the final PDF: " RESPONSE < /dev/tty
done
${python39Packages.img2pdf}/bin/img2pdf --output "''${SCANNER_OUTPUT_DIR}/''${NAME}.pdf" ''${TMPDIR}/*
rm -rf TMPDIR
''