28 lines
625 B
Nix
28 lines
625 B
Nix
{ pkgs, ... }:
|
|
|
|
let
|
|
scan = "${pkgs.sane-backends}/bin/scanimage";
|
|
convert = "${pkgs.imagemagick}/bin/convert";
|
|
# TODO: Can I specify this in a better way?
|
|
device = "gt68xx";
|
|
|
|
scan-a4 = pkgs.writeScriptBin "scan-a4" ''
|
|
#!${pkgs.stdenv.shell}
|
|
if [[ -z $1 ]]; then
|
|
echo "Missing filename"
|
|
exit 1
|
|
fi
|
|
|
|
${scan} --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 ];
|
|
}
|