nixos/modules/scanner.nix

30 lines
641 B
Nix

{pkgs, ...}: let
# TODO: Can I specify this in a better way?
device = "gt68xx";
scan-a4 = pkgs.writeShellApplication {
name = "scan-a4";
runtimeInputs = with pkgs; [
sane-backends
imagemagick
];
text = ''
if [[ -z $1 ]]; then
echo "Missing filename"
exit 1
fi
scanimage --device-name ${device} \
-x 210 \
-y 297 \
-o /tmp/last-scan.png \
--resolution 150 || exit 2
convert /tmp/last-scan.png "$1" || exit 3
'';
};
in {
hardware.sane.enable = true;
environment.systemPackages = [scan-a4];
}