2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, gettext, pkgconfig
|
|
|
|
, avahi, libgphoto2, libieee1284, libjpeg, libpng, libtiff, libusb1, libv4l, net-snmp
|
|
|
|
|
|
|
|
# List of { src name backend } attibute sets - see installFirmware below:
|
|
|
|
, extraFirmware ? []
|
|
|
|
|
|
|
|
# For backwards compatibility with older setups; use extraFirmware instead:
|
|
|
|
, gt68xxFirmware ? null, snapscanFirmware ? null
|
|
|
|
|
|
|
|
# Passed from versioned package (e.g. default.nix, git.nix):
|
|
|
|
, version, src, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
name = "sane-backends-${version}";
|
|
|
|
|
|
|
|
outputs = [ "out" "doc" "man" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
gettext
|
|
|
|
pkgconfig
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
avahi
|
|
|
|
libgphoto2
|
|
|
|
libieee1284
|
|
|
|
libjpeg
|
|
|
|
libpng
|
|
|
|
libtiff
|
|
|
|
libusb1
|
|
|
|
libv4l
|
|
|
|
net-snmp
|
|
|
|
];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
configureFlags = []
|
2021-01-17 00:15:33 +00:00
|
|
|
++ lib.optional (avahi != null) "--enable-avahi"
|
|
|
|
++ lib.optional (libusb1 != null) "--with-usb"
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
postInstall = let
|
|
|
|
|
|
|
|
compatFirmware = extraFirmware
|
2021-01-17 00:15:33 +00:00
|
|
|
++ lib.optional (gt68xxFirmware != null) {
|
2020-04-24 23:36:52 +00:00
|
|
|
src = gt68xxFirmware.fw;
|
|
|
|
inherit (gt68xxFirmware) name;
|
|
|
|
backend = "gt68xx";
|
|
|
|
}
|
2021-01-17 00:15:33 +00:00
|
|
|
++ lib.optional (snapscanFirmware != null) {
|
2020-04-24 23:36:52 +00:00
|
|
|
src = snapscanFirmware;
|
|
|
|
name = "your-firmwarefile.bin";
|
|
|
|
backend = "snapscan";
|
|
|
|
};
|
|
|
|
|
|
|
|
installFirmware = f: ''
|
|
|
|
mkdir -p $out/share/sane/${f.backend}
|
|
|
|
ln -sv ${f.src} $out/share/sane/${f.backend}/${f.name}
|
|
|
|
'';
|
|
|
|
|
|
|
|
in ''
|
|
|
|
mkdir -p $out/etc/udev/rules.d/
|
|
|
|
./tools/sane-desc -m udev > $out/etc/udev/rules.d/49-libsane.rules || \
|
|
|
|
cp tools/udev/libsane.rules $out/etc/udev/rules.d/49-libsane.rules
|
|
|
|
# the created 49-libsane references /bin/sh
|
|
|
|
substituteInPlace $out/etc/udev/rules.d/49-libsane.rules \
|
|
|
|
--replace "RUN+=\"/bin/sh" "RUN+=\"${stdenv.shell}"
|
|
|
|
|
|
|
|
substituteInPlace $out/lib/libsane.la \
|
|
|
|
--replace "-ljpeg" "-L${libjpeg.out}/lib -ljpeg"
|
|
|
|
|
|
|
|
# net.conf conflicts with the file generated by the nixos module
|
|
|
|
rm -f $out/etc/sane.d/net.conf
|
2021-01-17 00:15:33 +00:00
|
|
|
'' + lib.concatStrings (builtins.map installFirmware compatFirmware);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "SANE (Scanner Access Now Easy) backends";
|
|
|
|
longDescription = ''
|
|
|
|
Collection of open-source SANE backends (device drivers).
|
|
|
|
SANE is a universal scanner interface providing standardized access to
|
|
|
|
any raster image scanner hardware: flatbed scanners, hand-held scanners,
|
|
|
|
video- and still-cameras, frame-grabbers, etc. For a list of supported
|
|
|
|
scanners, see http://www.sane-project.org/sane-backends.html.
|
|
|
|
'';
|
|
|
|
homepage = "http://www.sane-project.org/";
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
|
|
|
|
maintainers = with maintainers; [ peti ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|